Skip to content

Commit

Permalink
Merge pull request #1250 from zacharyburnett/pep621
Browse files Browse the repository at this point in the history
move build configuration from `setup.py` to `pyproject.toml`
  • Loading branch information
mfixstsci committed Apr 18, 2023
2 parents 13706f3 + 258b9a8 commit a68e805
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 78 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: pip install bandit
- run: bandit ./jwql/ -c .bandit

Expand Down Expand Up @@ -43,7 +45,7 @@ jobs:
cache-env: true
cache-downloads: true

- run: pip install -e .
- run: pip install -e .[test]

- run: conda env export

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include LICENSE
include CHANGES.rst
include environment_python_3_7.yml
include environment_python_3_8.yml
include setup.py
include pyproject.toml
include requirements.txt
include rtd_requirements.txt
include jwql/example_config.json
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ It is highly suggested that contributors have a working installation of `anacond
- [Miniconda](https://conda.io/miniconda.html)
- [Anaconda](https://www.continuum.io/downloads)

Requirements for contributing to the `jwql` package will be included in the `jwql` `conda` environment, which is included in our installation instructions below. Further package requirements will be provided for `jwql` by a `setup.py` script included in the repository.
Requirements for contributing to the `jwql` package will be included in the `jwql` `conda` environment, which is included in our installation instructions below. Further package requirements will be provided for `jwql` by a `pyproject.toml` file included in the repository.

### Clone the `jwql` repo

Expand Down
18 changes: 9 additions & 9 deletions jwql/utils/logging_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def my_main_function():
import time
import traceback

if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib

from functools import wraps

from jwql.utils.permissions import set_permissions
Expand Down Expand Up @@ -218,15 +223,10 @@ def wrapped(*args, **kwargs):
logging.info('Running as PID {}'.format(os.getpid()))

# Read in setup.py file to build list of required modules
with open(get_config()['setup_file']) as f:
data = f.readlines()

for i, line in enumerate(data):
if 'REQUIRES = [' in line:
begin = i + 1
elif 'setup(' in line:
end = i - 2
required_modules = data[begin:end]
with open("pyproject.toml", "rb") as f:
data = tomllib.load(f)

required_modules = data['project']['dependencies']

# Clean up the module list
module_list = [item.strip().replace("'", "").replace(",", "").split("=")[0].split(">")[0].split("<")[0] for item in required_modules]
Expand Down
78 changes: 73 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,74 @@
# pyproject.toml
[project]
name = "jwql"
description = "The James Webb Space Telescope Quicklook Project"
readme = "README.md"
authors = [
{ name = "Matthew Bourque" },
{ name = "Lauren Chambers" },
{ name = "Misty Cracraft" },
{ name = "Mike Engesser" },
{ name = "Mees Fix" },
{ name = "Joe Filippazzo" },
{ name = "Bryan Hilbert" },
]
keywords = ["astronomy", "python"]
classifiers = ["Programming Language :: Python"]
dependencies = [
"asdf",
"astropy",
"astroquery",
"bokeh<3",
"crds",
"cryptography",
"django",
"inflection",
"jinja2",
"jsonschema",
"jwst",
"jwst_reffiles",
"matplotlib",
"nodejs",
"numpy",
"numpydoc",
"pandas",
"psycopg2-binary",
"pysiaf",
"pyvo",
"scipy",
"sqlalchemy",
"stdatamodels",
"wtforms",
]
dynamic = ["version"]

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"pytest-mock",
]
docs = [
"sphinx",
"sphinx_rtd_theme",
"stsci_rtd_theme",
]

[project.license]
file = "LICENSE"
content-type = "text/plain"

[build-system]
requires = ["setuptools<=65.5.0",
"numpy",
"wheel",
"setuptools_scm"]
requires = ["setuptools>=61.2,<=65.5.0", "numpy", "wheel", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
namespaces = false

[tool.setuptools_scm]

[tool.pytest]
junit_family = "xunit2"
addopts = "--ignore=jwql/website/apps/jwql/static"
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

58 changes: 0 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,6 @@
import numpy as np
from setuptools import setup
from setuptools import find_packages

VERSION = '1.1.1'

AUTHORS = 'Matthew Bourque, Lauren Chambers, Misty Cracraft, Mike Engesser, Mees Fix, Joe Filippazzo, Bryan Hilbert, '
AUTHORS += 'Graham Kanarek, Teagan King, Catherine Martlin, Shannon Osborne, Maria Pena-Guerrero, Johannes Sahlmann, '
AUTHORS += 'Ben Sunnquist, Brian York'

DESCRIPTION = 'The James Webb Space Telescope Quicklook Project'

REQUIRES = [
'asdf',
'astropy',
'astroquery',
'bandit',
'bokeh<3',
'crds',
'cryptography',
'django',
'flake8',
'inflection',
'ipython',
'jinja2',
'jsonschema',
'jwst',
'jwst_reffiles',
'matplotlib',
'nodejs',
'numpy',
'numpydoc',
'pandas',
'psycopg2',
'pysiaf',
'pytest',
'pytest-cov',
'pytest-mock',
'pyvo',
'scipy',
'sphinx',
'sphinx_rtd_theme',
'sqlalchemy',
'stdatamodels',
'stsci_rtd_theme',
'twine',
'wtforms'
]

setup(
name='jwql',
version=VERSION,
description=DESCRIPTION,
url='https://github.com/spacetelescope/jwql.git',
author=AUTHORS,
author_email='jwql@stsci.edu',
license='BSD',
keywords=['astronomy', 'python'],
classifiers=['Programming Language :: Python'],
packages=find_packages(),
install_requires=REQUIRES,
include_package_data=True,
include_dirs=[np.get_include()],
)

0 comments on commit a68e805

Please sign in to comment.