Skip to content

Commit a178170

Browse files
authored
Reworking pyproject.toml setup for simplicity (#78)
* Reworking pyproject.toml setup for simplicity * Fix Sphinx docs build (hard-coded to use setup_cfg) and some other tweaks * Fix version fetching for package * removing version printout in action- not needed * minor edits * Removing temp file
1 parent bc9e225 commit a178170

File tree

5 files changed

+98
-159
lines changed

5 files changed

+98
-159
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Python 3",
3-
"image": "mcr.microsoft.com/devcontainers/python:3.10",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.11",
44
"features": {
55
"ghcr.io/devcontainers-contrib/features/coverage-py:1": {},
66
"ghcr.io/devcontainers-contrib/features/pylint:1": {}
@@ -10,7 +10,7 @@
1010
// "forwardPorts": [],
1111

1212
// Use 'postCreateCommand' to run commands after the container is created.
13-
"postCreateCommand": "pip install pytest && pip install -e ."
13+
"postCreateCommand": "pip install -e .[all]"
1414

1515
// Configure tool-specific properties.
1616
// "customizations": {},

.github/workflows/test-package.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
- name: Install dependencies
2727
run: |
2828
python -m pip install --upgrade pip
29-
pip install flake8 pytest pytest-astropy pytest-cov sphinx-astropy codecov
3029
# install package and requirements
3130
pip install ".[all]"
3231
- name: Lint with ruff

pyproject.toml

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,105 @@
11
[build-system]
2-
32
requires = ["setuptools",
43
"setuptools_scm",
54
"wheel",
65
"extension-helpers",
76
"oldest-supported-numpy",
87
"cython>=0.29.15"]
9-
108
build-backend = 'setuptools.build_meta'
119

10+
11+
[project]
12+
name = "astrodbkit2"
13+
description = "Astronomical database handler code"
14+
dynamic = ["version"]
15+
readme = {file = "README.rst", content-type = "text/x-rst"}
16+
# license = {file = "licenses/LICENSE.rst"}
17+
license = {text = "BSD 3-Clause"}
18+
authors = [
19+
{name = "David Rodriguez", email = "drodriguez@stsci.edu"},
20+
]
21+
requires-python = ">= 3.7"
22+
dependencies = [
23+
"astropy",
24+
"astroquery",
25+
"sqlalchemy>=2.0",
26+
"pandas>=1.0.4",
27+
"packaging",
28+
"specutils>=1.0",
29+
"tqdm",
30+
]
31+
32+
[project.optional-dependencies]
33+
test = [
34+
"pytest",
35+
"pytest-cov",
36+
"pytest-astropy",
37+
"darker==1.7.2",
38+
"black==23.9.1",
39+
"pre-commit==3.4.0",
40+
"ruff==0.3.7",
41+
]
42+
docs = [
43+
"sphinx-astropy"
44+
]
45+
all = ["astrodbkit2[test, docs]"]
46+
47+
[project.urls]
48+
Repository = "https://github.com/astrodbtoolkit/AstrodbKit2"
49+
50+
51+
[tool.setuptools]
52+
packages = ["astrodbkit2"]
53+
54+
[tool.setuptools.dynamic]
55+
version = {attr = "astrodbkit2.__version__"}
56+
57+
[tool.setuptools_scm]
58+
# can be empty if no extra settings are needed, presence enables setuptools_scm
59+
version_file = "astrodbkit2/version.py"
60+
61+
62+
[tool.pytest.ini_options]
63+
testpaths = "astrodbkit2"
64+
65+
66+
[tool.coverage.run]
67+
omit = [
68+
"astrodbkit2/_astropy_init*",
69+
"astrodbkit2/conftest.py",
70+
"astrodbkit2/*setup_package*",
71+
"astrodbkit2/tests/*",
72+
"astrodbkit2/*/tests/*",
73+
"astrodbkit2/extern/*",
74+
"astrodbkit2/version*",
75+
"*/astrodbkit2/_astropy_init*",
76+
"*/astrodbkit2/conftest.py",
77+
"*/astrodbkit2/*setup_package*",
78+
"*/astrodbkit2/tests/*",
79+
"*/astrodbkit2/*/tests/*",
80+
"*/astrodbkit2/extern/*",
81+
"*/astrodbkit2/version*",
82+
]
83+
84+
85+
[tool.coverage.report]
86+
exclude_lines = [
87+
# Have to re-enable the standard pragma
88+
"pragma: no cover",
89+
# Don't complain about packages we have installed
90+
"except ImportError",
91+
# Don't complain if tests don't hit assertions
92+
"raise AssertionError",
93+
"raise NotImplementedError",
94+
# Don't complain about script hooks
95+
"def main\\(.*\\):",
96+
# Ignore branches that don't pertain to this version of Python
97+
"pragma: py{ignore_python_version}",
98+
# Don't complain about IPython completion helper
99+
"def _ipython_key_completions_",
100+
]
101+
102+
12103
[tool.ruff.lint]
13104
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
14105
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
@@ -32,6 +123,7 @@ line-length = 120
32123
# Flag errors (`C901`) whenever the complexity level exceeds 15.
33124
max-complexity = 15
34125

126+
35127
[tool.darker]
36128
line-length = 120
37129

setup.cfg

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,6 @@
11
[metadata]
22
name = astrodbkit2
33
author = David Rodriguez
4-
author_email = drodriguez@stsci.edu
5-
license = BSD 3-Clause
6-
license_file = licenses/LICENSE.rst
7-
url =
8-
description = Astronomical database handler code
9-
long_description = file: README.rst
10-
long_description_content_type = text/x-rst
114
edit_on_github = False
125
github_project = dr-rodriguez/AstrodbKit2
13-
14-
[options]
15-
zip_safe = False
16-
packages = find:
17-
python_requires = >=3.7
18-
setup_requires = setuptools_scm
19-
install_requires =
20-
astropy
21-
astroquery
22-
sqlalchemy>=2.0
23-
pandas>=1.0.4
24-
packaging
25-
specutils>=1.0
26-
tqdm
27-
28-
[options.entry_points]
29-
console_scripts =
30-
astropy-package-template-example = packagename.example_mod:main
31-
32-
[options.extras_require]
33-
all =
34-
astrodbkit2[test, docs]
35-
test =
36-
pytest
37-
pytest-cov
38-
pytest-astropy
39-
darker==1.7.2
40-
black==23.9.1
41-
pre-commit==3.4.0
42-
ruff==0.3.7
43-
docs =
44-
sphinx-astropy
45-
46-
[options.package_data]
47-
astrodbkit2 = data/*
48-
49-
[tool:pytest]
50-
testpaths = "astrodbkit2"
51-
52-
[coverage:run]
53-
omit =
54-
astrodbkit2/_astropy_init*
55-
astrodbkit2/conftest.py
56-
astrodbkit2/*setup_package*
57-
astrodbkit2/tests/*
58-
astrodbkit2/*/tests/*
59-
astrodbkit2/extern/*
60-
astrodbkit2/version*
61-
*/astrodbkit2/_astropy_init*
62-
*/astrodbkit2/conftest.py
63-
*/astrodbkit2/*setup_package*
64-
*/astrodbkit2/tests/*
65-
*/astrodbkit2/*/tests/*
66-
*/astrodbkit2/extern/*
67-
*/astrodbkit2/version*
68-
69-
[coverage:report]
70-
exclude_lines =
71-
# Have to re-enable the standard pragma
72-
pragma: no cover
73-
# Don't complain about packages we have installed
74-
except ImportError
75-
# Don't complain if tests don't hit assertions
76-
raise AssertionError
77-
raise NotImplementedError
78-
# Don't complain about script hooks
79-
def main\(.*\):
80-
# Ignore branches that don't pertain to this version of Python
81-
pragma: py{ignore_python_version}
82-
# Don't complain about IPython completion helper
83-
def _ipython_key_completions_
6+
# Most details are now in pyproject.toml

setup.py

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,3 @@
1-
#!/usr/bin/env python
2-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
3-
4-
# NOTE: The configuration for the package, including the name, version, and
5-
# other information are set in the setup.cfg file.
6-
7-
import os
8-
import sys
9-
101
from setuptools import setup
112

12-
13-
# First provide helpful messages if contributors try and run legacy commands
14-
# for tests or docs.
15-
16-
TEST_HELP = """
17-
Note: running tests is no longer done using 'python setup.py test'. Instead
18-
you will need to run:
19-
20-
tox -e test
21-
22-
If you don't already have tox installed, you can install it with:
23-
24-
pip install tox
25-
26-
If you only want to run part of the test suite, you can also use pytest
27-
directly with::
28-
29-
pip install -e .[test]
30-
pytest
31-
32-
For more information, see:
33-
34-
http://docs.astropy.org/en/latest/development/testguide.html#running-tests
35-
"""
36-
37-
if 'test' in sys.argv:
38-
print(TEST_HELP)
39-
sys.exit(1)
40-
41-
DOCS_HELP = """
42-
Note: building the documentation is no longer done using
43-
'python setup.py build_docs'. Instead you will need to run:
44-
45-
tox -e build_docs
46-
47-
If you don't already have tox installed, you can install it with:
48-
49-
pip install tox
50-
51-
You can also build the documentation with Sphinx directly using::
52-
53-
pip install -e .[docs]
54-
cd docs
55-
make html
56-
57-
For more information, see:
58-
59-
http://docs.astropy.org/en/latest/install.html#builddocs
60-
"""
61-
62-
if 'build_docs' in sys.argv or 'build_sphinx' in sys.argv:
63-
print(DOCS_HELP)
64-
sys.exit(1)
65-
66-
VERSION_TEMPLATE = """
67-
# Note that we need to fall back to the hard-coded version if either
68-
# setuptools_scm can't be imported or setuptools_scm can't determine the
69-
# version, so we catch the generic 'Exception'.
70-
try:
71-
from setuptools_scm import get_version
72-
version = get_version(root='..', relative_to=__file__)
73-
except Exception:
74-
version = '{version}'
75-
""".lstrip()
76-
77-
setup(use_scm_version={'write_to': os.path.join('astrodbkit2', 'version.py'),
78-
'write_to_template': VERSION_TEMPLATE})
3+
setup(use_scm_version=True)

0 commit comments

Comments
 (0)