diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 57b97964..00000000 --- a/.coveragerc +++ /dev/null @@ -1,28 +0,0 @@ -[run] -source = py/desidatamodel -omit = - py/desidatamodel/_version.py - py/desidatamodel/conftest* - py/desidatamodel/cython_version* - py/desidatamodel/setup_package* - py/desidatamodel/*/setup_package* - py/desidatamodel/*/*/setup_package* - py/desidatamodel/sphinx/* - py/desidatamodel/test/* - py/desidatamodel/*/test/* - py/desidatamodel/*/*/test/* - -[report] -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about packages we have installed - except ImportError - - # Don't complain if tests don't hit assertions - raise AssertionError - raise NotImplementedError - - # Don't complain about script hooks - def main\(.*\): diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e823ba85..4de8e16d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -18,23 +18,23 @@ jobs: matrix: os: [ubuntu-latest] python-version: ['3.9', '3.10'] #, '3.11'] possible conflicts between numpy & astropy on 3.11. - astropy-version: ['<5.1', '<5.3', '<6.0'] - desiutil-version: ['3.3.1', 'main'] + astropy-version: ['<6.0', '<6.1', '<7.0'] + desiutil-version: ['3.4.3', 'main'] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies run: | python -m pip install --upgrade pip setuptools wheel python -m pip install pytest jinja2 - python -m pip install numpy\<1.23 + python -m pip install numpy\<2.0 python -m pip install "git+https://github.com/desihub/desiutil.git@${{ matrix.desiutil-version }}#egg=desiutil" python -m pip install "astropy${{ matrix.astropy-version }}" - name: Run the test @@ -52,19 +52,19 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies run: | python -m pip install --upgrade pip setuptools wheel python -m pip install pytest pytest-cov coveralls + python -m pip install numpy\<2.0 python -m pip install -r requirements.txt - python -m pip install --upgrade numpy\<1.23 - name: Run the test with coverage run: | pytest --cov @@ -86,11 +86,11 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies @@ -112,15 +112,15 @@ jobs: matrix: os: [ubuntu-latest] python-version: ['3.10'] - desiutil-version: ['3.3.0'] + desiutil-version: ['3.4.3'] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies @@ -144,11 +144,11 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies diff --git a/.readthedocs.yml b/.readthedocs.yml index f8a86a28..03573990 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -22,7 +22,5 @@ sphinx: # Optionally set the version of Python and requirements required to build your docs python: - # version: 3 - # system_packages: true install: - requirements: doc/rtd-requirements.txt diff --git a/LICENSE.rst b/LICENSE.rst index 9e79a9ae..d479b116 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -1,4 +1,4 @@ -Copyright (c) 2014-2022, DESI Collaboration +Copyright (c) 2014-2024, DESI Collaboration All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/MANIFEST.in b/MANIFEST.in index d72c06de..7081da00 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,12 +1,2 @@ -include LICENSE.rst -include README.rst -include requirements.txt - -graft bin -graft doc -graft etc - -prune build -prune dist -prune htmlcov -prune doc/_build +prune .github +global-exclude .gitignore .readthedocs.yml diff --git a/doc/changes.rst b/doc/changes.rst index 22b83ddc..142fe488 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -5,7 +5,9 @@ desidatamodel Change Log 24.10 (unreleased) ------------------ -* No changes yet. +* Update package infrastructure, ... (PR `#200`_). + +.. _`#200`: https://github.com/desihub/desidatamodel/pull/200 24.9 (2024-09-12) ----------------- diff --git a/py/desidatamodel/__init__.py b/py/desidatamodel/__init__.py index 7e9efecd..843b2ccb 100644 --- a/py/desidatamodel/__init__.py +++ b/py/desidatamodel/__init__.py @@ -7,7 +7,7 @@ This package provides support for the DESI_ Data Model. -.. _DESI: http://desi.lbl.gov +.. _DESI: https://www.desi.lbl.gov """ # # Set version string. diff --git a/py/desidatamodel/check.py b/py/desidatamodel/check.py index e735f8a6..a720287e 100644 --- a/py/desidatamodel/check.py +++ b/py/desidatamodel/check.py @@ -328,7 +328,7 @@ def extract_metadata(self, error=False): spanend = int(g[1]) log.debug('Detected range specification from HDU %d to HDU %d', spanstart, spanend) - spanref = [l for l in section if l.startswith('Data:')][0] + spanref = [ln for ln in section if ln.startswith('Data:')][0] spanext = spanref[spanref.lower().index('see') + 4:].replace('.', '') try: spanmeta = self.hdumeta[spanext] @@ -336,8 +336,8 @@ def extract_metadata(self, error=False): m = "Cannot find EXTNAME = '%s' which is supposed to define HDU %d to HDU %d!" log.critical(m, spanext, spanstart, spanend) raise DataModelError(m % (spanext, spanstart, spanend)) - spanname = [l.split('=')[1].strip() for l in section - if l.startswith('EXTNAME = ')][0] + spanname = [ln.split('=')[1].strip() for ln in section + if ln.startswith('EXTNAME = ')][0] extnames = [p.strip() for p in spanname.split(',')] if len(range(spanstart, spanend+1)) == len(extnames): for i, l in enumerate(range(spanstart, spanend+1)): @@ -357,7 +357,7 @@ def extract_metadata(self, error=False): meta = dict() meta['number'] = k meta['title'] = section[0] - hdu_cross_ref = [l for l in section if l.startswith('See `')] + hdu_cross_ref = [ln for ln in section if ln.startswith('See `')] if hdu_cross_ref: log.debug("Found HDU cross-reference: %s", hdu_cross_ref[0]) hcr = self._cross_reference(hdu_cross_ref[0]).split('#') @@ -372,7 +372,7 @@ def extract_metadata(self, error=False): if 'Empty HDU.' in section: meta['extension'] = 'IMAGE' meta['format'] = 'Empty HDU.' - image_data = [l for l in section if l.startswith('Data:')] + image_data = [ln for ln in section if ln.startswith('Data:')] if image_data: meta['extension'] = 'IMAGE' meta['format'] = image_data[0] @@ -439,8 +439,8 @@ def extract_metadata(self, error=False): # the detailed policy on EXTNAME. # try: - meta['extname'] = [l.split()[2] for l in section - if l.startswith('EXTNAME = ')][0] + meta['extname'] = [ln.split()[2] for ln in section + if ln.startswith('EXTNAME = ')][0] except IndexError: meta['extname'] = 'HDU{0:02d}'.format(k) if (k > 0 or (k == 0 and meta['format'] != 'Empty HDU.')): diff --git a/py/desidatamodel/test/datamodeltestcase.py b/py/desidatamodel/test/datamodeltestcase.py index e06160f8..11e4903b 100644 --- a/py/desidatamodel/test/datamodeltestcase.py +++ b/py/desidatamodel/test/datamodeltestcase.py @@ -95,9 +95,12 @@ def assertInLog(self, logger, message=''): def badUnitMessage(self, unit): """Returns a string that can be used to match errors related to bad units. """ - m = "'{0}' did not parse as fits unit: At col {1:d}, Unit 'ergs' not supported by the FITS standard. Did you mean erg?".format(unit, unit.index('ergs')) + m = ("'{0}' did not parse as fits unit: At col {1:d}, Unit 'ergs' not " + + "supported by the FITS standard. Did you mean erg?").format(unit, unit.index('ergs')) if self.astropyVersion >= version.parse('4.0'): - m += " If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html" + m += (" If this is meant to be a custom unit, define it with 'u.def_unit'. " + + "To have it recognized inside a file reader or other code, enable it with " + + "'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html") if self.astropyVersion >= version.parse('4.0.2'): m = m.replace('http', 'https') return m diff --git a/py/desidatamodel/test/test_check.py b/py/desidatamodel/test/test_check.py index 08885195..a7f253a7 100644 --- a/py/desidatamodel/test/test_check.py +++ b/py/desidatamodel/test/test_check.py @@ -471,7 +471,9 @@ def test_validate_prototype_hdu_mismatch(self): foo = f.extract_metadata() f.hdumeta['foobar'] = 'baz' f.validate_prototype(error=True) - self.assertLog(log, -2, "{0} has the wrong number of sections (HDUs) according to {1}, skipping to next candidate.".format(str(modelfile).replace('.rst', '.fits'), modelfile)) + self.assertLog(log, -2, ("{0} has the wrong number of sections (HDUs) " + + "according to {1}, skipping to next " + + "candidate.").format(str(modelfile).replace('.rst', '.fits'), modelfile)) self.assertLog(log, -1, "No useful prototype files found for {0}!".format(modelfile)) def test_validate_prototype_hdu_keyword_mismatch(self): @@ -484,7 +486,8 @@ def test_validate_prototype_hdu_keyword_mismatch(self): f.validate_prototype() f._stub_meta[0]['keywords'].append(('BUNIT', 'erg', 'str', 'This is a test.')) f.validate_prototype(error=True) - self.assertLog(log, -1, "Prototype file {0} has these keywords in HDU0 missing from model: {{'BUNIT'}}".format(str(modelfile).replace('.rst', '.fits'))) + self.assertLog(log, -1, ("Prototype file {0} has these keywords " + + "in HDU0 missing from model: {{'BUNIT'}}").format(str(modelfile).replace('.rst', '.fits'))) def test_validate_prototype_hdu_keyword_type_mismatch(self): """Test the data model validation method with a keyword type mismatch. @@ -496,7 +499,9 @@ def test_validate_prototype_hdu_keyword_type_mismatch(self): f.extract_metadata() f.hdumeta['PRIMARY']['keywords'][2] = ('BSCALE', '1.2', 'float', '') f.validate_prototype() - self.assertLog(log, -1, "File %s HDU%d keyword %s has different keyword type according to %s (%s != %s)." % (f.prototype, 0, 'BSCALE', modelfile, 'int', 'float')) + self.assertLog(log, -1, ("File %s HDU%d keyword %s has different keyword " + + "type according to %s (%s != %s).") % + (f.prototype, 0, 'BSCALE', modelfile, 'int', 'float')) def test_validate_prototype_hdu_wrong_keyword(self): """Test the data model validation method with wrong HDU keyword names. @@ -521,7 +526,9 @@ def test_validate_prototype_hdu_extension_type(self): f.validate_prototype() f._stub_meta[1]['extension'] = 'IMAGE' f.validate_prototype(error=True) - self.assertLog(log, -1, "Prototype file {0} has an extension type mismatch in HDU1 (IMAGE != BINTABLE) according to {1}.".format(str(modelfile).replace('.rst', '.fits'), modelfile)) + self.assertLog(log, -1, ("Prototype file {0} has an extension type " + + "mismatch in HDU1 (IMAGE != BINTABLE) according " + + "to {1}.").format(str(modelfile).replace('.rst', '.fits'), modelfile)) # f._stub_meta[1]['extname'] = '' # f.validate_prototype(error=True) # self.assertLog(log, -1, "Prototype file {0} has no EXTNAME in HDU1.".format(str(modelfile).replace('.rst', '.fits'))) @@ -536,7 +543,9 @@ def test_validate_prototype_hdu_extension_name(self): f.validate_prototype() f._stub_meta[1]['extname'] = 'GALAXY' f.validate_prototype(error=True) - self.assertLog(log, -1, "Prototype file {0} has an EXTNAME mismatch in HDU1 (GALAXY != Galaxies) according to {1}.".format(str(modelfile).replace('.rst', '.fits'), modelfile)) + self.assertLog(log, -1, ("Prototype file {0} has an EXTNAME mismatch in " + + "HDU1 (GALAXY != Galaxies) according to " + + "{1}.").format(str(modelfile).replace('.rst', '.fits'), modelfile)) f._stub_meta[1]['extname'] = '' f.validate_prototype(error=True) self.assertLog(log, -2, "Prototype file {0} has no EXTNAME in HDU1.".format(str(modelfile).replace('.rst', '.fits'))) diff --git a/py/desidatamodel/test/test_scan.py b/py/desidatamodel/test/test_scan.py index f01085d3..9da4da68 100644 --- a/py/desidatamodel/test/test_scan.py +++ b/py/desidatamodel/test/test_scan.py @@ -129,13 +129,30 @@ def test_union_metadata(self, mock_update, mock_mark): foo = model.get_regexp('/desi/spectro/data') union_metadata(model, stubs) mock_mark.assert_called_once() - mock_update.assert_has_calls([call(0, [('NAXIS1', '100', 'int', ''), ('NAXIS2', '100', 'int', ''), ('BSCALE', '1', 'int', ''), ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]), - call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'), ('NAXIS2', '3', 'int', 'length of dimension 2')]), - call(1, [('Name', 'Type', 'Units', 'Description'), ('target', 'char[20]', '', ''), ('V_mag', 'float32', 'mag', ''), ('vdisp', 'float64', 'km/s', '')], columns=True), - call(0, [('NAXIS1', '100', 'int', ''), ('NAXIS2', '100', 'int', ''), ('BSCALE', '1', 'int', ''), ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]), - call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'), ('NAXIS2', '3', 'int', 'length of dimension 2')]), - call(1, [('Name', 'Type', 'Units', 'Description'), ('target', 'char[20]', '', ''), ('V_mag', 'float32', 'mag', ''), ('vdisp', 'float64', 'km/s', '')], columns=True), - call(0, [('NAXIS1', '100', 'int', ''), ('NAXIS2', '100', 'int', ''), ('BSCALE', '1', 'int', ''), ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')])]) + mock_update.assert_has_calls([call(0, [('NAXIS1', '100', 'int', ''), + ('NAXIS2', '100', 'int', ''), + ('BSCALE', '1', 'int', ''), + ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]), + call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'), + ('NAXIS2', '3', 'int', 'length of dimension 2')]), + call(1, [('Name', 'Type', 'Units', 'Description'), + ('target', 'char[20]', '', ''), + ('V_mag', 'float32', 'mag', ''), + ('vdisp', 'float64', 'km/s', '')], columns=True), + call(0, [('NAXIS1', '100', 'int', ''), + ('NAXIS2', '100', 'int', ''), + ('BSCALE', '1', 'int', ''), + ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')]), + call(1, [('NAXIS1', '32', 'int', 'length of dimension 1'), + ('NAXIS2', '3', 'int', 'length of dimension 2')]), + call(1, [('Name', 'Type', 'Units', 'Description'), + ('target', 'char[20]', '', ''), + ('V_mag', 'float32', 'mag', ''), + ('vdisp', 'float64', 'km/s', '')], columns=True), + call(0, [('NAXIS1', '100', 'int', ''), + ('NAXIS2', '100', 'int', ''), + ('BSCALE', '1', 'int', ''), + ('BZERO', '32768', 'int', 'Data are really unsigned 16-bit int.')])]) @patch('sys.argv', ['deep_scan_metadata', '--verbose', '--number', '1000', 'DESI_SPECTRO_DATA/NIGHT/EXPID/desi-EXPID.rst', '/desi/spectro/data']) def test_options(self): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..54a891e3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = ["setuptools", + "wheel"] +build-backend = 'setuptools.build_meta' diff --git a/requirements.txt b/requirements.txt index b65bfb4f..8a93d2f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ astropy sphinx-toolbox jinja2 -git+https://github.com/desihub/desiutil.git@3.3.1#egg=desiutil +git+https://github.com/desihub/desiutil.git@3.4.3#egg=desiutil diff --git a/setup.cfg b/setup.cfg index 1cee296c..c9bee76a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,106 @@ +[metadata] +name = desidatamodel +version = attr: desidatamodel.__version__ +author = DESI Collaboration +author_email = desi-data@desi.lbl.gov +license = BSD 3-Clause License +license_files = LICENSE.rst +url = https://github.com/desihub/desidatamodel +description = DESI data transfer infrastructure. +long_description = file: README.rst +long_description_content_type = text/x-rst +edit_on_github = True +github_project = desihub/desidatamodel +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + Framework :: Sphinx + Intended Audience :: Science/Research + License :: OSI Approved :: BSD License + Natural Language :: English + Operating System :: OS Independent + Programming Language :: Python :: 3 + Topic :: Documentation :: Sphinx + Topic :: Scientific/Engineering :: Astronomy + +[options] +zip_safe = True +package_dir = + =py +packages = find: +include_package_data = True +python_requires = >=3.9 +# setup_requires = setuptools_scm +install_requires = + astropy + jinja2 +scripts = + bin/check_minitest.sh + bin/check_model + bin/deep_scan_metadata + bin/generate_model + bin/update_bitmasks + bin/update_column_descriptions + +# [options.entry_points] +# console_scripts = +# check_model = desidatamodel.check:main +# deep_scan_metadata = desidatamodel.scan:main +# generate_model = desidatamodel.stub:main +# update_column_descriptions = desidatamodel.update:main + +[options.extras_require] +test = + pytest +coverage = + pytest-cov + coveralls +doc = + Sphinx + sphinx-rtd-theme>1.2 + sphinx-toolbox + +[options.package_data] +desidatamodel = data/* +desidatamodel.test = t/* + +[options.packages.find] +where = py +exclude = .github/* + +[coverage:run] +relative_files = True +source = + py/desidatamodel +omit = + py/desidatamodel/_version.py + py/desidatamodel/conftest* + py/desidatamodel/test/* + */desidatamodel/_version.py + */desidatamodel/conftest* + */desidatamodel/test/* + +# [coverage:paths] +# source = +# py/desidatamodel/ +# */site-packages/desidatamodel/ + +[coverage:report] +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + # Don't complain about packages we have installed + except ImportError + # Don't complain if tests don't hit assertions + raise AssertionError + raise NotImplementedError + # Don't complain about script hooks + def main\(.*\): + # Ignore branches that don't pertain to this version of Python + pragma: py{ignore_python_version} + # Don't complain about IPython completion helper + def _ipython_key_completions_ + [pycodestyle] # See https://pycodestyle.readthedocs.io/en/latest/intro.html#configuration # for details of these configuration options. @@ -5,9 +108,14 @@ # These are normally ignored by default: # ignore = E121, E123, E126, E133, E226, E241, E242, E704, W503, W504 # -# In addition to the default set we add: -# - E501: line too long (82 > 79 characters) -# - E731: do not assign a lambda expression, use a def -# - E741: do not use variables named 'l', 'O', or 'I' -- because, for example, -# 'l' might refer to Galactic longitude. -ignore = E121, E123, E126, E133, E226, E241, E242, E501, E704, E731, E741, W503, W504 +# These are the explicitly ignored styles: +# +# - E126: continuation line over-indented for hanging indent +# - E226: missing whitespace around arithmetic operator +# - E241: multiple spaces after ',' +# - W504: line break after binary operator +# +# In addition: +# - E501: not ignored, but 180 will eventually be reduced. +max-line-length = 180 +ignore = E126,E226,E241,W504 diff --git a/setup.py b/setup.py index a686072b..061bf023 100755 --- a/setup.py +++ b/setup.py @@ -1,78 +1,85 @@ #!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst -# -# Standard imports -# -import glob -import os + +# NOTE: The configuration for the package, including the name, version, and +# other information are set in the setup.cfg file. + import sys -# -# setuptools' sdist command ignores MANIFEST.in -# -from distutils.command.sdist import sdist as DistutilsSdist -from setuptools import setup, find_packages -# -# DESI support code. -# -import desiutil.setup as ds -# -# Begin setup -# -setup_keywords = dict() -# -# THESE SETTINGS NEED TO BE CHANGED FOR EVERY PRODUCT. -# -setup_keywords['name'] = 'desidatamodel' -setup_keywords['description'] = 'DESI Data Model' -setup_keywords['author'] = 'DESI Collaboration' -setup_keywords['author_email'] = 'desi-data@desi.lbl.gov' -setup_keywords['license'] = 'BSD' -setup_keywords['url'] = 'https://github.com/desihub/desidatamodel' -# -# END OF SETTINGS THAT NEED TO BE CHANGED. -# -setup_keywords['version'] = ds.get_version(setup_keywords['name']) -# -# Use README.rst as long_description. -# -setup_keywords['long_description'] = '' -if os.path.exists('README.rst'): - with open('README.rst') as readme: - setup_keywords['long_description'] = readme.read() -# -# Set other keywords for the setup function. These are automated, & should -# be left alone unless you are an expert. -# -# Treat everything in bin/ except *.rst as a script to be installed. -# -if os.path.isdir('bin'): - setup_keywords['scripts'] = [fname for fname in glob.glob(os.path.join('bin', '*')) - if not os.path.basename(fname).endswith('.rst')] -setup_keywords['provides'] = [setup_keywords['name']] -setup_keywords['python_requires'] = '>=3.5' -setup_keywords['zip_safe'] = False -setup_keywords['use_2to3'] = False -setup_keywords['packages'] = find_packages('py') -setup_keywords['package_dir'] = {'': 'py'} -setup_keywords['cmdclass'] = {'module_file': ds.DesiModule, - 'version': ds.DesiVersion, - 'test': ds.DesiTest, - 'api': ds.DesiAPI, - 'sdist': DistutilsSdist} -setup_keywords['test_suite']='{name}.test.{name}_test_suite'.format(**setup_keywords) -# -# Autogenerate command-line scripts. -# -# setup_keywords['entry_points'] = {'console_scripts': ['check_model = desidatamodel.check:main', -# 'deep_scan_metadata = desidatamodel.scan:main', -# 'generate_model = desidatamodel.stub:main', -# 'update_bitmasks = desidatamodel.bitmasks:main', -# 'update_column_descriptions = desidatamodel.update:main']} -# -# Add internal data directories. -# -setup_keywords['package_data'] = {'desidatamodel.test': ['t/*']} -# -# Run setup command. -# -setup(**setup_keywords) +from setuptools import setup + +# First provide helpful messages if contributors try and run legacy commands +# for tests or docs. + +API_HELP = """ +Note: Generating api.rst files is no longer done using 'python setup.py api'. Instead +you will need to run: + + desi_api_file + +which is part of the desiutil package. If you don't already have desiutil installed, you can install it with: + + pip install desiutil +""" + +MODULE_HELP = """ +Note: Generating Module files is no longer done using 'python setup.py api'. Instead +you will need to run: + + desiInstall + +or + + desi_module_file + +depending on your exact situation. desiInstall is preferred. Both commands are +part of the desiutil package. If you don't already have desiutil installed, you can install it with: + + pip install desiutil +""" + +VERSION_HELP = """ +Note: Generating version strings is no longer done using 'python setup.py version'. Instead +you will need to run: + + desi_update_version [-t TAG] desiutil + +which is part of the desiutil package. If you don't already have desiutil installed, you can install it with: + + pip install desiutil +""" + +TEST_HELP = """ +Note: running tests is no longer done using 'python setup.py test'. Instead +you will need to run: + + pytest + +If you don't already have pytest installed, you can install it with: + + pip install pytest +""" + +DOCS_HELP = """ +Note: building the documentation is no longer done using +'python setup.py {0}'. Instead you will need to run: + + sphinx-build -W --keep-going -b html doc doc/_build/html + +If you don't already have Sphinx installed, you can install it with: + + pip install Sphinx +""" + +message = {'api': API_HELP, + 'module_file': MODULE_HELP, + 'test': TEST_HELP, + 'version': VERSION_HELP, + 'build_docs': DOCS_HELP.format('build_docs'), + 'build_sphinx': DOCS_HELP.format('build_sphinx'), } + +for m in message: + if m in sys.argv: + print(message[m]) + sys.exit(1) + +setup()