Skip to content

Commit

Permalink
Completely migrated setuptools to use pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Apr 20, 2023
1 parent 4782745 commit f10f8b2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 78 deletions.
4 changes: 0 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
include AUTHORS.md
include CODE_OF_CONDUCT.md
include CHANGELOG.md
include CONTRIBUTING.md
include LICENSE
include README.md
include requirements/*.txt
include requirements/*.in
include requirements.txt

graft tests
prune __pycache__
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ test = [
[tool.setuptools.dynamic]
version = {attr = "bumpversion.__version__"}

[tool.setuptools.packages.find]
exclude = ["example*", "tests*", "docs*", "build"]

[tool.coverage.run]
branch = true
omit = ["**/test_*.py", "**/__main__.py", "**/aliases.py"]
Expand Down
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
[options]
zip_safe = False
include_package_data = True
packages = find:

[options.packages.find]
exclude =
example*
tests*
docs*
build

[darglint]
ignore = DAR402

Expand Down
63 changes: 1 addition & 62 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,4 @@
"""The setup script."""
from pathlib import Path
from typing import List, Optional

from setuptools import setup


def parse_reqs_in(filepath: Path, visited: Optional[set] = None) -> List[str]: # noqa: C901
"""
Parse a file path containing a pip-tools requirements.in and return a list of requirements.
Will properly follow ``-r`` and ``-c`` links like ``pip-tools``. This
means layered requirements will be returned as one list.
Other ``pip-tools`` and ``pip``-specific lines are excluded.
Args:
filepath (Path): The path to the requirements file
visited (set, optional): A set of paths that have already been visited.
Returns:
All the requirements as a list.
"""
if visited is None:
visited = set()
reqstr: str = filepath.read_text()
reqs: List[str] = []
for line in reqstr.splitlines(keepends=False):
line = line.strip() # noqa: PLW2901
if not line:
continue
elif not line or line.startswith("#"):
# comments are lines that start with # only
continue
elif line.startswith("-c"):
_, new_filename = line.split()
new_file_path = filepath.parent / new_filename.replace(".txt", ".in")
if new_file_path not in visited:
visited.add(new_file_path)
reqs.extend(parse_reqs_in(new_file_path, visited))
elif line.startswith(("-r", "--requirement")):
_, new_filename = line.split()
new_file_path = filepath.parent / new_filename
if new_file_path not in visited:
visited.add(new_file_path)
reqs.extend(parse_reqs_in(new_file_path, visited))
elif line.startswith("-f") or line.startswith("-i") or line.startswith("--"):
continue
elif line.startswith("-Z") or line.startswith("--always-unzip"):
continue
else:
reqs.append(line)
return reqs


here: Path = Path(__file__).parent.absolute()
requirements = parse_reqs_in(here / "requirements/prod.in")
dev_requirements = parse_reqs_in(here / "requirements/dev.in")
test_requirements = parse_reqs_in(here / "requirements/test.in")

setup(
install_requires=requirements,
tests_require=test_requirements,
extras_require={"dev": dev_requirements, "test": test_requirements},
)
setup()

0 comments on commit f10f8b2

Please sign in to comment.