diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ddec50..684db34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,8 +25,7 @@ All pull requests must: Follow the patterns seen in the code. Walk where others have walked. -The majority of code style nits will be met when passing `pre-commit` checks -prior to submitting a pull request. +Be sure to run the expected formatters and linters prior to opening the PR. ### Tests @@ -70,22 +69,22 @@ package, and installs all dependency files. nox -s dev ``` -### Run tests with coverage (quick) +### Run tests with coverage ```console -nox -e coverage +nox -s test ``` -### Run tests (slow) +### Run formatters and linters ```console -nox +nox -s lint ``` ### Build dist ```console -nox -e build +nox -s build ``` --- @@ -119,9 +118,3 @@ nox -s upgrade-deps This repo is setup with a `.pre-commit-config.yaml` with the expectation that any code submitted for review already passes all selected pre-commit checks. - ---- - -## Error: File "setup.py" not found - -Update `pip` to at least version 22.3.1 diff --git a/README.md b/README.md index 3915202..52ce775 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,7 @@ fit. - **Q:** Why not put the requirements into the `pyproject.toml`? - **A:** Mostly because `pip-compile` does all the work for me and doesn't - target the `pyproject.toml`. Partly because many of my projects need to be - scanned by utilities that still think `requirements.txt` is the only pattern - to use. + target the `pyproject.toml` dependency groups yet. - **Q:** Why does this template change so often? - **A:** I'm constantly finding new tweaks that make the template fit just a @@ -39,7 +37,3 @@ fit. - **Q:** Have I heard of uv? - **A:** Yes. I'm already exploring a uv driven workflow for this template. - You can see it on the `uv-workflow` branch. I will be waiting until the - April 2025 release of pip for support of - [dependency-groups](https://packaging.python.org/en/latest/specifications/dependency-groups/) - before committing to any changes. diff --git a/noxfile.py b/noxfile.py index 85c5963..edca70c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,7 +12,6 @@ MODULE_NAME = "module_name" TESTS_PATH = "tests" COVERAGE_FAIL_UNDER = 50 -DEFAULT_PYTHON = "3.12" VENV_PATH = "./.venv" LINT_PATH = "./src" REQUIREMENTS_PATH = "./requirements" @@ -37,33 +36,31 @@ nox.options.sessions = ["lint", "test"] -@nox.session(python=False) +@nox.session() def dev(session: nox.Session) -> None: """Setup a development environment by creating the venv and installs dependencies.""" # Use the active environement if it exists, otherwise create a new one venv_path = os.environ.get("VIRTUAL_ENV", VENV_PATH) if sys.platform == "win32": - py_command = "py" venv_path = f"{venv_path}/Scripts" activate_command = f"{venv_path}/activate" else: - py_command = f"python{DEFAULT_PYTHON}" venv_path = f"{venv_path}/bin" activate_command = f"source {venv_path}/activate" if not os.path.exists(VENV_PATH): - session.run(py_command, "-m", "venv", VENV_PATH, "--upgrade-deps") + session.run("python", "-m", "venv", VENV_PATH, "--upgrade-deps") - python = f"{venv_path}/python" - requirement_files = get_requirement_files() + python = partial(session.run, f"{venv_path}/python", "-m") - session.run(python, "-m", "pip", "install", "-e", ".") + requirement_files = get_requirement_files() for requirement_file in requirement_files: - session.run(python, "-m", "pip", "install", "-r", requirement_file) + python("pip", "install", "-r", requirement_file, external=True) + python("pip", "install", "--editable", ".", external=True) - session.run(python, "-m", "pip", "install", "pre-commit") - session.run(f"{venv_path}/pre-commit", "install") + python("pip", "install", "pre-commit", external=True) + session.run(f"{venv_path}/pre-commit", "install", external=True) if not os.environ.get("VIRTUAL_ENV"): session.log(f"\n\nRun '{activate_command}' to enter the virtual environment.\n") @@ -74,8 +71,7 @@ def run_tests_with_coverage(session: nox.Session) -> None: """Run pytest with coverage, outputs console report and json.""" print_standard_logs(session) - session.install(".") - session.install("-r", f"{REQUIREMENTS_PATH}/requirements-test.txt") + session.install(".", "-r", f"{REQUIREMENTS_PATH}/requirements-test.txt") coverage = partial(session.run, "python", "-m", "coverage") @@ -129,7 +125,7 @@ def run_linters_and_formatters(session: nox.Session) -> None: python("mypy", "--no-incremental", "--package", MODULE_NAME) -@nox.session(python=DEFAULT_PYTHON) +@nox.session() def build(session: nox.Session) -> None: """Build distribution files.""" print_standard_logs(session) @@ -138,7 +134,7 @@ def build(session: nox.Session) -> None: session.run("python", "-m", "build") -@nox.session(python=DEFAULT_PYTHON, name="update-deps") +@nox.session(name="update-deps") def update_deps(session: nox.Session) -> None: """Process requirement*.txt files, updating only additions/removals.""" print_standard_logs(session) @@ -156,7 +152,7 @@ def update_deps(session: nox.Session) -> None: ) -@nox.session(python=DEFAULT_PYTHON, name="upgrade-deps") +@nox.session(name="upgrade-deps") def upgrade_deps(session: nox.Session) -> None: """Process requirement*.txt files and upgrade all libraries as possible.""" print_standard_logs(session) diff --git a/pyproject.toml b/pyproject.toml index c5a51de..b710fb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,11 @@ [build-system] -requires = ["setuptools>=64", "setuptools_scm>=8"] +requires = ["setuptools>=64"] build-backend = "setuptools.build_meta" [project] name = "module-name" requires-python = ">=3.9" +version = "0.1.0" description = "Module Description" readme = "README.md" license = { file = "LICENSE" } @@ -19,7 +20,6 @@ classifiers = [ "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", ] -dynamic = ["version"] [project.urls] homepage = "https://github.com/[ORG NAME]/[REPO NAME]" @@ -27,9 +27,6 @@ homepage = "https://github.com/[ORG NAME]/[REPO NAME]" # [project.scripts] # python-src-example = "module_name.sample:main" -[tool.setuptools_scm] -# Purposely left empty - [tool.setuptools.package-data] "module_name" = ["py.typed"]