mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-04-17 02:06:29 +00:00
Add input no-project in combination with activate-environment (#856)
Closes: #854
This commit is contained in:
committed by
GitHub
parent
7dd591db95
commit
b3e97d2ba1
44
.github/workflows/test.yml
vendored
44
.github/workflows/test.yml
vendored
@@ -430,6 +430,49 @@ jobs:
|
|||||||
PY
|
PY
|
||||||
shell: bash
|
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:
|
test-debian-unstable:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: debian:unstable
|
container: debian:unstable
|
||||||
@@ -1057,6 +1100,7 @@ jobs:
|
|||||||
- test-python-version
|
- test-python-version
|
||||||
- test-activate-environment
|
- test-activate-environment
|
||||||
- test-activate-environment-custom-path
|
- test-activate-environment-custom-path
|
||||||
|
- test-activate-environment-no-project
|
||||||
- test-debian-unstable
|
- test-debian-unstable
|
||||||
- test-musl
|
- test-musl
|
||||||
- test-cache-key-os-version
|
- test-cache-key-os-version
|
||||||
|
|||||||
@@ -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)
|
# Custom path for the virtual environment when using activate-environment (default: .venv in the working directory)
|
||||||
venv-path: ""
|
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
|
# The directory to execute all commands in and look for files such as pyproject.toml
|
||||||
working-directory: ""
|
working-directory: ""
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ inputs:
|
|||||||
type: boolean
|
type: boolean
|
||||||
venv-path:
|
venv-path:
|
||||||
type: string
|
type: string
|
||||||
|
no-project:
|
||||||
|
type: boolean
|
||||||
working-directory:
|
working-directory:
|
||||||
type: string
|
type: string
|
||||||
checksum:
|
checksum:
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ inputs:
|
|||||||
venv-path:
|
venv-path:
|
||||||
description: "Custom path for the virtual environment when using activate-environment. Defaults to '.venv' in the working directory."
|
description: "Custom path for the virtual environment when using activate-environment. Defaults to '.venv' in the working directory."
|
||||||
default: ""
|
default: ""
|
||||||
|
no-project:
|
||||||
|
description: "Pass --no-project when creating the venv with activate-environment."
|
||||||
|
default: "false"
|
||||||
working-directory:
|
working-directory:
|
||||||
description: "The directory to execute all commands in and look for files such as pyproject.toml"
|
description: "The directory to execute all commands in and look for files such as pyproject.toml"
|
||||||
default: ${{ github.workspace }}
|
default: ${{ github.workspace }}
|
||||||
|
|||||||
2
dist/save-cache/index.cjs
generated
vendored
2
dist/save-cache/index.cjs
generated
vendored
@@ -62968,6 +62968,7 @@ function loadInputs() {
|
|||||||
const versionFile = getVersionFile(workingDirectory);
|
const versionFile = getVersionFile(workingDirectory);
|
||||||
const pythonVersion = getInput("python-version");
|
const pythonVersion = getInput("python-version");
|
||||||
const activateEnvironment = getBooleanInput("activate-environment");
|
const activateEnvironment = getBooleanInput("activate-environment");
|
||||||
|
const noProject = getBooleanInput("no-project");
|
||||||
const venvPath = getVenvPath(workingDirectory, activateEnvironment);
|
const venvPath = getVenvPath(workingDirectory, activateEnvironment);
|
||||||
const checksum = getInput("checksum");
|
const checksum = getInput("checksum");
|
||||||
const enableCache = getEnableCache();
|
const enableCache = getEnableCache();
|
||||||
@@ -63004,6 +63005,7 @@ function loadInputs() {
|
|||||||
ignoreEmptyWorkdir,
|
ignoreEmptyWorkdir,
|
||||||
ignoreNothingToCache,
|
ignoreNothingToCache,
|
||||||
manifestFile,
|
manifestFile,
|
||||||
|
noProject,
|
||||||
pruneCache: pruneCache2,
|
pruneCache: pruneCache2,
|
||||||
pythonDir,
|
pythonDir,
|
||||||
pythonVersion,
|
pythonVersion,
|
||||||
|
|||||||
10
dist/setup/index.cjs
generated
vendored
10
dist/setup/index.cjs
generated
vendored
@@ -96970,6 +96970,7 @@ function loadInputs() {
|
|||||||
const versionFile = getVersionFile(workingDirectory);
|
const versionFile = getVersionFile(workingDirectory);
|
||||||
const pythonVersion = getInput("python-version");
|
const pythonVersion = getInput("python-version");
|
||||||
const activateEnvironment2 = getBooleanInput("activate-environment");
|
const activateEnvironment2 = getBooleanInput("activate-environment");
|
||||||
|
const noProject = getBooleanInput("no-project");
|
||||||
const venvPath = getVenvPath(workingDirectory, activateEnvironment2);
|
const venvPath = getVenvPath(workingDirectory, activateEnvironment2);
|
||||||
const checksum = getInput("checksum");
|
const checksum = getInput("checksum");
|
||||||
const enableCache = getEnableCache();
|
const enableCache = getEnableCache();
|
||||||
@@ -97006,6 +97007,7 @@ function loadInputs() {
|
|||||||
ignoreEmptyWorkdir,
|
ignoreEmptyWorkdir,
|
||||||
ignoreNothingToCache,
|
ignoreNothingToCache,
|
||||||
manifestFile,
|
manifestFile,
|
||||||
|
noProject,
|
||||||
pruneCache,
|
pruneCache,
|
||||||
pythonDir,
|
pythonDir,
|
||||||
pythonVersion,
|
pythonVersion,
|
||||||
@@ -97385,13 +97387,17 @@ async function activateEnvironment(inputs) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
info(`Creating and activating python venv at ${inputs.venvPath}...`);
|
info(`Creating and activating python venv at ${inputs.venvPath}...`);
|
||||||
await exec("uv", [
|
const venvArgs = [
|
||||||
"venv",
|
"venv",
|
||||||
inputs.venvPath,
|
inputs.venvPath,
|
||||||
"--directory",
|
"--directory",
|
||||||
inputs.workingDirectory,
|
inputs.workingDirectory,
|
||||||
"--clear"
|
"--clear"
|
||||||
]);
|
];
|
||||||
|
if (inputs.noProject) {
|
||||||
|
venvArgs.push("--no-project");
|
||||||
|
}
|
||||||
|
await exec("uv", venvArgs);
|
||||||
let venvBinPath = `${inputs.venvPath}${path16.sep}bin`;
|
let venvBinPath = `${inputs.venvPath}${path16.sep}bin`;
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
venvBinPath = `${inputs.venvPath}${path16.sep}Scripts`;
|
venvBinPath = `${inputs.venvPath}${path16.sep}Scripts`;
|
||||||
|
|||||||
@@ -218,13 +218,17 @@ async function activateEnvironment(inputs: SetupInputs): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Creating and activating python venv at ${inputs.venvPath}...`);
|
core.info(`Creating and activating python venv at ${inputs.venvPath}...`);
|
||||||
await exec.exec("uv", [
|
const venvArgs = [
|
||||||
"venv",
|
"venv",
|
||||||
inputs.venvPath,
|
inputs.venvPath,
|
||||||
"--directory",
|
"--directory",
|
||||||
inputs.workingDirectory,
|
inputs.workingDirectory,
|
||||||
"--clear",
|
"--clear",
|
||||||
]);
|
];
|
||||||
|
if (inputs.noProject) {
|
||||||
|
venvArgs.push("--no-project");
|
||||||
|
}
|
||||||
|
await exec.exec("uv", venvArgs);
|
||||||
|
|
||||||
let venvBinPath = `${inputs.venvPath}${path.sep}bin`;
|
let venvBinPath = `${inputs.venvPath}${path.sep}bin`;
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export interface SetupInputs {
|
|||||||
versionFile: string;
|
versionFile: string;
|
||||||
pythonVersion: string;
|
pythonVersion: string;
|
||||||
activateEnvironment: boolean;
|
activateEnvironment: boolean;
|
||||||
|
noProject: boolean;
|
||||||
venvPath: string;
|
venvPath: string;
|
||||||
checksum: string;
|
checksum: string;
|
||||||
enableCache: boolean;
|
enableCache: boolean;
|
||||||
@@ -49,6 +50,7 @@ export function loadInputs(): SetupInputs {
|
|||||||
const versionFile = getVersionFile(workingDirectory);
|
const versionFile = getVersionFile(workingDirectory);
|
||||||
const pythonVersion = core.getInput("python-version");
|
const pythonVersion = core.getInput("python-version");
|
||||||
const activateEnvironment = core.getBooleanInput("activate-environment");
|
const activateEnvironment = core.getBooleanInput("activate-environment");
|
||||||
|
const noProject = core.getBooleanInput("no-project");
|
||||||
const venvPath = getVenvPath(workingDirectory, activateEnvironment);
|
const venvPath = getVenvPath(workingDirectory, activateEnvironment);
|
||||||
const checksum = core.getInput("checksum");
|
const checksum = core.getInput("checksum");
|
||||||
const enableCache = getEnableCache();
|
const enableCache = getEnableCache();
|
||||||
@@ -87,6 +89,7 @@ export function loadInputs(): SetupInputs {
|
|||||||
ignoreEmptyWorkdir,
|
ignoreEmptyWorkdir,
|
||||||
ignoreNothingToCache,
|
ignoreNothingToCache,
|
||||||
manifestFile,
|
manifestFile,
|
||||||
|
noProject,
|
||||||
pruneCache,
|
pruneCache,
|
||||||
pythonDir,
|
pythonDir,
|
||||||
pythonVersion,
|
pythonVersion,
|
||||||
|
|||||||
Reference in New Issue
Block a user