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

Migrate to pyproject.toml instead of setup.cfg #832

Merged
merged 6 commits into from
Aug 11, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__

# Other generated files
*/version.py
*/_version.py
*/cython_version.py
htmlcov
.coverage
Expand Down
64 changes: 36 additions & 28 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,26 @@
# be accessible, and the documentation will not build correctly.

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

try:
from sphinx_astropy.conf.v1 import * # noqa
except ImportError:
print('ERROR: the documentation requires the sphinx-astropy package to be installed')
sys.exit(1)

# Get configuration information from setup.cfg
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
conf = ConfigParser()
if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib

# Grab minversion from pyproject.toml
with (Path(__file__).parents[1] / "pyproject.toml").open("rb") as f:
pyproject = tomllib.load(f)

conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
setup_cfg = dict(conf.items('metadata'))
__minimum_python_version__ = pyproject["project"]["requires-python"].replace(">=", "")

# -- General configuration ----------------------------------------------------

Expand All @@ -68,20 +70,26 @@
# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = setup_cfg['name']
author = setup_cfg['author']
copyright = '{0}, {1}'.format(
datetime.datetime.now().year, setup_cfg['author'])
project = pyproject["project"]["name"]
author = ", ".join(v["name"] for v in pyproject["project"]["authors"])
copyright = f"{datetime.datetime.now().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
# built documents.
__import__(project)
package = sys.modules[project]

ver = package.__version__
version = '.'.join(ver.split('.'))[:5]
release = ver
import_module(pyproject["project"]["name"])
package = sys.modules[pyproject["project"]["name"]]

# The short X.Y version.
version = package.__version__.split("-", 1)[0]
# The full version, including alpha/beta/rc tags.
release = package.__version__

# Only include dev docs in dev version.
dev = "dev" in release
if not dev:
exclude_patterns += ["development/*"]

# -- Options for HTML output --------------------------------------------------

Expand Down Expand Up @@ -157,18 +165,18 @@

# -- Options for the edit_on_github extension ---------------------------------

if eval(setup_cfg.get('edit_on_github')):
extensions += ['sphinx_astropy.ext.edit_on_github']
# if eval(setup_cfg.get('edit_on_github')):
# extensions += ['sphinx_astropy.ext.edit_on_github']

versionmod = __import__(setup_cfg['name'] + '.version')
edit_on_github_project = setup_cfg['github_project']
if versionmod.version.release:
edit_on_github_branch = "v" + versionmod.version.version
else:
edit_on_github_branch = "main"
# versionmod = __import__(setup_cfg['name'] + '.version')
# edit_on_github_project = setup_cfg['github_project']
# if versionmod.version.release:
# edit_on_github_branch = "v" + versionmod.version.version
# else:
# edit_on_github_branch = "main"

edit_on_github_source_root = ""
edit_on_github_doc_root = "docs"
# edit_on_github_source_root = ""
# edit_on_github_doc_root = "docs"

# -- Resolving issue number to links in changelog -----------------------------
github_issues_url = 'https://github.com/astropy/ccdproc/issues/'
Expand Down
110 changes: 106 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,107 @@
[build-system]
requires = ["setuptools",
"setuptools_scm",
"wheel"]
build-backend = 'setuptools.build_meta'
requires = ["hatchling",
"hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "ccdproc"
dynamic = ["version"]
description = "Astropy affiliated package"
readme = "README.rst"
license = "BSD-3-clause"
requires-python = ">=3.8"
authors = [
{ name = "Steve Crawford", email = "[email protected]" },
{ name = "Matt Craig" },
{ name = "and Michael Seifert" },
]
dependencies = [
"astropy>=5.0.1",
"astroscrappy>=1.0.8",
"numpy>=1.21",
"reproject>=0.7",
"scikit-image",
"scipy",
]

[project.optional-dependencies]
docs = [
"matplotlib",
"sphinx-astropy",
]
test = [
"memory_profiler",
"pytest-astropy>=0.10.0",
]

[project.urls]
Homepage = "http://ccdproc.readthedocs.io/"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "ccdproc/_version.py"

[tool.hatch.build.targets.sdist]
include = [
"/ccdproc",
]

[tool.coverage]
[tool.coverage.run]
source = ["ccdproc"]
omit = [
"*/ccdproc/__init__*",
"*/ccdproc/conftest.py",
"*/ccdproc/*setup*",
"*/ccdproc/*/tests/*",
"*/ccdproc/tests/*",
]

[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}",
]

[tool.pytest.ini_options]
minversion = 7.0
testpaths = [
"ccdproc",
"docs",
]
norecursedirs = [
"docs[\\/]_build",
"docs[\\/]generated",
]
astropy_header = true
doctest_plus = "enabled"
text_file_format = "rst"
remote_data_strict = true
addopts = [
"--doctest-rst",
"--color=yes",
]
log_cli_level = "info"
xfail_strict = true
filterwarnings= [
"error",
"ignore:numpy\\.ufunc size changed:RuntimeWarning",
"ignore:numpy.ndarray size changed:RuntimeWarning",
"ignore:`np.bool` is a deprecated alias for the builtin `bool`:DeprecationWarning",
]
markers = [
"data_size(N): set dimension of square data array for ccd_data fixture",
"data_scale(s): set the scale of the normal distribution used to generate data",
"data_mean(m): set the center of the normal distribution used to generate data",
]
117 changes: 0 additions & 117 deletions setup.cfg

This file was deleted.

Loading