Add input no-project in combination with activate-environment (#856)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Release Drafter / ✏️ Draft release (push) Waiting to run
test / lint (push) Waiting to run
test / test-default-version (macos-14) (push) Waiting to run
test / test-default-version (macos-latest) (push) Waiting to run
test / test-default-version (ubuntu-latest) (push) Waiting to run
test / test-default-version (windows-latest) (push) Waiting to run
test / test-uv-no-modify-path (push) Waiting to run
test / test-specific-version (map[expected-version:0.1.0 resolution-strategy:lowest version-input:>=0.1.0,<0.2]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.1.45 resolution-strategy:highest version-input:>=0.1,<0.2]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25,<0.5]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25]) (push) Waiting to run
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Waiting to run
test / test-latest-version (>=0.8) (push) Waiting to run
test / test-latest-version (latest) (push) Waiting to run
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Waiting to run
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Waiting to run
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Waiting to run
test / test-version-file-version (map[expected-version:0.6.17 version-file:__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt]) (push) Waiting to run
test / test-version-file-version (map[expected-version:0.8.3 version-file:__tests__/fixtures/uv-in-requirements-hash-txt-project/requirements.txt]) (push) Waiting to run
test / test-malformed-pyproject-file-fallback (push) Waiting to run
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Waiting to run
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Waiting to run
test / test-with-explicit-token (push) Waiting to run
test / test-uvx (push) Waiting to run
test / test-tool-install (macos-14) (push) Waiting to run
test / test-tool-install (macos-latest) (push) Waiting to run
test / test-tool-install (ubuntu-latest) (push) Waiting to run
test / test-tool-install (windows-latest) (push) Waiting to run
test / test-python-version (macos-latest) (push) Waiting to run
test / test-python-version (ubuntu-latest) (push) Waiting to run
test / test-python-version (windows-latest) (push) Waiting to run
test / test-activate-environment (macos-latest) (push) Waiting to run
test / test-activate-environment (ubuntu-latest) (push) Waiting to run
test / test-activate-environment (windows-latest) (push) Waiting to run
test / test-activate-environment-custom-path (macos-latest) (push) Waiting to run
test / test-activate-environment-custom-path (ubuntu-latest) (push) Waiting to run
test / test-activate-environment-custom-path (windows-latest) (push) Waiting to run
test / test-activate-environment-no-project (push) Waiting to run
test / test-debian-unstable (push) Waiting to run
test / test-musl (push) Waiting to run
test / test-cache-key-os-version (macos-14, macos-14) (push) Waiting to run
test / test-cache-key-os-version (macos-15, macos-15) (push) Waiting to run
test / test-cache-key-os-version (ubuntu-22.04, ubuntu-22.04) (push) Waiting to run
test / test-cache-key-os-version (ubuntu-24.04, ubuntu-24.04) (push) Waiting to run
test / test-cache-key-os-version (windows-2022, windows-2022) (push) Waiting to run
test / test-cache-key-os-version (windows-2025, windows-2025) (push) Waiting to run
test / test-setup-cache (auto, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (auto, windows-latest) (push) Waiting to run
test / test-setup-cache (false, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (false, windows-latest) (push) Waiting to run
test / test-setup-cache (true, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (true, windows-latest) (push) Waiting to run
test / test-restore-cache (auto, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (auto, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (false, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (false, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (true, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (true, windows-latest) (push) Blocked by required conditions
test / test-setup-cache-requirements-txt (push) Waiting to run
test / test-restore-cache-requirements-txt (push) Blocked by required conditions
test / test-setup-cache-dependency-glob (push) Waiting to run
test / test-restore-cache-dependency-glob (push) Blocked by required conditions
test / test-setup-cache-save-cache-false (push) Waiting to run
test / test-restore-cache-save-cache-false (push) Blocked by required conditions
test / test-setup-cache-restore-cache-false (push) Waiting to run
test / test-restore-cache-restore-cache-false (push) Blocked by required conditions
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Waiting to run
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Waiting to run
test / test-cache-local-cache-disabled (push) Waiting to run
test / test-cache-local-cache-disabled-but-explicit-path (push) Waiting to run
test / test-no-python-version (push) Waiting to run
test / test-custom-manifest-file (push) Waiting to run
test / test-absolute-path (push) Waiting to run
test / test-relative-path (push) Waiting to run
test / test-cache-prune-force (push) Waiting to run
test / test-cache-dir-from-file (push) Waiting to run
test / test-cache-python-missing-managed-install-dir (push) Waiting to run
test / test-cache-python-installs (push) Waiting to run
test / test-restore-python-installs (push) Blocked by required conditions
test / test-python-install-dir (map[expected-python-dir:/home/runner/work/_temp/uv-python-dir os:ubuntu-latest]) (push) Waiting to run
test / test-python-install-dir (map[expected-python-dir:D:\a\_temp\uv-python-dir os:windows-latest]) (push) Waiting to run
test / test-act (push) Waiting to run
test / validate-typings (push) Waiting to run
test / all-tests-passed (push) Blocked by required conditions

Closes: #854
This commit is contained in:
Kevin Stillhammer 2026-04-16 15:48:02 +02:00 committed by GitHub
parent 7dd591db95
commit b3e97d2ba1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 71 additions and 4 deletions

View file

@ -430,6 +430,49 @@ jobs:
PY
shell: bash
test-activate-environment-no-project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Create incompatible pyproject.toml
run: |
cat > pyproject.toml <<'EOF'
[project]
name = "test-no-project"
version = "0.1.0"
[dependency-groups]
dev = [
"-e file:///${PROJECT_ROOT}/projects/pkg",
]
EOF
shell: bash
- name: Install latest version with no-project
id: setup-uv
uses: ./
with:
python-version: 3.13.1t
activate-environment: true
no-project: true
- name: Verify packages can be installed
run: uv pip install pip
shell: bash
- name: Verify output venv is set
run: |
if [ -z "$UV_VENV" ]; then
echo "output venv is not set"
exit 1
fi
if [ ! -d "$UV_VENV" ]; then
echo "output venv not point to a directory: $UV_VENV"
exit 1
fi
shell: bash
env:
UV_VENV: ${{ steps.setup-uv.outputs.venv }}
test-debian-unstable:
runs-on: ubuntu-latest
container: debian:unstable
@ -1057,6 +1100,7 @@ jobs:
- test-python-version
- test-activate-environment
- test-activate-environment-custom-path
- test-activate-environment-no-project
- test-debian-unstable
- test-musl
- test-cache-key-os-version

View file

@ -62,6 +62,9 @@ Have a look under [Advanced Configuration](#advanced-configuration) for detailed
# Custom path for the virtual environment when using activate-environment (default: .venv in the working directory)
venv-path: ""
# Pass --no-project when creating the venv with activate-environment.
no-project: "false"
# The directory to execute all commands in and look for files such as pyproject.toml
working-directory: ""

View file

@ -11,6 +11,8 @@ inputs:
type: boolean
venv-path:
type: string
no-project:
type: boolean
working-directory:
type: string
checksum:

View file

@ -18,6 +18,9 @@ inputs:
venv-path:
description: "Custom path for the virtual environment when using activate-environment. Defaults to '.venv' in the working directory."
default: ""
no-project:
description: "Pass --no-project when creating the venv with activate-environment."
default: "false"
working-directory:
description: "The directory to execute all commands in and look for files such as pyproject.toml"
default: ${{ github.workspace }}

2
dist/save-cache/index.cjs generated vendored
View file

@ -62968,6 +62968,7 @@ function loadInputs() {
const versionFile = getVersionFile(workingDirectory);
const pythonVersion = getInput("python-version");
const activateEnvironment = getBooleanInput("activate-environment");
const noProject = getBooleanInput("no-project");
const venvPath = getVenvPath(workingDirectory, activateEnvironment);
const checksum = getInput("checksum");
const enableCache = getEnableCache();
@ -63004,6 +63005,7 @@ function loadInputs() {
ignoreEmptyWorkdir,
ignoreNothingToCache,
manifestFile,
noProject,
pruneCache: pruneCache2,
pythonDir,
pythonVersion,

10
dist/setup/index.cjs generated vendored
View file

@ -96970,6 +96970,7 @@ function loadInputs() {
const versionFile = getVersionFile(workingDirectory);
const pythonVersion = getInput("python-version");
const activateEnvironment2 = getBooleanInput("activate-environment");
const noProject = getBooleanInput("no-project");
const venvPath = getVenvPath(workingDirectory, activateEnvironment2);
const checksum = getInput("checksum");
const enableCache = getEnableCache();
@ -97006,6 +97007,7 @@ function loadInputs() {
ignoreEmptyWorkdir,
ignoreNothingToCache,
manifestFile,
noProject,
pruneCache,
pythonDir,
pythonVersion,
@ -97385,13 +97387,17 @@ async function activateEnvironment(inputs) {
);
}
info(`Creating and activating python venv at ${inputs.venvPath}...`);
await exec("uv", [
const venvArgs = [
"venv",
inputs.venvPath,
"--directory",
inputs.workingDirectory,
"--clear"
]);
];
if (inputs.noProject) {
venvArgs.push("--no-project");
}
await exec("uv", venvArgs);
let venvBinPath = `${inputs.venvPath}${path16.sep}bin`;
if (process.platform === "win32") {
venvBinPath = `${inputs.venvPath}${path16.sep}Scripts`;

View file

@ -218,13 +218,17 @@ async function activateEnvironment(inputs: SetupInputs): Promise<void> {
}
core.info(`Creating and activating python venv at ${inputs.venvPath}...`);
await exec.exec("uv", [
const venvArgs = [
"venv",
inputs.venvPath,
"--directory",
inputs.workingDirectory,
"--clear",
]);
];
if (inputs.noProject) {
venvArgs.push("--no-project");
}
await exec.exec("uv", venvArgs);
let venvBinPath = `${inputs.venvPath}${path.sep}bin`;
if (process.platform === "win32") {

View file

@ -22,6 +22,7 @@ export interface SetupInputs {
versionFile: string;
pythonVersion: string;
activateEnvironment: boolean;
noProject: boolean;
venvPath: string;
checksum: string;
enableCache: boolean;
@ -49,6 +50,7 @@ export function loadInputs(): SetupInputs {
const versionFile = getVersionFile(workingDirectory);
const pythonVersion = core.getInput("python-version");
const activateEnvironment = core.getBooleanInput("activate-environment");
const noProject = core.getBooleanInput("no-project");
const venvPath = getVenvPath(workingDirectory, activateEnvironment);
const checksum = core.getInput("checksum");
const enableCache = getEnableCache();
@ -87,6 +89,7 @@ export function loadInputs(): SetupInputs {
ignoreEmptyWorkdir,
ignoreNothingToCache,
manifestFile,
noProject,
pruneCache,
pythonDir,
pythonVersion,