Skip to content

Commit

Permalink
BREAK: remove setup.cfg support (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Oct 15, 2024
1 parent 891a9d7 commit 7ca22c5
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/compwa_policy/.github/workflows/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
paths:
- .constraints/py3.*.txt
- .pre-commit-config.yaml
- setup.cfg
schedule:
- cron: "0 3 7 */2 *"
workflow_dispatch:
Expand Down
1 change: 0 additions & 1 deletion src/compwa_policy/.template/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"pyrightconfig.json",
"pytest.ini",
"requirements*.txt",
"setup.cfg",
"setup.py",
"tox.ini",
"typings",
Expand Down
4 changes: 2 additions & 2 deletions src/compwa_policy/check_dev_files/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from compwa_policy.utilities.pyproject import (
Pyproject,
PythonVersion,
get_build_system,
get_constraints_file,
has_pyproject_package_name,
)
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml

Expand All @@ -30,7 +30,7 @@ def main(python_version: PythonVersion, package_manager: PackageManagerChoice) -


def update_conda_environment(python_version: PythonVersion) -> None:
if get_build_system() is None:
if not has_pyproject_package_name():
return
yaml = create_prettier_round_trip_yaml()
updated = False
Expand Down
2 changes: 0 additions & 2 deletions src/compwa_policy/check_dev_files/github_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pathlib import Path

from compwa_policy.errors import PrecommitError
from compwa_policy.utilities import CONFIG_PATH
from compwa_policy.utilities.match import filter_files

__LABELS_CONFIG_FILE = "labels.toml"
Expand Down Expand Up @@ -56,7 +55,6 @@ def _get_requirement_files() -> list[Path]:
patterns = [
"**/requirements*.in",
"**/requirements*.txt",
str(CONFIG_PATH.setup_cfg),
]
filenames = filter_files(patterns)
return [Path(file) for file in filenames]
Expand Down
8 changes: 6 additions & 2 deletions src/compwa_policy/check_dev_files/github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
write,
)
from compwa_policy.utilities.executor import Executor
from compwa_policy.utilities.pyproject import Pyproject, PythonVersion, get_build_system
from compwa_policy.utilities.pyproject import (
Pyproject,
PythonVersion,
has_pyproject_package_name,
)
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml

if TYPE_CHECKING:
Expand Down Expand Up @@ -70,7 +74,7 @@ def update() -> None:
workflow_path = CONFIG_PATH.github_workflow_dir / "cd.yml"
expected_data = yaml.load(COMPWA_POLICY_DIR / workflow_path)
banned_jobs = set()
if no_pypi or get_build_system() is None:
if no_pypi or not has_pyproject_package_name():
banned_jobs.add("package-name")
banned_jobs.add("pypi")
if no_version_branches:
Expand Down
7 changes: 5 additions & 2 deletions src/compwa_policy/check_dev_files/jupyter.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""Update the developer setup when using Jupyter notebooks."""

from compwa_policy.utilities.pyproject import ModifiablePyproject, get_build_system
from compwa_policy.utilities.pyproject import (
ModifiablePyproject,
has_pyproject_package_name,
)


def main(no_ruff: bool) -> None:
_update_dev_requirements(no_ruff)


def _update_dev_requirements(no_ruff: bool) -> None:
if get_build_system() is None:
if not has_pyproject_package_name():
return
with ModifiablePyproject.load() as pyproject:
supported_python_versions = pyproject.get_supported_python_versions()
Expand Down
4 changes: 2 additions & 2 deletions src/compwa_policy/check_dev_files/ruff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ModifiablePyproject,
Pyproject,
complies_with_subset,
get_build_system,
has_pyproject_package_name,
)
from compwa_policy.utilities.readme import add_badge, remove_badge
from compwa_policy.utilities.toml import to_toml_array
Expand Down Expand Up @@ -624,7 +624,7 @@ def __add_nbqa_isort_pre_commit(precommit: ModifiablePrecommit) -> None:


def _update_lint_dependencies(pyproject: ModifiablePyproject) -> None:
if get_build_system() is None:
if not has_pyproject_package_name():
return
python_versions = pyproject.get_supported_python_versions()
if "3.6" in python_versions:
Expand Down
1 change: 0 additions & 1 deletion src/compwa_policy/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class _ConfigFilePaths(NamedTuple):
readthedocs: Path = Path(".readthedocs.yml")
release_drafter_config: Path = Path(".github/release-drafter.yml")
release_drafter_workflow: Path = Path(".github/workflows/release-drafter.yml")
setup_cfg: Path = Path("setup.cfg")
taplo: Path = Path(".taplo.toml")
tox: Path = Path("tox.ini")
vscode_extensions: Path = Path(".vscode/extensions.json")
Expand Down
18 changes: 3 additions & 15 deletions src/compwa_policy/utilities/pyproject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from compwa_policy.errors import PrecommitError
from compwa_policy.utilities import CONFIG_PATH
from compwa_policy.utilities.cfg import open_config
from compwa_policy.utilities.pyproject.getters import (
PythonVersion,
get_package_name,
Expand Down Expand Up @@ -265,15 +264,11 @@ def _complies_minimally(obj: Any, other: Any) -> bool:
return obj == other


def get_build_system() -> Literal["pyproject", "setup.cfg"] | None:
if _has_setup_cfg_build_system():
return "setup.cfg"
def has_pyproject_package_name() -> bool:
if not CONFIG_PATH.pyproject.exists():
return None
return False
pyproject = Pyproject.load()
if pyproject.get_package_name() is None:
return None
return "pyproject"
return pyproject.get_package_name() is not None


def get_constraints_file(python_version: PythonVersion) -> Path | None:
Expand All @@ -283,13 +278,6 @@ def get_constraints_file(python_version: PythonVersion) -> Path | None:
return None


def _has_setup_cfg_build_system() -> bool:
if not CONFIG_PATH.setup_cfg.exists():
return False
cfg = open_config(CONFIG_PATH.setup_cfg)
return cfg.has_section("metadata")


def load_pyproject_toml(source: IO | Path | str, modifiable: bool) -> PyprojectTOML:
"""Load a :code:`pyproject.toml` file from a file, I/O stream, or `str`.
Expand Down

0 comments on commit 7ca22c5

Please sign in to comment.