From 4b61e65d6cf252bcec81164a6672685be3992a0b Mon Sep 17 00:00:00 2001
From: Blair Allan <72862871+BlairAllan@users.noreply.github.com>
Date: Sun, 2 Nov 2025 20:25:19 +0000
Subject: [PATCH] Add `UV_NO_SOURCES` as an environment variable (#15883)
## Summary
This is an enhancement that makes the cli flag `--no-sources` an
environment variable - "UV_NO_SOURCES"
Why is this a relevant change?
When working across different environments, in our case remote vs local,
we often have our packages hosted in a artifact registry but when
developing locally we build our packages from github. This results in us
using the uv.tool.sources table quite a bit however this then also
forces us to use `--no-sources` for all our remote work.
This change enables us to set an environment variable once and to never
have to type --no-sources after every uv run command again.
## Test Plan
Expanded on the current --no-sources tests, to test when
UV_NO_SOURCES=true/false the behaviour is the same as the flag.
Additionally ensured that the cli overrides the env variable.
---------
Co-authored-by: Charlie Marsh If a virtual environment is active or found in a current or parent directory, it will be used as if there was no project or workspace. Disable automatic downloads of Python. Ignore the Avoid syncing the virtual environment. May also be set with the Avoid syncing the virtual environment. Implies May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Avoid syncing the virtual environment May also be set with the Avoid syncing the virtual environment May also be set with the Don't add the dependency as a workspace member. By default, when adding a dependency that's a local path and is within the workspace directory, uv will add it as a workspace member; pass Disable network access. For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Avoid syncing the virtual environment after re-locking the project May also be set with the Avoid syncing the virtual environment after re-locking the project May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the Remove the packages from the project's optional dependencies for the specified extra For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Avoid syncing the virtual environment after re-locking the project May also be set with the Avoid syncing the virtual environment after re-locking the project May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the The format of the output For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the Only include the development dependency group. The project and its dependencies will be omitted. For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the The strategy to use when considering pre-release versions. By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers ( For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the Only include the development dependency group. The project and its dependencies will be omitted. For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the Only include the development dependency group. The project and its dependencies will be omitted. For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the Override versions using the given requirements files. Overrides files are For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the Override versions using the given requirements files. Overrides files are For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable network access. May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files. May also be set with the The strategy to use when considering pre-release versions. By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers ( For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Include extras in the output file. May also be set with the Include extras in the output file. By default, uv strips extras, as any packages pulled in by the extras are already included as dependencies in the output file directly. Further, output files generated with Include environment markers in the output file. By default, uv strips environment markers, as the resolution generated by For example, spinners or progress bars. May also be set with the Disable automatic downloads of Python. Ignore the Disable validation of hashes in the requirements file. May also be set with the Disable validation of hashes in the requirements file. By default, uv will verify any available hashes in the requirements file, but will not require that all requirements have an associated hash. To enforce hash validation, use May also be set with the Disable network access. When disabled, uv will only use locally cached data and locally available files.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--no-syncUV_NO_SOURCES environment variable.--no-sync--frozen, as the project dependencies will be ignored (i.e., the lockfile will not be updated, since the environment will not be synced regardless).UV_NO_SYNC environment variable.--offlineUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--no-syncUV_NO_SOURCES environment variable.--no-syncUV_NO_SYNC environment variable.--no-workspace--no-workspace to add the package as direct path dependency instead.--offlineUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--no-syncUV_NO_SOURCES environment variable.--no-syncUV_NO_SYNC environment variable.--offlineUV_OFFLINE environment variable.--optional optionalUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--no-syncUV_NO_SOURCES environment variable.--no-syncUV_NO_SYNC environment variable.--offlineUV_OFFLINE environment variable.--output-format output-formatUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--only-devUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--prerelease prereleaseif-necessary-or-explicit).UV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--only-devUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--only-devUV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--overrides, --override overridesrequirements.txt-like files that force a specific version of a requirement to be installed, regardless of the requirements declared by any constituent package, and regardless of whether this would be considered an invalid resolution.UV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--overrides, --override overridesrequirements.txt-like files that force a specific version of a requirement to be installed, regardless of the requirements declared by any constituent package, and regardless of whether this would be considered an invalid resolution.UV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--offlineUV_NO_SOURCES environment variable.--offlineUV_OFFLINE environment variable.--prerelease prereleaseif-necessary-or-explicit).UV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--no-strip-extrasUV_NO_SOURCES environment variable.--no-strip-extras--no-strip-extras cannot be used as constraints files in install and sync invocations.--no-strip-markerscompile is only guaranteed to be correct for the target environment.UV_NO_PROGRESS environment variable.--no-python-downloads--no-sourcestool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources--no-verify-hashesUV_NO_SOURCES environment variable.--no-verify-hashes--require-hashes.UV_NO_VERIFY_HASHES environment variable.--offline
May also be set with the UV_NO_PROGRESS environment variable.
--no-python-downloadsDisable automatic downloads of Python.
--no-sourcesIgnore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources
--no-verify-hashesDisable validation of hashes in the requirements file.
+May also be set with the UV_NO_SOURCES environment variable.
--no-verify-hashesDisable validation of hashes in the requirements file.
By default, uv will verify any available hashes in the requirements file, but will not require that all requirements have an associated hash. To enforce hash validation, use --require-hashes.
May also be set with the UV_NO_VERIFY_HASHES environment variable.
--offlineDisable network access.
When disabled, uv will only use locally cached data and locally available files.
@@ -5745,7 +5745,7 @@ uv build [OPTIONS] [SRC]For example, spinners or progress bars.
May also be set with the UV_NO_PROGRESS environment variable.
--no-python-downloadsDisable automatic downloads of Python.
--no-sourcesIgnore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any workspace, Git, URL, or local path sources
--no-verify-hashesDisable validation of hashes in the requirements file.
+May also be set with the UV_NO_SOURCES environment variable.
--no-verify-hashesDisable validation of hashes in the requirements file.
By default, uv will verify any available hashes in the requirements file, but will not require that all requirements have an associated hash. To enforce hash validation, use --require-hashes.
May also be set with the UV_NO_VERIFY_HASHES environment variable.
--offlineDisable network access.
When disabled, uv will only use locally cached data and locally available files.
diff --git a/docs/reference/environment.md b/docs/reference/environment.md index a0ff012c8..5c0711549 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -386,6 +386,12 @@ alias, for backwards compatibility. Equivalent to the `--no-progress` command-line argument. Disables all progress output. For example, spinners and progress bars. +### `UV_NO_SOURCES` +added in `0.9.8` + +Equivalent to the `--no-sources` command-line argument. If set, uv will ignore +`[tool.uv.sources]` annotations when resolving dependencies. + ### `UV_NO_SYNC` added in `0.4.18`