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 to using pyproject.toml #526

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
ignore=
# missing whitespace around arithmetic operator
E226,
# line break before binary operator (have to choose before or after),
W503
exclude =
# part of astropy affilliated package template, not our worry.
baseband/conftest.py,baseband/version.py,baseband/__init__.py,
baseband/_astropy_init.py,
docs/conf.py,
setup.py,
# standard things to ignore
__pycache__,build,dist,htmlcov,licenses
13 changes: 13 additions & 0 deletions .github/workflows/ci_cron_monthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ on:
types:
- synchronize
- labeled
push:
# We want this workflow to always run on release branches as well as
# all tags since we want to be really sure we don't introduce
# regressions on the release branches, and it's also important to run
# this on pre-release and release tags.
branches:
- 'v*'
tags:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test_more_architectures:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Test basics and coverage
python: "3.12"
toxenv: py312-test-cov
toxenv: py312-test-cov-xml

- name: Code style checks
python: "3.x"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ __pycache__
*.c

# Other generated files
*/version.py
*/_version.py
*/cython_version.py
htmlcov
.coverage
Expand Down
2 changes: 1 addition & 1 deletion baseband/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['__version__', 'test']

try:
from .version import version as __version__
from ._version import version as __version__
except ImportError:
__version__ = ''

Expand Down
8 changes: 5 additions & 3 deletions baseband/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ def _full_path(name, dirname=_path.dirname(_path.abspath(__file__))):
SAMPLE_VEGAS = _full_path('sample_vegas.raw')
r"""VEGAS sample, npol=2, obsnchan=32.

Created from a Green Bank Telescope observation of TOI 1898
dd if=vegas_59332_80137_Jade_1898_1_0001.0000.raw \
of=sample_vegas.raw bs=80 count=178
Created from a Green Bank Telescope observation of TOI 1898::

dd if=vegas_59332_80137_Jade_1898_1_0001.0000.raw \
of=sample_vegas.raw bs=80 count=178

Initial frame is >50 MB and truncated. For tests of header functionality only.
"""

Expand Down
78 changes: 31 additions & 47 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,24 @@

import os
import sys
import datetime
import tomllib
import warnings
from datetime import UTC, datetime
from importlib import import_module
from pathlib import Path

import baseband

try:
with warnings.catch_warnings():
# Remove warning about matplotlib - we don't use it.
warnings.filterwarnings("ignore", "matplotlib")
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
from configparser import ConfigParser
conf = ConfigParser()

conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
setup_cfg = dict(conf.items('metadata'))
# -- Get user configuration from pyproject.toml -------------------------------
with (Path(__file__).parents[1] / "pyproject.toml").open("rb") as f:
pyproject = tomllib.load(f)

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

# By default, highlight as Python 3.
highlight_language = 'python3'

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.2'

# To perform a Sphinx version check that needs to be more specific than
# major.minor, call `check_sphinx_version("x.y.z")` here.
# check_sphinx_version("1.2.1")

# add any custom intersphinx mappings
intersphinx_mapping['baseband_tasks'] = (
'https://baseband.readthedocs.io/projects/baseband-tasks/en/stable/', None)
Expand All @@ -65,38 +53,36 @@
# directories to ignore when looking for source files.
exclude_patterns.append('_templates')

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
rst_epilog += """
.. _Python: https://www.python.org/
.. _Astropy: https://www.astropy.org
.. _NumPy: https://numpy.org
.. _baseband-tasks: https://baseband.readthedocs.io/projects/baseband-tasks/
.. |minimum_python_version| replace:: {0.__minimum_python_version__}
.. |minimum_astropy_version| replace:: {0.__minimum_astropy_version__}
.. |minimum_numpy_version| replace:: {0.__minimum_numpy_version__}
""".format(baseband)

# -- 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(auth["name"] for auth in pyproject["project"]["authors"])
copyright = f"{datetime.now(tz=UTC).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_module(setup_cfg['name'])
package = sys.modules[setup_cfg['name']]
import_module(project)
package = sys.modules[project]

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

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
rst_epilog += """
.. _Python: https://www.python.org/
.. _Astropy: https://www.astropy.org
.. _NumPy: https://numpy.org
.. _baseband-tasks: https://baseband.readthedocs.io/projects/baseband-tasks/
.. |minimum_python_version| replace:: {0.__minimum_python_version__}
.. |minimum_astropy_version| replace:: {0.__minimum_astropy_version__}
.. |minimum_numpy_version| replace:: {0.__minimum_numpy_version__}
""".format(package)

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

Expand Down Expand Up @@ -167,15 +153,13 @@

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

if eval(setup_cfg.get('edit_on_github')):
extensions += ['sphinx_astropy.ext.edit_on_github']
edit_on_github_project = setup_cfg['github_project']
edit_on_github_branch = "master"
edit_on_github_source_root = ""
edit_on_github_doc_root = "docs"
extensions += ['sphinx_astropy.ext.edit_on_github']
edit_on_github_project = pyproject["project"]["urls"]["repository"].replace("https://github.com/", "")
edit_on_github_source_root = ""
edit_on_github_doc_root = "docs"

# -- Resolving issue number to links in changelog -----------------------------
github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project'])
github_issues_url = pyproject["project"]["urls"]["repository"] + "/issues/"

# -- Turn on nitpicky mode for sphinx (to warn about references not found) ----
#
Expand Down
122 changes: 118 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,121 @@
[project]
name = "baseband"
description = "A package for radio baseband I/O"
readme = { file = "README.rst", content-type = "text/x-rst" }
requires-python = ">=3.10"
license = { text = "GNU GPL v3+" }
authors = [
{ name = "Marten H. van Kerkwijk", email = "[email protected]"},
{ name = "Chenchong Zhu" },
]
dynamic = ["version"]
dependencies = [
"astropy>=5.1",
]

[build-system]
requires = [
"setuptools>=62.1",
"setuptools_scm[toml]>=6.2",
"wheel",
]
build-backend = "setuptools.build_meta"

[project.optional-dependencies]
all = ["baseband-tasks[all]"]
test = [
"pytest-astropy-header",
"pytest-doctestplus",
"pytest-filter-subpackage",
"pytest-remotedata",
]
cov = [
"coverage",
"pytest-cov",
]
docs = ["sphinx-astropy"]

[project.urls]
repository = "https://github.com/mhvk/baseband"
documentation = "https://baseband.readthedocs.io"

[project.entry-points."baseband.io"]
dada = "baseband.dada"
guppi = "baseband.guppi"
mark4 = "baseband.mark4"
mark5b = "baseband.mark5b"
vdif = "baseband.vdif"
gsb = "baseband.gsb"

[tool.setuptools]
include-package-data = true
license-files = ["LICENSE", "licenses/*.rst"]

[tool.setuptools.packages.find]
include = ["baseband*"]
exclude = ["baseband._dev*"]

[tool.setuptools.package-data]
"*" = ["data/*", "data/gsb/*"]

[tool.setuptools_scm]
write_to = "baseband/_version.py"

[tool.pytest.ini_options]
testpaths = [
"baseband",
"docs",
]
astropy_header = true
astropy_header_packages = [
"astropy",
"numpy",
]
doctest_plus = "enabled"
text_file_format = "rst"
addopts = "--color=yes --doctest-rst" # --doctest-ignore-import-errors?
filterwarnings = [
"error",
"ignore:::pytest_doctestplus",
"ignore:numpy.ufunc size changed:RuntimeWarning",
"ignore:numpy.ndarray size changed:RuntimeWarning",
]

requires = ["setuptools",
"setuptools_scm",
"wheel"]
[tool.coverage.run]
omit = [
"baseband/__init*",
"baseband/conftest.py",
"baseband/*setup_package*",
"baseband/tests/*",
"baseband/*/tests/*",
"baseband/extern/*",
"baseband/version*",
"*/baseband/__init*",
"*/baseband/conftest.py",
"*/baseband/*setup_package*",
"*/baseband/tests/*",
"*/baseband/*/tests/*",
"*/baseband/extern/*",
"*/baseband/version*",
]

build-backend = 'setuptools.build_meta'
[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}",
# Don't complain about IPython completion helper
"def _ipython_key_completions_",
# typing.TYPE_CHECKING is False at runtime
"if TYPE_CHECKING:",
# Ignore typing overloads
"@overload",
]
Loading
Loading