Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use setuptools_scm for version #157

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
28 changes: 27 additions & 1 deletion Ska/engarchive/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from .version import __version__, __git_version__

from pkg_resources import get_distribution, DistributionNotFound

try:
_dist = get_distribution('Ska.engarchive') # hard-code only for this dual-name package
__version__ = _dist.version

# Check if this file is the same as what was found in the distribution.
# Windows does not necessarily respect the case so downcase everything.
assert __file__.lower().startswith(_dist.location.lower())

except (AssertionError, DistributionNotFound):
try:
# get_distribution found a different package from this file, must be in source repo
from setuptools_scm import get_version
from pathlib import Path

root = Path('..')
try:
__version__ = get_version(root=root, relative_to=__file__)
except LookupError:
__version__ = get_version(root=root / '..', relative_to=__file__)

except Exception:
import warnings
warnings.warn('Failed to find a package version, setting to 0.0.0')
__version__ = '0.0.0'


def test(*args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion Ska/engarchive/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .units import Units
from . import cache
from . import remote_access
from .version import __version__, __git_version__
from . import __version__

from Chandra.Time import DateTime

Expand Down
2 changes: 1 addition & 1 deletion Ska/engarchive/fetch_eng.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from .fetch import *
from . import fetch
from .version import version as __version__
from . import __version__

# Module-level units, defaults to CXC units (e.g. Kelvins etc)
UNITS = Units('eng')
Expand Down
2 changes: 1 addition & 1 deletion Ska/engarchive/fetch_sci.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from .fetch import *
from . import fetch
from .version import version as __version__
from . import __version__

# Module-level units, defaults to CXC units (e.g. Kelvins etc)
UNITS = Units('sci')
Expand Down
2 changes: 1 addition & 1 deletion Ska/engarchive/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from Ska.Matplotlib import plot_cxctime
from Chandra.Time import DateTime

from .version import version as __version__
from . import __version__

MIN_TSTART_UNIX = DateTime('1999:100').unix
MAX_TSTOP_UNIX = DateTime().unix + 1e7
Expand Down
150 changes: 0 additions & 150 deletions Ska/engarchive/version.py

This file was deleted.

1 change: 1 addition & 0 deletions cheta
26 changes: 10 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand

from Ska.engarchive.version import package_version

try:
from testr.setup_helper import cmdclass
except ImportError:
cmdclass = {}

# Write GIT revisions and SHA tag into <this_package/git_version.py>
# (same directory as version.py)
package_version.write_git_version_file()


setup(name='Ska.engarchive',
author='Tom Aldcroft',
description='Modules supporting Ska engineering telemetry archive',
author_email='aldcroft@head.cfa.harvard.edu',
use_scm_version=True,
setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'],
entry_points={'console_scripts': ['ska_fetch = Ska.engarchive.get_telem:main']},
py_modules=['Ska.engarchive.fetch', 'Ska.engarchive.converters', 'Ska.engarchive.utils',
'Ska.engarchive.get_telem'],
version=package_version.version,
zip_safe=False,
packages=['Ska', 'Ska.engarchive', 'Ska.engarchive.derived', 'Ska.engarchive.tests'],
package_dir={'Ska': 'Ska'},
package_data={'Ska.engarchive': ['*.dat', 'units_*.pkl', 'GIT_VERSION'],
'Ska.engarchive.tests': ['*.dat']},
package_dir={'Ska': 'Ska', 'cheta': 'Ska/engarchive'},
packages=['Ska', 'Ska.engarchive', 'Ska.engarchive.derived', 'Ska.engarchive.tests',
'cheta', 'cheta.derived', 'cheta.tests'],
package_data={'Ska.engarchive': ['*.dat', 'units_*.pkl'],
'Ska.engarchive.tests': ['*.dat'],
'cheta': ['*.dat', 'units_*.pkl'],
'cheta.tests': ['*.dat']},

tests_require=['pytest'],
cmdclass=cmdclass,
)