From f10f8b25303c503753b33b434a344600c94409ee Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Thu, 20 Apr 2023 11:49:38 -0500 Subject: [PATCH] Completely migrated setuptools to use pyproject.toml --- MANIFEST.in | 4 ---- pyproject.toml | 3 +++ setup.cfg | 12 ---------- setup.py | 63 +------------------------------------------------- 4 files changed, 4 insertions(+), 78 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index d7c4f505..bc889cf1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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__ diff --git a/pyproject.toml b/pyproject.toml index 2f729473..56fbd672 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/setup.cfg b/setup.cfg index b09589d7..660923b1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index b221a1bb..00bdab42 100644 --- a/setup.py +++ b/setup.py @@ -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()