Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move build configuration to pyproject.toml #27

Merged
merged 8 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# flake8 does not support pyproject.toml (https://github.com/PyCQA/flake8/issues/234)

[flake8]
select = E101,E111,E112,E113,E101,E111,E112,E113,E201,E202,E203,E211,E221,E222,E223,E224,E225,E226,E227,E228,E231,E241,E242,E251,E271,E272,E273,E274,E901,E902,W191,W291,W292,W293,W391
exclude = extern,sphinx,*parsetab.py,build
24 changes: 17 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@

import os
import sys
import datetime
import importlib
from datetime import datetime
from pathlib import Path

import sphinx
import stsci_rtd_theme
from distutils.version import LooseVersion

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

try:
from ConfigParser import ConfigParser
except ImportError:
Expand All @@ -35,8 +42,9 @@
sys.path.insert(0, os.path.abspath('../stsci/imagestats'))

# -- General configuration ------------------------------------------------
conf.read([os.path.join(os.path.dirname(__file__), '../..', 'setup.cfg')])
setup_cfg = dict(conf.items('metadata'))
with open(Path(__file__).parent.parent.parent / "pyproject.toml", "rb") as configuration_file:
conf = tomllib.load(configuration_file)
setup_cfg = conf['project']

# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.3'
Expand Down Expand Up @@ -111,9 +119,11 @@ def check_sphinx_version(expected_version):


# General information about the project
project = setup_cfg['name']
author = setup_cfg['author']
copyright = u'{0}, {1}'.format(datetime.datetime.now().year, author)
with open(Path(__file__).parent.parent.parent / "pyproject.toml", "rb") as metadata_file:
metadata = tomli.load(metadata_file)['project']
project = metadata['name']
author = f'{metadata["authors"][0]["name"]} <{metadata["authors"][0]["email"]}>'
copyright = f'{datetime.today().year}, {author}'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
77 changes: 75 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,83 @@
[project]
name = "stsci.imagestats"
description = "Compute sigma-clipped statistics on data arrays"
requires-python = ">=3.7"
authors = [
{ name = "Warren Hack", email = "[email protected]" },
{ name = "Christopher Hanley" },
]
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Software Development :: Libraries :: Python Modules",
"Development Status :: 7 - Inactive",
]
dependencies = [
"numpy>=1.14",
]
dynamic = [
"version",
]

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

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

[project.urls]
Homepage = "https://github.com/spacetelescope/stsci.imagestats"
Tracker = "https://github.com/spacetelescope/stsci.imagestats/issues"
Documentation = "https://stsciimagestats.readthedocs.io/en/stable/"
"Source Code" = "https://github.com/spacetelescope/stsci.imagestats"

[project.optional-dependencies]
docs = [
"numpydoc",
"sphinx",
"sphinx-automodapi",
"sphinx-rtd-theme",
"stsci-rtd-theme",
]

[build-system]
requires = [
"setuptools>=38.2.5",
"setuptools_scm",
"setuptools>=61.2",
"setuptools_scm[toml] >=3.4",
"wheel",
"oldest-supported-numpy",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "stsci/imagestats/_version.py"

[tool.setuptools]
zip-safe = false
include-package-data = false
namespace-packages = [
"stsci",
]

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

[tool.setuptools.package-data]
"*" = [
"README.md",
"LICENSE.txt",
]

[tool.build-sphinx]
source-dir = "docs"
build-dir = "docs"
all_files = "1"

[tool.distutils.upload_docs]
upload-dir = "docs/_build/html"
show-response = 1
53 changes: 0 additions & 53 deletions setup.cfg

This file was deleted.

27 changes: 12 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import numpy
import sys
from setuptools import setup, find_packages, Extension
from setuptools import setup, Extension


# Setup C module include directories
Expand All @@ -17,20 +17,17 @@
('__STDC__', 1)
]

PACKAGE_DATA = {'': ['README.md', 'LICENSE.txt']}
ext_modules = [
Extension('stsci.imagestats.buildHistogram',
['src/buildHistogram.c'],
include_dirs=include_dirs,
define_macros=define_macros),
Extension('stsci.imagestats.computeMean',
['src/computeMean.c'],
include_dirs=include_dirs,
define_macros=define_macros),
]

setup(
use_scm_version={"write_to": "stsci/imagestats/_version.py"},
setup_requires=['setuptools_scm'],
package_data=PACKAGE_DATA,
ext_modules=[
Extension('stsci.imagestats.buildHistogram',
['src/buildHistogram.c'],
include_dirs=include_dirs,
define_macros=define_macros),
Extension('stsci.imagestats.computeMean',
['src/computeMean.c'],
include_dirs=include_dirs,
define_macros=define_macros),
],
ext_modules=ext_modules,
)