diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9d61454..7b1c4b2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Python 3", - "image": "mcr.microsoft.com/devcontainers/python:3.10", + "image": "mcr.microsoft.com/devcontainers/python:3.11", "features": { "ghcr.io/devcontainers-contrib/features/coverage-py:1": {}, "ghcr.io/devcontainers-contrib/features/pylint:1": {} @@ -10,7 +10,7 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip install pytest && pip install -e ." + "postCreateCommand": "pip install -e .[all]" // Configure tool-specific properties. // "customizations": {}, diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index cfbbaab..bf89fb6 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -26,7 +26,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pytest-astropy pytest-cov sphinx-astropy codecov # install package and requirements pip install ".[all]" - name: Lint with ruff diff --git a/pyproject.toml b/pyproject.toml index 164f5c9..4276f07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,105 @@ [build-system] - requires = ["setuptools", "setuptools_scm", "wheel", "extension-helpers", "oldest-supported-numpy", "cython>=0.29.15"] - build-backend = 'setuptools.build_meta' + +[project] +name = "astrodbkit2" +description = "Astronomical database handler code" +dynamic = ["version"] +readme = {file = "README.rst", content-type = "text/x-rst"} +# license = {file = "licenses/LICENSE.rst"} +license = {text = "BSD 3-Clause"} +authors = [ + {name = "David Rodriguez", email = "drodriguez@stsci.edu"}, +] +requires-python = ">= 3.7" +dependencies = [ + "astropy", + "astroquery", + "sqlalchemy>=2.0", + "pandas>=1.0.4", + "packaging", + "specutils>=1.0", + "tqdm", +] + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-cov", + "pytest-astropy", + "darker==1.7.2", + "black==23.9.1", + "pre-commit==3.4.0", + "ruff==0.3.7", +] +docs = [ + "sphinx-astropy" +] +all = ["astrodbkit2[test, docs]"] + +[project.urls] +Repository = "https://github.com/astrodbtoolkit/AstrodbKit2" + + +[tool.setuptools] +packages = ["astrodbkit2"] + +[tool.setuptools.dynamic] +version = {attr = "astrodbkit2.__version__"} + +[tool.setuptools_scm] +# can be empty if no extra settings are needed, presence enables setuptools_scm +version_file = "astrodbkit2/version.py" + + +[tool.pytest.ini_options] +testpaths = "astrodbkit2" + + +[tool.coverage.run] +omit = [ + "astrodbkit2/_astropy_init*", + "astrodbkit2/conftest.py", + "astrodbkit2/*setup_package*", + "astrodbkit2/tests/*", + "astrodbkit2/*/tests/*", + "astrodbkit2/extern/*", + "astrodbkit2/version*", + "*/astrodbkit2/_astropy_init*", + "*/astrodbkit2/conftest.py", + "*/astrodbkit2/*setup_package*", + "*/astrodbkit2/tests/*", + "*/astrodbkit2/*/tests/*", + "*/astrodbkit2/extern/*", + "*/astrodbkit2/version*", +] + + +[tool.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_", +] + + [tool.ruff.lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. # Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or @@ -32,6 +123,7 @@ line-length = 120 # Flag errors (`C901`) whenever the complexity level exceeds 15. max-complexity = 15 + [tool.darker] line-length = 120 diff --git a/setup.cfg b/setup.cfg index 3af1bc8..f8dd489 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,83 +1,6 @@ [metadata] name = astrodbkit2 author = David Rodriguez -author_email = drodriguez@stsci.edu -license = BSD 3-Clause -license_file = licenses/LICENSE.rst -url = -description = Astronomical database handler code -long_description = file: README.rst -long_description_content_type = text/x-rst edit_on_github = False github_project = dr-rodriguez/AstrodbKit2 - -[options] -zip_safe = False -packages = find: -python_requires = >=3.7 -setup_requires = setuptools_scm -install_requires = - astropy - astroquery - sqlalchemy>=2.0 - pandas>=1.0.4 - packaging - specutils>=1.0 - tqdm - -[options.entry_points] -console_scripts = - astropy-package-template-example = packagename.example_mod:main - -[options.extras_require] -all = - astrodbkit2[test, docs] -test = - pytest - pytest-cov - pytest-astropy - darker==1.7.2 - black==23.9.1 - pre-commit==3.4.0 - ruff==0.3.7 -docs = - sphinx-astropy - -[options.package_data] -astrodbkit2 = data/* - -[tool:pytest] -testpaths = "astrodbkit2" - -[coverage:run] -omit = - astrodbkit2/_astropy_init* - astrodbkit2/conftest.py - astrodbkit2/*setup_package* - astrodbkit2/tests/* - astrodbkit2/*/tests/* - astrodbkit2/extern/* - astrodbkit2/version* - */astrodbkit2/_astropy_init* - */astrodbkit2/conftest.py - */astrodbkit2/*setup_package* - */astrodbkit2/tests/* - */astrodbkit2/*/tests/* - */astrodbkit2/extern/* - */astrodbkit2/version* - -[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_ +# Most details are now in pyproject.toml diff --git a/setup.py b/setup.py index 5ac24c2..26126d8 100755 --- a/setup.py +++ b/setup.py @@ -1,78 +1,3 @@ -#!/usr/bin/env python -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -# NOTE: The configuration for the package, including the name, version, and -# other information are set in the setup.cfg file. - -import os -import sys - from setuptools import setup - -# First provide helpful messages if contributors try and run legacy commands -# for tests or docs. - -TEST_HELP = """ -Note: running tests is no longer done using 'python setup.py test'. Instead -you will need to run: - - tox -e test - -If you don't already have tox installed, you can install it with: - - pip install tox - -If you only want to run part of the test suite, you can also use pytest -directly with:: - - pip install -e .[test] - pytest - -For more information, see: - - http://docs.astropy.org/en/latest/development/testguide.html#running-tests -""" - -if 'test' in sys.argv: - print(TEST_HELP) - sys.exit(1) - -DOCS_HELP = """ -Note: building the documentation is no longer done using -'python setup.py build_docs'. Instead you will need to run: - - tox -e build_docs - -If you don't already have tox installed, you can install it with: - - pip install tox - -You can also build the documentation with Sphinx directly using:: - - pip install -e .[docs] - cd docs - make html - -For more information, see: - - http://docs.astropy.org/en/latest/install.html#builddocs -""" - -if 'build_docs' in sys.argv or 'build_sphinx' in sys.argv: - print(DOCS_HELP) - sys.exit(1) - -VERSION_TEMPLATE = """ -# Note that we need to fall back to the hard-coded version if either -# setuptools_scm can't be imported or setuptools_scm can't determine the -# version, so we catch the generic 'Exception'. -try: - from setuptools_scm import get_version - version = get_version(root='..', relative_to=__file__) -except Exception: - version = '{version}' -""".lstrip() - -setup(use_scm_version={'write_to': os.path.join('astrodbkit2', 'version.py'), - 'write_to_template': VERSION_TEMPLATE}) +setup(use_scm_version=True) \ No newline at end of file