Skip to content

Commit 1e052c9

Browse files
authored
Clenaup and housekeeping (#193)
* Remove setuptools_scm from template This is less one-size-fits-all than a targeted solution * Remove hardcoded python version defaults Use whatever nox was installed with * Clean up extra install call * Update documentation
1 parent dd58585 commit 1e052c9

File tree

4 files changed

+21
-41
lines changed

4 files changed

+21
-41
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ All pull requests must:
2525

2626
Follow the patterns seen in the code. Walk where others have walked.
2727

28-
The majority of code style nits will be met when passing `pre-commit` checks
29-
prior to submitting a pull request.
28+
Be sure to run the expected formatters and linters prior to opening the PR.
3029

3130
### Tests
3231

@@ -70,22 +69,22 @@ package, and installs all dependency files.
7069
nox -s dev
7170
```
7271

73-
### Run tests with coverage (quick)
72+
### Run tests with coverage
7473

7574
```console
76-
nox -e coverage
75+
nox -s test
7776
```
7877

79-
### Run tests (slow)
78+
### Run formatters and linters
8079

8180
```console
82-
nox
81+
nox -s lint
8382
```
8483

8584
### Build dist
8685

8786
```console
88-
nox -e build
87+
nox -s build
8988
```
9089

9190
---
@@ -119,9 +118,3 @@ nox -s upgrade-deps
119118
120119
This repo is setup with a `.pre-commit-config.yaml` with the expectation that
121120
any code submitted for review already passes all selected pre-commit checks.
122-
123-
---
124-
125-
## Error: File "setup.py" not found
126-
127-
Update `pip` to at least version 22.3.1

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ fit.
2828

2929
- **Q:** Why not put the requirements into the `pyproject.toml`?
3030
- **A:** Mostly because `pip-compile` does all the work for me and doesn't
31-
target the `pyproject.toml`. Partly because many of my projects need to be
32-
scanned by utilities that still think `requirements.txt` is the only pattern
33-
to use.
31+
target the `pyproject.toml` dependency groups yet.
3432

3533
- **Q:** Why does this template change so often?
3634
- **A:** I'm constantly finding new tweaks that make the template fit just a
@@ -39,7 +37,3 @@ fit.
3937

4038
- **Q:** Have I heard of uv?
4139
- **A:** Yes. I'm already exploring a uv driven workflow for this template.
42-
You can see it on the `uv-workflow` branch. I will be waiting until the
43-
April 2025 release of pip for support of
44-
[dependency-groups](https://packaging.python.org/en/latest/specifications/dependency-groups/)
45-
before committing to any changes.

noxfile.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
MODULE_NAME = "module_name"
1313
TESTS_PATH = "tests"
1414
COVERAGE_FAIL_UNDER = 50
15-
DEFAULT_PYTHON = "3.12"
1615
VENV_PATH = "./.venv"
1716
LINT_PATH = "./src"
1817
REQUIREMENTS_PATH = "./requirements"
@@ -37,33 +36,31 @@
3736
nox.options.sessions = ["lint", "test"]
3837

3938

40-
@nox.session(python=False)
39+
@nox.session()
4140
def dev(session: nox.Session) -> None:
4241
"""Setup a development environment by creating the venv and installs dependencies."""
4342
# Use the active environement if it exists, otherwise create a new one
4443
venv_path = os.environ.get("VIRTUAL_ENV", VENV_PATH)
4544

4645
if sys.platform == "win32":
47-
py_command = "py"
4846
venv_path = f"{venv_path}/Scripts"
4947
activate_command = f"{venv_path}/activate"
5048
else:
51-
py_command = f"python{DEFAULT_PYTHON}"
5249
venv_path = f"{venv_path}/bin"
5350
activate_command = f"source {venv_path}/activate"
5451

5552
if not os.path.exists(VENV_PATH):
56-
session.run(py_command, "-m", "venv", VENV_PATH, "--upgrade-deps")
53+
session.run("python", "-m", "venv", VENV_PATH, "--upgrade-deps")
5754

58-
python = f"{venv_path}/python"
59-
requirement_files = get_requirement_files()
55+
python = partial(session.run, f"{venv_path}/python", "-m")
6056

61-
session.run(python, "-m", "pip", "install", "-e", ".")
57+
requirement_files = get_requirement_files()
6258
for requirement_file in requirement_files:
63-
session.run(python, "-m", "pip", "install", "-r", requirement_file)
59+
python("pip", "install", "-r", requirement_file, external=True)
60+
python("pip", "install", "--editable", ".", external=True)
6461

65-
session.run(python, "-m", "pip", "install", "pre-commit")
66-
session.run(f"{venv_path}/pre-commit", "install")
62+
python("pip", "install", "pre-commit", external=True)
63+
session.run(f"{venv_path}/pre-commit", "install", external=True)
6764

6865
if not os.environ.get("VIRTUAL_ENV"):
6966
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:
7471
"""Run pytest with coverage, outputs console report and json."""
7572
print_standard_logs(session)
7673

77-
session.install(".")
78-
session.install("-r", f"{REQUIREMENTS_PATH}/requirements-test.txt")
74+
session.install(".", "-r", f"{REQUIREMENTS_PATH}/requirements-test.txt")
7975

8076
coverage = partial(session.run, "python", "-m", "coverage")
8177

@@ -129,7 +125,7 @@ def run_linters_and_formatters(session: nox.Session) -> None:
129125
python("mypy", "--no-incremental", "--package", MODULE_NAME)
130126

131127

132-
@nox.session(python=DEFAULT_PYTHON)
128+
@nox.session()
133129
def build(session: nox.Session) -> None:
134130
"""Build distribution files."""
135131
print_standard_logs(session)
@@ -138,7 +134,7 @@ def build(session: nox.Session) -> None:
138134
session.run("python", "-m", "build")
139135

140136

141-
@nox.session(python=DEFAULT_PYTHON, name="update-deps")
137+
@nox.session(name="update-deps")
142138
def update_deps(session: nox.Session) -> None:
143139
"""Process requirement*.txt files, updating only additions/removals."""
144140
print_standard_logs(session)
@@ -156,7 +152,7 @@ def update_deps(session: nox.Session) -> None:
156152
)
157153

158154

159-
@nox.session(python=DEFAULT_PYTHON, name="upgrade-deps")
155+
@nox.session(name="upgrade-deps")
160156
def upgrade_deps(session: nox.Session) -> None:
161157
"""Process requirement*.txt files and upgrade all libraries as possible."""
162158
print_standard_logs(session)

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[build-system]
2-
requires = ["setuptools>=64", "setuptools_scm>=8"]
2+
requires = ["setuptools>=64"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "module-name"
77
requires-python = ">=3.9"
8+
version = "0.1.0"
89
description = "Module Description"
910
readme = "README.md"
1011
license = { file = "LICENSE" }
@@ -19,17 +20,13 @@ classifiers = [
1920
"Programming Language :: Python :: 3 :: Only",
2021
"Programming Language :: Python :: Implementation :: CPython",
2122
]
22-
dynamic = ["version"]
2323

2424
[project.urls]
2525
homepage = "https://github.com/[ORG NAME]/[REPO NAME]"
2626

2727
# [project.scripts]
2828
# python-src-example = "module_name.sample:main"
2929

30-
[tool.setuptools_scm]
31-
# Purposely left empty
32-
3330
[tool.setuptools.package-data]
3431
"module_name" = ["py.typed"]
3532

0 commit comments

Comments
 (0)