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 10 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
31 changes: 20 additions & 11 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 @@ -45,7 +47,17 @@
conf = ConfigParser()

conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")])
setup_cfg = dict(conf.items("metadata"))
# setup_cfg = dict(conf.items("metadata"))

#Get configuration from pyproject.toml
toml_conf_path = Path(__file__).parent.parent / "pyproject.toml"

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 +194,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 +289,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
150 changes: 99 additions & 51 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[build-system]
requires = ["setuptools",
"setuptools_scm",
"wheel"]
requires = ["setuptools", "setuptools_scm", "wheel"]
build-backend = 'setuptools.build_meta'

[tool.black]
Expand Down Expand Up @@ -52,74 +50,74 @@ verbose = 0
[tool.ruff]
line-length = 80
lint.select = ["ALL"]
exclude=[]
lint.ignore = [ # NOTE: non-permanent exclusions should be added to `.ruff.toml` instead.
exclude = []
lint.ignore = [ # NOTE: non-permanent exclusions should be added to `.ruff.toml` instead.

# flake8-builtins (A) : shadowing a Python built-in.
# New ones should be avoided and is up to maintainers to enforce.
"A00",
# flake8-builtins (A) : shadowing a Python built-in.
# New ones should be avoided and is up to maintainers to enforce.
"A00",

# flake8-annotations (ANN)
"ANN101", # No annotation for `self`.
"ANN102", # No annotation for `cls`.
# flake8-annotations (ANN)
"ANN101", # No annotation for `self`.
"ANN102", # No annotation for `cls`.

# flake8-bugbear (B)
"B008", # FunctionCallArgumentDefault
# flake8-bugbear (B)
"B008", # FunctionCallArgumentDefault

# flake8-commas (COM)
"COM812", # TrailingCommaMissing
"COM819", # TrailingCommaProhibited
# flake8-commas (COM)
"COM812", # TrailingCommaMissing
"COM819", # TrailingCommaProhibited

# pydocstyle (D)
# Missing Docstrings
"D102", # Missing docstring in public method. Don't check b/c docstring inheritance.
"D105", # Missing docstring in magic method. Don't check b/c class docstring.
# Whitespace Issues
"D200", # FitsOnOneLine
# Docstring Content Issues
"D410", # BlankLineAfterSection. Using D412 instead.
"D400", # EndsInPeriod. NOTE: might want to revisit this.
# pydocstyle (D)
# Missing Docstrings
"D102", # Missing docstring in public method. Don't check b/c docstring inheritance.
KasukabeDefenceForce marked this conversation as resolved.
Show resolved Hide resolved
"D105", # Missing docstring in magic method. Don't check b/c class docstring.
# Whitespace Issues
"D200", # FitsOnOneLine
# Docstring Content Issues
"D410", # BlankLineAfterSection. Using D412 instead.
"D400", # EndsInPeriod. NOTE: might want to revisit this.

# pycodestyle (E, W)
"E711", # NoneComparison (see unfixable)
"E741", # AmbiguousVariableName. Physics variables are often poor code variables
# pycodestyle (E, W)
"E711", # NoneComparison (see unfixable)
"E741", # AmbiguousVariableName. Physics variables are often poor code variables

# flake8-fixme (FIX)
"FIX002", # Line contains TODO | notes for improvements are OK iff the code works
# flake8-fixme (FIX)
"FIX002", # Line contains TODO | notes for improvements are OK iff the code works

# ISC001 shouldn't be used with ruff format
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"ISC001",
# ISC001 shouldn't be used with ruff format
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"ISC001",

# pep8-naming (N)
"N803", # invalid-argument-name. Physics variables are often poor code variables
"N806", # non-lowercase-variable-in-function. Physics variables are often poor code variables
# pep8-naming (N)
"N803", # invalid-argument-name. Physics variables are often poor code variables
"N806", # non-lowercase-variable-in-function. Physics variables are often poor code variables

# pandas-vet (PD)
"PD",
# pandas-vet (PD)
"PD",

# flake8-self (SLF)
"SLF001", # private member access
# flake8-self (SLF)
"SLF001", # private member access

# flake8-todos (TD)
"TD002", # Missing author in TODO
# flake8-todos (TD)
"TD002", # Missing author in TODO

# Ruff-specific rules (RUF)
"RUF005", # unpack-instead-of-concatenating-to-collection-literal -- it's not clearly faster.
# Ruff-specific rules (RUF)
"RUF005", # unpack-instead-of-concatenating-to-collection-literal -- it's not clearly faster.
]

[tool.ruff.lint.extend-per-file-ignores]
"setup.py" = ["INP001"] # Part of configuration, not a package.
"setup.py" = ["INP001"] # Part of configuration, not a package.
".github/workflows/*.py" = ["INP001"]
"test_*.py" = [
"B018", # UselessExpression
"D", # pydocstyle
"S101", # Use of assert detected
"B018", # UselessExpression
"D", # pydocstyle
"S101", # Use of assert detected
]
".pyinstaller/*.py" = ["INP001"] # Not a package.
"conftest.py" = ["INP001"] # Part of configuration, not a package.
".pyinstaller/*.py" = ["INP001"] # Not a package.
"conftest.py" = ["INP001"] # Part of configuration, not a package.
"docs/*.py" = [
"INP001", # implicit-namespace-package. The examples are not a package.
"INP001", # implicit-namespace-package. The examples are not a package.
]

[tool.ruff.lint.flake8-annotations]
Expand All @@ -137,3 +135,53 @@ known-first-party = ["tardis", "carsus", "stardis"]

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

[project]
name = "tardis"
authors = [{ name = "TARDIS Collaboration", email = "[email protected]" }]
license = { file = "licenses/LICENSE.rst" }
classifiers = ["License :: BSD-3-Clause"]
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"]

KasukabeDefenceForce marked this conversation as resolved.
Show resolved Hide resolved
[project.optional-dependencies]
test = ['pytest-astropy']
docs = ["sphinx-astropy"]

[project.scripts]
cmfgen2tardis = "tardis.scripts.cmfgen2tardis:main"
tardis_test_runner = "tardis.tests.integration_tests.runner:run_tests"

[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"

[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"]
# addopts = "--astropy-header"
# 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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ exclude_lines =
[options.entry_points]
console_scripts =
Copy link
Member

Choose a reason for hiding this comment

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

In the end, we want to remove setup.cfg

You want to remove this and then make sure the tests pass.

Copy link
Member

Choose a reason for hiding this comment

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

also I will suggest adding some reference links in the pr description on why we're switching from setup.cfg to pyproject.toml

Copy link
Member

@atharva-2001 atharva-2001 Jul 10, 2024

Choose a reason for hiding this comment

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

on a side note, we also want to perhaps remove setup.py- these files are outdated and python community has better ways for packaging if you could research it would be great.

cmfgen2tardis = tardis.scripts.cmfgen2tardis:main
tardis_test_runner = tardis.tests.integration_tests.runner:run_tests
tardis_test_runner = tardis.tests.integration_tests.runner:run_tests
Loading