Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
// Mount the parent as /workspaces so we can pip install peers as editable
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// After the container is created, recreate the venv then make pre-commit first run faster
"postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks"
// Ensure we use system uv, as there might be a different (old) version of uv in the venv
"postCreateCommand": "/usr/bin/uv venv --clear && /usr/bin/uv sync && pre-commit install --install-hooks"
}
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev = [
"sphinx-autobuild",
"sphinx-copybutton",
"sphinx-design",
"tox-uv",
"tox-uv-bare",
]

[tool.uv]
Expand All @@ -43,6 +43,13 @@ env_list = ["pre-commit", "tests", "docs"]
[tool.tox.env_run_base]
# Pass all environment variables to the test environments
passenv = ["*"]
allowlist_externals = [
"pyright",
"pytest",
"pre-commit",
"sphinx-build",
"sphinx-autobuild",
]

[tool.tox.env.pre-commit]
description = "Run pre-commit on all files"
Expand Down
11 changes: 10 additions & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev = [
{% if sphinx %}"sphinx-autobuild",
"sphinx-copybutton",
"sphinx-design",
{% endif %}"tox-uv",
{% endif %}"tox-uv-bare",
"types-mock",
]

Expand Down Expand Up @@ -90,6 +90,15 @@ env_list = ["pre-commit", "type-checking", "tests"{% if sphinx %}, "docs"{% endi
[tool.tox.env_run_base]
# Pass all environment variables to the test environments
passenv = ["*"]
allowlist_externals = [
{% if type_checker=="mypy" %}"mypy",
{% endif %}{% if type_checker=="pyright" %}"pyright",
{% endif %}"pytest",
"pre-commit",
{% if sphinx %}"sphinx-build",
"sphinx-autobuild",
{% endif %}
]

[tool.tox.env.pre-commit]
description = "Run pre-commit on all files"
Expand Down
7 changes: 6 additions & 1 deletion tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ def copy_project(project_path: Path, **kwargs):


def run_pipe(cmd: str, cwd=None, venv="") -> str:
env = dict(os.environ, UV_PROJECT_ENVIRONMENT="", VIRTUAL_ENV=venv)
if venv:
# Activate thevenv. This means the newly created Python project
# is in the environment, along with its associated tools.
env["PATH"] = f"{venv}/bin{os.pathsep}{env['PATH']}"
sp = subprocess.run(
shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=cwd,
env=dict(os.environ, UV_PROJECT_ENVIRONMENT="", VIRTUAL_ENV=venv),
env=env,
)
output = sp.stdout.decode()
assert sp.returncode == 0, output
Expand Down
42 changes: 2 additions & 40 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading