Skip to content

Commit f254bd9

Browse files
committed
Fixes to dev container and tests (but some test cases fail, e.g. running test_template_mypy
1 parent 2e9b88f commit f254bd9

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

__init__.py

Whitespace-only changes.

template/Dockerfile.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ RUN touch dev-requirements.txt && uv pip install -c dev-requirements.txt .
3232
# The runtime stage copies the built venv into a slim runtime container
3333
FROM python:${PYTHON_VERSION}-slim AS runtime
3434
# Add apt-get system dependecies for runtime here if needed
35-
COPY --from=build /venv/ /venv/
36-
ENV VIRTUAL_ENV=/venv
35+
COPY --from=build /venv/ .venv/
36+
ENV VIRTUAL_ENV=./.venv
3737
ENV PATH=$VIRTUAL_ENV/bin:$PATH
3838

3939
# change this entrypoint if it is not the same as the repo

template/pyproject.toml.jinja

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ GitHub = "{{ repo_url }}"
4949
email = "{{ author_email }}"
5050
name = "{{ author_name }}"
5151

52+
[tool.uv]
53+
default-groups = []
5254

5355
[tool.setuptools_scm]
5456
version_file = "src/{{ package_name }}/_version.py"
@@ -61,6 +63,8 @@ typeCheckingMode = "standard"
6163
{% endif %}{% if type_checker=="mypy" %}
6264
[tool.mypy]
6365
ignore_missing_imports = true # Ignore missing stubs in imported modules
66+
explicit_package_bases = true
67+
#no_namespace_packages = true
6468
{% endif %}
6569
[tool.pytest.ini_options]
6670
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error

tests/test_example.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ def run_pipe(cmd: str, cwd=None):
3737

3838

3939
def make_venv(project_path: Path) -> callable:
40-
venv_path = project_path / "venv"
41-
run_pipe(f"python -m venv {venv_path}")
40+
venv_path = project_path / ".venv"
41+
run_pipe(f"uv venv {venv_path}")
4242
run = functools.partial(run_pipe, cwd=str(project_path))
43-
run("./venv/bin/pip install -e .[dev]")
43+
# install to this env (hence the -p)
44+
run(f"uv pip install -e .[dev] -p {venv_path}/bin/python")
45+
# run("ls -la .venv/bin >&2")
4446
return run
4547

4648

@@ -53,14 +55,14 @@ def test_template_defaults(tmp_path: Path):
5355
catalog_info = tmp_path / "catalog-info.yaml"
5456
assert catalog_info.exists()
5557
assert 'typeCheckingMode = "strict"' in pyproject_toml.read_text()
56-
run("./venv/bin/tox -p")
58+
run(".venv/bin/tox -p")
5759
if not run_pipe("git tag --points-at HEAD"):
5860
# Only run linkcheck if not on a tag, as the CI might not have pushed
5961
# the docs for this tag yet, so we will fail
60-
run("./venv/bin/tox -e docs build -- -b linkcheck")
61-
run("./venv/bin/pip install build twine")
62-
run("./venv/bin/python -m build")
63-
run("./venv/bin/twine check --strict dist/*")
62+
run(".venv/bin/tox -p -e docs -- -b linkcheck")
63+
run(".venv/bin/uv pip install build twine")
64+
run(".venv/bin/python -m build")
65+
run(".venv/bin/twine check --strict dist/*")
6466

6567

6668
def test_template_with_extra_code_and_api_docs(tmp_path: Path):
@@ -100,7 +102,7 @@ class Thing:
100102
# Add to make sure pre-commit doesn't moan
101103
run("git add .")
102104
# Build
103-
run("./venv/bin/tox -p")
105+
run(".venv/bin/tox -p")
104106
# Check it generates the right output
105107
api_dir = tmp_path / "build" / "html" / "_api"
106108
top_html = api_dir / "python_copier_template_example.html"
@@ -121,13 +123,13 @@ class Thing:
121123
def test_template_mypy(tmp_path: Path):
122124
copy_project(tmp_path, type_checker="mypy")
123125
run = make_venv(tmp_path)
124-
run("./venv/bin/tox -p")
126+
run(".venv/bin/tox -p")
125127

126128

127129
def test_template_no_docs(tmp_path: Path):
128130
copy_project(tmp_path, docs_type="README")
129131
run = make_venv(tmp_path)
130-
run("./venv/bin/tox -p")
132+
run(".venv/bin/tox -p")
131133

132134

133135
def test_template_in_different_org_has_no_catalog(tmp_path: Path):
@@ -141,7 +143,7 @@ def test_template_no_docker_has_no_docs_and_works(tmp_path: Path):
141143
container_doc = tmp_path / "docs" / "how-to" / "run-container.md"
142144
assert not container_doc.exists()
143145
run = make_venv(tmp_path)
144-
run("./venv/bin/tox -p")
146+
run(".venv/bin/tox -p")
145147

146148

147149
def test_bad_repo_name(tmp_path: Path):
@@ -232,7 +234,7 @@ def test_pyright_works_in_standard_typing_mode(tmp_path: Path):
232234

233235
# Ensure pyright is still happy
234236
run = make_venv(tmp_path)
235-
run(f"./venv/bin/pyright {tmp_path}")
237+
run(f".venv/bin/pyright {tmp_path}")
236238

237239

238240
def test_ignores_mypy_strict_mode(tmp_path: Path):

0 commit comments

Comments
 (0)