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

Change setup.cfg to pyproject.toml #2694

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
33 changes: 17 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import datetime
import tardis # FIXME: this import is required by astropy.constants
from importlib import import_module
import toml
from pathlib import Path

try:
from sphinx_astropy.conf.v1 import * # noqa
Expand All @@ -39,13 +41,15 @@
)
sys.exit(1)

# Get configuration information from setup.cfg
from configparser import ConfigParser
#Get configuration information from pyproject.toml
toml_conf_path = Path(__file__).parent.parent / "pyproject.toml"

conf = ConfigParser()

conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")])
setup_cfg = dict(conf.items("metadata"))
with open(toml_conf_path, 'r') as f_toml:
toml_config = toml.load(f_toml)
toml_config_project_dict = toml_config["project"]
toml_config_tool_dict = toml_config['tool']
for k,v in toml_config_project_dict.items():
print(k,v)

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

Expand Down Expand Up @@ -182,16 +186,16 @@
# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = setup_cfg["name"]
author = setup_cfg["author"]
project = toml_config_project_dict["name"]
author = toml_config_project_dict["authors"][0]["name"]
copyright = "2013-{0}, {1}".format(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_module(setup_cfg["name"])
package = sys.modules[setup_cfg["name"]]
import_module(toml_config_project_dict["name"])
package = sys.modules[toml_config_project_dict["name"]]

# The short X.Y version.
version = "latest" # package.__version__.split("-", 1)[0]
Expand Down Expand Up @@ -277,21 +281,18 @@

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

if setup_cfg.get("edit_on_github").lower() == "true":
if toml_config_tool_dict["tardis"]['edit_on_github'] == True:

extensions += ["sphinx_astropy.ext.edit_on_github"]

edit_on_github_project = setup_cfg["github_project"]
edit_on_github_project = toml_config_project_dict["github_project"]
edit_on_github_branch = "main"

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 = toml_config_project_dict['urls']['Issues']

# -- Options for linkcheck output -------------------------------------------
linkcheck_retry = 5
Expand Down
53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
[project]
name = "tardis"
authors = [{ name = "TARDIS Collaboration", email = "[email protected]" }]
license = { text = "BSD-3-Clause" }
classifiers = ["License :: OSI Approved :: BSD License"]
description = "TARDIS - Temperature And Radiative Diffusion In Supernovae"
readme = { file = "README.rst", content-type = "text/x-rst" }
requires-python = ">=3.7"
dependencies = ["astropy"]
dynamic = ["version"]

[project.optional-dependencies]
test = ['pytest-astropy']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use double quotes consistently

docs = ["sphinx-astropy"]

[project.scripts]
cmfgen2tardis = "tardis.scripts.cmfgen2tardis:main"

[project.urls]
Homepage = "https://tardis-sn.github.io/"
Documentation = "https://tardis-sn.github.io/tardis/"
Repository = "https://github.com/tardis-sn/tardis"
Issues = "https://github.com/tardis-sn/tardis/issues/"
Changelog = "https://tardis-sn.github.io/tardis/contributing/CHANGELOG.html"

[build-system]
requires = ["setuptools",
"setuptools_scm",
Expand Down Expand Up @@ -137,3 +162,31 @@ known-first-party = ["tardis", "carsus", "stardis"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.setuptools]
packages = ["tardis"]
license-files = ["LICENSE.rst", "licenses/*.rst"]

[tool.setuptools.package-data]
tardis = ["data/*"]
tardis_grid = ["tests/data/*", "./"]
tardis_io = [
"configuration/schemas/*",
"configuration/tests/data/*",
"model/readers/tests/data/*"
]
tardis_model_tests = ["data/*"]
tardis_montecarlo_tests = ["data/*"]
tardis_plasma_tests = ["data/*"]
tardis_scripts = ["debug/*"]
tardis_tests_integration_tests = ["**/*"]
tardis_visualization = ["tools/tests/data/*"]

[tool.pytest.ini_options]
testpaths = ["tardis"]
# astropy_header = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests were failing after I added those two lines so I was testing which is exactly causing the tests to fail.

# doctest_plus = "disabled"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we keeping a commented out line?

text_file_format = "rst"

[tool.tardis]
edit_on_github = false
91 changes: 0 additions & 91 deletions setup.cfg

This file was deleted.

Loading