From a148b907d441917863908e71384fd88b91af3eed Mon Sep 17 00:00:00 2001 From: Ed Slavich Date: Mon, 22 Mar 2021 10:34:38 -0400 Subject: [PATCH 1/2] Remove defunct asdf.test method and use setuptools-scm to generate version file --- .github/workflows/{asdf_ci.yml => ci.yml} | 0 .gitignore | 3 + README.rst | 17 ++-- asdf/__init__.py | 11 +-- asdf/_internal_init.py | 102 ---------------------- asdf/version.py | 9 -- setup.py | 3 +- 7 files changed, 14 insertions(+), 131 deletions(-) rename .github/workflows/{asdf_ci.yml => ci.yml} (100%) delete mode 100644 asdf/_internal_init.py delete mode 100644 asdf/version.py diff --git a/.github/workflows/asdf_ci.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflows/asdf_ci.yml rename to .github/workflows/ci.yml diff --git a/.gitignore b/.gitignore index 0708eaba8..7b5f6512a 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,6 @@ pip-wheel-metadata # Mac OSX .DS_Store + +# setuptools-scm generated version file +asdf/version.py diff --git a/README.rst b/README.rst index 1af5771ff..b8e766556 100644 --- a/README.rst +++ b/README.rst @@ -301,23 +301,18 @@ To run the unit tests from a source checkout of the repository: $ pytest It is also possible to run the test suite from an installed version of -the package. In a Python interpreter: +the package. -.. code:: python - - import asdf - asdf.test() - -Please note that the `astropy `__ -package must be installed to run the tests. +:: + pip install asdf[tests] + pytest --pyargs asdf It is also possible to run the tests using `tox -`__. It is first necessary to install -``tox`` and `tox-conda `__: +`__. :: - $ pip install tox tox-conda + $ pip install tox To list all available environments: diff --git a/asdf/__init__.py b/asdf/__init__.py index 3ea5bf0b9..0f148bc98 100644 --- a/asdf/__init__.py +++ b/asdf/__init__.py @@ -3,16 +3,10 @@ Data Format (ASDF) files """ -# Affiliated packages may add whatever they like to this file, but -# should keep this content at the top. -# ---------------------------------------------------------------------------- -from ._internal_init import __version__, __githash__, test -# ---------------------------------------------------------------------------- - __all__ = [ - 'AsdfFile', 'CustomType', 'AsdfExtension', 'Stream', 'open', 'test', + 'AsdfFile', 'CustomType', 'AsdfExtension', 'Stream', 'open', 'commands', 'IntegerType', 'ExternalArrayReference', 'info', '__version__', - '__githash__', 'ValidationError', 'get_config', 'config_context', + 'ValidationError', 'get_config', 'config_context', ] @@ -25,5 +19,6 @@ from .tags.core.external_reference import ExternalArrayReference from ._convenience import info from .config import get_config, config_context +from .version import version as __version__ from jsonschema import ValidationError diff --git a/asdf/_internal_init.py b/asdf/_internal_init.py deleted file mode 100644 index 9925ab5ae..000000000 --- a/asdf/_internal_init.py +++ /dev/null @@ -1,102 +0,0 @@ -__all__ = ['__version__', '__githash__', 'test'] - - -try: - from .version import version as __version__ -except ImportError: - __version__ = '' -try: - from .version import githash as __githash__ -except ImportError: - __githash__ = '' - - -# set up the test command -def _get_test_runner(): - import os - from astropy.tests.helper import TestRunner - return TestRunner(os.path.dirname(__file__)) - - -def test(package=None, test_path=None, args=None, plugins=None, - verbose=False, pastebin=None, remote_data=False, pep8=False, - pdb=False, coverage=False, open_files=False, **kwargs): - """ - Run the tests using `pytest `__. A proper set - of arguments is constructed and passed to `pytest.main`_. - - .. _pytest: http://pytest.org/latest/ - .. _pytest.main: http://pytest.org/latest/builtin.html#pytest.main - - Parameters - ---------- - package : str, optional - The name of a specific package to test, e.g. 'asdf.tags'. - If nothing is specified all default tests are run. - - test_path : str, optional - Specify location to test by path. May be a single file or - directory. Must be specified absolutely or relative to the - calling directory. - - args : str, optional - Additional arguments to be passed to pytest.main_ in the ``args`` - keyword argument. - - plugins : list, optional - Plugins to be passed to pytest.main_ in the ``plugins`` keyword - argument. - - verbose : bool, optional - Convenience option to turn on verbose output from pytest_. Passing - True is the same as specifying ``'-v'`` in ``args``. - - pastebin : {'failed','all',None}, optional - Convenience option for turning on pytest_ pastebin output. Set to - ``'failed'`` to upload info for failed tests, or ``'all'`` to upload - info for all tests. - - remote_data : bool, optional - Controls whether to run tests marked with @remote_data. These - tests use online data and are not run by default. Set to True to - run these tests. - - pep8 : bool, optional - Turn on PEP8 checking via the `pytest-pep8 plugin - `_ and disable normal - tests. Same as specifying ``'--pep8 -k pep8'`` in ``args``. - - pdb : bool, optional - Turn on PDB post-mortem analysis for failing tests. Same as - specifying ``'--pdb'`` in ``args``. - - coverage : bool, optional - Generate a test coverage report. The result will be placed in - the directory htmlcov. - - open_files : bool, optional - Fail when any tests leave files open. Off by default, because - this adds extra run time to the test suite. Requires the - `psutil `_ package. - - parallel : int, optional - When provided, run the tests in parallel on the specified - number of CPUs. If parallel is negative, it will use the all - the cores on the machine. Requires the - `pytest-xdist `_ plugin - installed. - - kwargs - Any additional keywords passed into this function will be passed - on to the astropy test runner. This allows use of test-related - functionality implemented in later versions of astropy without - explicitly updating the package template. - - """ - - test_runner = _get_test_runner() - return test_runner.run_tests( - package=package, test_path=test_path, args=args, - plugins=plugins, verbose=verbose, pastebin=pastebin, - remote_data=remote_data, pep8=pep8, pdb=pdb, - coverage=coverage, open_files=open_files, **kwargs) diff --git a/asdf/version.py b/asdf/version.py deleted file mode 100644 index ba1cf1f1f..000000000 --- a/asdf/version.py +++ /dev/null @@ -1,9 +0,0 @@ -from pkg_resources import get_distribution, DistributionNotFound - -try: - version = get_distribution('asdf').version -except DistributionNotFound: - # package is not installed - version = "unknown" - -__all__ = ['version'] diff --git a/setup.py b/setup.py index 3985c2803..45cfa6570 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +import os from setuptools import setup, find_packages @@ -23,7 +24,7 @@ } setup( - use_scm_version=True, + use_scm_version={"write_to": os.path.join("asdf", "version.py"), "write_to_template": 'version = "{version}"\n'}, packages=packages, package_dir=package_dir, package_data=package_data, From e8ddb14fd2a1798140021cb5a80a3c7dbef7cc3f Mon Sep 17 00:00:00 2001 From: Ed Slavich Date: Mon, 22 Mar 2021 11:52:18 -0400 Subject: [PATCH 2/2] Add changelog entry --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 62de2fe28..cdb53e5b2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -43,6 +43,8 @@ - Add ``edit`` subcommand to asdftool for efficient editing of the YAML portion of an ASDF file. [#873, #922] +- Remove the ``asdf.test`` method and ``asdf.__githash__`` attribute. [#943] + 2.7.3 (2021-02-25) ------------------