Skip to content

Commit

Permalink
Merge pull request #1093 from aphearin/pytoml
Browse files Browse the repository at this point in the history
Migrate to pyproject.toml
  • Loading branch information
aphearin authored Sep 8, 2024
2 parents bdaa6df + f4ab1d6 commit c8e519d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 102 deletions.
55 changes: 10 additions & 45 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
#

import datetime
import os
import sys
from datetime import datetime, timezone
from importlib import metadata

try:
import sphinx_astropy
Expand All @@ -16,53 +17,30 @@
sys.path.insert(1, a_h_path)

# Load all of the global Astropy configuration
from sphinx_astropy.conf import *

# Get configuration information from setup.cfg
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
conf = ConfigParser()
conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")])
setup_cfg = dict(conf.items("metadata"))
from sphinx_astropy.conf.v2 import exclude_patterns

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

# 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.3.1")
needs_sphinx = "3.0"

# List of patterns, relative to source directory, that match files and
# 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 += """
"""

# -- 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 = "halotools"
author = "Andrew Hearin"
copyright = f"2017–{datetime.now(tz=timezone.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__(setup_cfg["name"])
package = sys.modules[setup_cfg["name"]]

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


# -- Options for HTML output --------------------------------------------------
Expand Down Expand Up @@ -103,7 +81,7 @@

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = "{0} v{1}".format(project, release)
html_title = f"{project} v{release}"

# Output file base name for HTML help builder.
htmlhelp_basename = project + "doc"
Expand All @@ -128,16 +106,3 @@
man_pages = [("index", project.lower(), project + " Documentation", [author], 1)]

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

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 = "master"

edit_on_github_source_root = ""
edit_on_github_doc_root = "docs"
47 changes: 45 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
[build-system]
[project]
name = "halotools"
dynamic = ["version", "dependencies"]
description = "Package designed to analyze N-body simulations and constrain models of cosmology and galaxy evolution"
readme = "README.rst"
authors = [
{ name = "Andrew Hearin", email = "[email protected]" }
]
license = { text = "BSD-3-Clause" }
requires-python = ">=3.10"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[project.optional-dependencies]
test = [
"coverage[toml]",
"pytest>=7.0",
"pytest-astropy>=0.10",
"pytest-xdist",
]
docs = [
"sphinx-astropy",
"pytest>=7.0",
"matplotlib",
]


[tool.setuptools]
include-package-data = true
package-dir = {halotools = "halotools"}
package-data = {halotools = ["data/*", "*/data/*", "*/*/data/*", "*/*/*/data/*", "*/*/*/*/data/*", "*/*/*/*/*/data/*", "*/*/*/*/*/*/data/*"]}
license-files = ["licenses/*.rst"]

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = ["halotools", "docs"]
astropy_header = true
doctest_plus = "enabled"
text_file_format = "rst"
addopts = [
"--doctest-rst",
]
markers = ["slow", "installation_test"]

[build-system]
requires = ["setuptools>=42.0.0",
"setuptools_scm",
"wheel",
"oldest-supported-numpy",
"cython==3.0.2",
"extension-helpers==1.*"]

build-backend = 'setuptools.build_meta'


Expand Down
54 changes: 0 additions & 54 deletions setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extras =
commands =
pip freeze
!cov: pytest --pyargs halotools {toxinidir}/docs {posargs}
cov: pytest --pyargs halotools {toxinidir}/docs --cov halotools --cov-config={toxinidir}/setup.cfg {posargs}
cov: pytest --pyargs halotools {toxinidir}/docs --cov halotools --cov-config={toxinidir}/pyproject.toml {posargs}
cov: coverage xml -o {toxinidir}/coverage.xml

[testenv:build_docs]
Expand Down

0 comments on commit c8e519d

Please sign in to comment.