Skip to content

Commit

Permalink
Use Versioneer (#70)
Browse files Browse the repository at this point in the history
* Add versioneer

* Remove unnecessary try/catch in __init__.py

 - Version is no longer obtained by importing from __init__.py
  • Loading branch information
rebeccafair authored May 27, 2020
1 parent 76a689a commit 94c1283
Show file tree
Hide file tree
Showing 7 changed files with 2,380 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Added by versioneer
euphonic/_version.py export-subst
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
include c/*.h
include versioneer.py
include euphonic/_version.py
48 changes: 22 additions & 26 deletions euphonic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
__version__ = '0.2.2'
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions

try:
# Create ureg here so it is only created once. However, this
# __init__.py needs to be imported by setup.py to find __version__,
# so allow pint import to fail as in this case pint might not be
# installed yet
from pint import UnitRegistry
ureg = UnitRegistry()
ureg.enable_contexts('spectroscopy')
ureg.define('@alias bohr = INTERNAL_LENGTH_UNIT')
ureg.define('@alias electron_mass = INTERNAL_MASS_UNIT')
ureg.define('@alias hartree = INTERNAL_ENERGY_UNIT')
ureg.define('@alias elementary_charge = INTERNAL_CHARGE_UNIT')
ureg.define('@alias K = INTERNAL_TEMPERATURE_UNIT')
# Create ureg here so it is only created once
from pint import UnitRegistry
ureg = UnitRegistry()
ureg.enable_contexts('spectroscopy')
ureg.define('@alias bohr = INTERNAL_LENGTH_UNIT')
ureg.define('@alias electron_mass = INTERNAL_MASS_UNIT')
ureg.define('@alias hartree = INTERNAL_ENERGY_UNIT')
ureg.define('@alias elementary_charge = INTERNAL_CHARGE_UNIT')
ureg.define('@alias K = INTERNAL_TEMPERATURE_UNIT')

ureg.define('@alias angstrom = DEFAULT_LENGTH_UNIT')
ureg.define('@alias amu = DEFAULT_MASS_UNIT')
ureg.define('@alias eV = DEFAULT_ENERGY_UNIT')
ureg.define('@alias K = DEFAULT_TEMPERATURE_UNIT')
ureg.define('@alias angstrom = DEFAULT_LENGTH_UNIT')
ureg.define('@alias amu = DEFAULT_MASS_UNIT')
ureg.define('@alias eV = DEFAULT_ENERGY_UNIT')
ureg.define('@alias K = DEFAULT_TEMPERATURE_UNIT')

from .spectra import Spectrum1D, Spectrum2D
from .crystal import Crystal
from .debye_waller import DebyeWaller
from .structure_factor import StructureFactor
from .qpoint_phonon_modes import QpointPhononModes
from .force_constants import ForceConstants
except ImportError:
pass
from .spectra import Spectrum1D, Spectrum2D
from .crystal import Crystal
from .debye_waller import DebyeWaller
from .structure_factor import StructureFactor
from .qpoint_phonon_modes import QpointPhononModes
from .force_constants import ForceConstants
Loading

0 comments on commit 94c1283

Please sign in to comment.