-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consolidate build metadata in
pyproject.toml
(PEP621) (#241)
* apply `peppyproject` for PEP621 * remove deprecated codecov package * flake8 -> ruff * use pathlib to match filenames * run build workflow on PR, and do import check on C extension * use packages.find * change wheel-built numpy version to match runtime numpy version (below 2.0)
- Loading branch information
1 parent
16f02ce
commit 65a5a89
Showing
5 changed files
with
125 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: build | ||
|
||
on: | ||
release: | ||
types: [ released ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish.yml@v1 | ||
with: | ||
targets: | | ||
# Linux wheels | ||
- cp3*-manylinux_x86_64 | ||
# MacOS wheels | ||
- cp3*-macosx_x86_64 | ||
# Until we have arm64 runners, we can't automatically test arm64 wheels | ||
- cp3*-macosx_arm64 | ||
sdist: true | ||
test_command: python -c "from calcos import ccos" | ||
upload_to_pypi: ${{ (github.event_name == 'release') && (github.event.action == 'released') }} | ||
secrets: | ||
pypi_token: ${{ secrets.PYPI_PASSWORD_STSCI_MAINTAINER }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,85 @@ | ||
[project] | ||
name = "calcos" | ||
description = "Calibration software for COS (Cosmic Origins Spectrograph)" | ||
requires-python = ">=3.9" | ||
authors = [ | ||
{ name = "Phil Hodge", email="[email protected]" }, | ||
{ name = "Robert Jedrzejewski" }, | ||
] | ||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: C", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
dependencies = [ | ||
"astropy>=5.0.4", | ||
"numpy<2.0", | ||
"scipy", | ||
"stsci.tools>=4.0.0", | ||
] | ||
dynamic = [ | ||
"version", | ||
] | ||
|
||
[project.readme] | ||
file = "README.md" | ||
content-type = "text/markdown" | ||
|
||
[project.scripts] | ||
calcos = "calcos:main" | ||
|
||
[project.optional-dependencies] | ||
docs = [ | ||
"sphinx<7", | ||
] | ||
test = [ | ||
"ci-watson", | ||
"pytest", | ||
"pytest-cov", | ||
] | ||
|
||
[build-system] | ||
requires = [ | ||
"setuptools>=42.0", | ||
"setuptools_scm[toml]>=3.4", | ||
"wheel", | ||
"numpy>=2.0.0rc2", | ||
"oldest-supported-numpy", | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
include-package-data = false | ||
|
||
[tool.setuptools.packages.find] | ||
|
||
[tool.setuptools.package-data] | ||
calcos = [ | ||
"pars/*", | ||
"*.help", | ||
] | ||
|
||
[tool.setuptools_scm] | ||
version_file = "calcos/version.py" | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "3.0" | ||
norecursedirs = [ | ||
"build", | ||
"doc/build", | ||
"src", | ||
] | ||
junit_family = "xunit2" | ||
|
||
[tool.ruff.lint] | ||
exclude = [ | ||
"setup.py", | ||
"__init__.py", | ||
] | ||
ignore = [ | ||
"E265", | ||
"F821", | ||
"F841", | ||
] | ||
build-backend = 'setuptools.build_meta' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
from fnmatch import fnmatch | ||
from setuptools import setup, find_packages, Extension | ||
from setuptools import setup, Extension | ||
from numpy import get_include as numpy_includes | ||
from pathlib import Path | ||
|
||
def c_sources(parent): | ||
sources = [] | ||
for root, _, files in os.walk(parent): | ||
for f in files: | ||
fn = os.path.join(root, f) | ||
if fnmatch(fn, '*.c'): | ||
sources.append(fn) | ||
return sources | ||
|
||
def c_sources(parent: str) -> list[str]: | ||
return [str(filename) for filename in Path(parent).glob("*.c")] | ||
|
||
def c_includes(parent, depth=1): | ||
includes = [parent] | ||
for root, dirs, _ in os.walk(parent): | ||
for d in dirs: | ||
dn = os.path.join(root, d) | ||
if len(dn.split(os.sep)) - 1 > depth: | ||
continue | ||
includes.append(dn) | ||
return includes | ||
|
||
def c_includes(parent: str, depth: int = 1): | ||
return [ | ||
parent, | ||
*( | ||
str(filename) | ||
for filename in Path(parent).iterdir() | ||
if filename.is_dir() and len(filename.parts) - 1 <= depth | ||
), | ||
] | ||
|
||
|
||
PACKAGENAME = 'calcos' | ||
SOURCES = c_sources('src') | ||
INCLUDES = c_includes('src') + [numpy_includes()] | ||
PACKAGENAME = "calcos" | ||
SOURCES = c_sources("src") | ||
INCLUDES = c_includes("src") + [numpy_includes()] | ||
|
||
|
||
setup( | ||
name=PACKAGENAME, | ||
use_scm_version={'write_to': 'calcos/version.py'}, | ||
setup_requires=['setuptools_scm'], | ||
install_requires=[ | ||
'astropy>=5.0.4', | ||
'numpy<2.0', | ||
'scipy', | ||
'stsci.tools>=4.0.0', | ||
], | ||
extras_require={ | ||
'docs': [ | ||
'sphinx<7', | ||
], | ||
'test': [ | ||
'ci-watson', | ||
'pytest', | ||
'pytest-cov', | ||
'codecov', | ||
], | ||
}, | ||
packages=find_packages(), | ||
package_data={ | ||
PACKAGENAME: [ | ||
'pars/*', | ||
'*.help', | ||
], | ||
}, | ||
ext_modules=[ | ||
Extension( | ||
PACKAGENAME + '.ccos', | ||
PACKAGENAME + ".ccos", | ||
sources=SOURCES, | ||
include_dirs=INCLUDES, | ||
), | ||
], | ||
entry_points={ | ||
'console_scripts': { | ||
'calcos = calcos:main', | ||
}, | ||
}, | ||
author='Phil Hodge, Robert Jedrzejewski', | ||
author_email='[email protected]', | ||
description='Calibration software for COS (Cosmic Origins Spectrograph)', | ||
long_description='README.md', | ||
long_description_content_type='text/x-rst', | ||
url='https://github.com/spacetelescope/calcos', | ||
license='BSD', | ||
classifiers=[ | ||
'Intended Audience :: Science/Research', | ||
'License :: OSI Approved :: BSD License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: C', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
], | ||
) |