Skip to content

Commit

Permalink
rename to no-editable
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Sep 17, 2024
1 parent db575a6 commit 9fe78de
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 27 deletions.
15 changes: 9 additions & 6 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2408,9 +2408,10 @@ pub struct RunArgs {
#[arg(long, conflicts_with("no_dev"))]
pub only_dev: bool,

/// Install the project and any local dependencies as non-editable.
/// Install any editable dependencies, including the project and any workspace members, as
/// non-editable.
#[arg(long)]
pub non_editable: bool,
pub no_editable: bool,

/// The command to run.
///
Expand Down Expand Up @@ -2564,9 +2565,10 @@ pub struct SyncArgs {
#[arg(long, conflicts_with("no_dev"))]
pub only_dev: bool,

/// Install the project and any local dependencies as non-editable.
/// Install any editable dependencies, including the project and any workspace members, as
/// non-editable.
#[arg(long)]
pub non_editable: bool,
pub no_editable: bool,

/// Do not remove extraneous packages present in the environment.
///
Expand Down Expand Up @@ -3010,9 +3012,10 @@ pub struct ExportArgs {
#[arg(long, conflicts_with("no_dev"))]
pub only_dev: bool,

/// Install the project and any local dependencies as non-editable.
/// Install any editable dependencies, including the project and any workspace members, as
/// non-editable.
#[arg(long)]
pub non_editable: bool,
pub no_editable: bool,

/// Include hashes for all dependencies.
#[arg(long, overrides_with("no_hashes"), hide = true)]
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-configuration/src/editable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub enum EditableMode {

impl EditableMode {
/// Determine the editable mode based on the command-line arguments.
pub fn from_args(non_editable: bool) -> Self {
if non_editable {
pub fn from_args(no_editable: bool) -> Self {
if no_editable {
Self::NonEditable
} else {
Self::Editable
Expand Down
12 changes: 6 additions & 6 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl RunSettings {
dev,
no_dev,
only_dev,
non_editable,
no_editable,
command: _,
with,
with_editable,
Expand All @@ -261,7 +261,7 @@ impl RunSettings {
extra.unwrap_or_default(),
),
dev: DevMode::from_args(dev, no_dev, only_dev),
editable: EditableMode::from_args(non_editable),
editable: EditableMode::from_args(no_editable),
with,
with_editable,
with_requirements: with_requirements
Expand Down Expand Up @@ -684,7 +684,7 @@ impl SyncSettings {
dev,
no_dev,
only_dev,
non_editable,
no_editable,
inexact,
exact,
no_install_project,
Expand Down Expand Up @@ -712,7 +712,7 @@ impl SyncSettings {
extra.unwrap_or_default(),
),
dev: DevMode::from_args(dev, no_dev, only_dev),
editable: EditableMode::from_args(non_editable),
editable: EditableMode::from_args(no_editable),
install_options: InstallOptions::new(
no_install_project,
no_install_workspace,
Expand Down Expand Up @@ -991,7 +991,7 @@ impl ExportSettings {
dev,
no_dev,
only_dev,
non_editable,
no_editable,
hashes,
no_hashes,
output_file,
Expand All @@ -1014,7 +1014,7 @@ impl ExportSettings {
extra.unwrap_or_default(),
),
dev: DevMode::from_args(dev, no_dev, only_dev),
editable: EditableMode::from_args(non_editable),
editable: EditableMode::from_args(no_editable),
hashes: flag(hashes, no_hashes).unwrap_or(true),
install_options: InstallOptions::new(
no_emit_project,
Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ fn no_emit() -> Result<()> {
}

#[test]
fn non_editable() -> Result<()> {
fn no_editable() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
Expand Down Expand Up @@ -948,12 +948,12 @@ fn non_editable() -> Result<()> {

context.lock().assert().success();

uv_snapshot!(context.filters(), context.export().arg("--non-editable"), @r###"
uv_snapshot!(context.filters(), context.export().arg("--no-editable"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv export --cache-dir [CACHE_DIR] --non-editable
# uv export --cache-dir [CACHE_DIR] --no-editable
.
./child
anyio==3.7.0 \
Expand Down
8 changes: 6 additions & 2 deletions crates/uv/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@ fn transitive_dev() -> Result<()> {

/// Avoid installing dev dependencies of transitive dependencies.
#[test]
fn sync_non_editable() -> Result<()> {
fn sync_no_editable() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
Expand All @@ -2405,11 +2405,14 @@ fn sync_non_editable() -> Result<()> {
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["child"]
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
[tool.uv.sources]
child = { workspace = true }
[tool.uv.workspace]
members = ["child"]
"#,
Expand All @@ -2431,6 +2434,7 @@ fn sync_non_editable() -> Result<()> {
name = "child"
version = "0.1.0"
requires-python = ">=3.12"
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
Expand All @@ -2443,7 +2447,7 @@ fn sync_non_editable() -> Result<()> {
let init = src.child("__init__.py");
init.touch()?;

uv_snapshot!(context.filters(), context.sync().arg("--non-editable"), @r###"
uv_snapshot!(context.filters(), context.sync().arg("--no-editable"), @r###"
success: true
exit_code: 0
----- stdout -----
Expand Down
10 changes: 8 additions & 2 deletions docs/concepts/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ project should be packaged and installed.
uv uses the presence of a build system to determine if a project contains a package that should be
installed in the project virtual environment. If a build system is not defined, uv will not attempt
to build or install the project itself, just its dependencies. If a build system is defined, uv will
build and install the project into the project environment. Projects are installed in
build and install the project into the project environment. By default, projects are installed in
[editable mode](https://setuptools.pypa.io/en/latest/userguide/development_mode.html) so changes to
the source code are reflected immediately, without reinstallation.
the source code are reflected immediately, without re-installation.

### Configuring project packaging

Expand Down Expand Up @@ -297,6 +297,12 @@ use [`uvx`](../guides/tools.md) or
managed = false
```

By default, the project will be installed in editable mode, such that changes to the source code are
immediately reflected in the environment. `uv sync` and `uv run` both accept a `--no-editable` flag,
which instructs uv to install the project in non-editable mode. `--no-editable` is intended for
deployment use-cases, such as building a Docker container, in which the project should be included
in the deployed environment without a dependency on the originating source code.

### Configuring the project environment path

The `UV_PROJECT_ENVIRONMENT` environment variable can be used to configure the project virtual
Expand Down
44 changes: 44 additions & 0 deletions docs/guides/integration/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,50 @@ _contents_ are not copied into the image until the final `uv sync` command.

If you want to remove specific packages from the sync, use `--no-install-package <name>`.

### Non-editable installs

By default, uv installs projects and workspace members in editable mode, such that changes to the
source code are immediately reflected in the environment.

`uv sync` and `uv run` both accept a `--no-editable` flag, which instructs uv to install the project
in non-editable mode, removing any dependency on the source code.

In the context of a multi-stage Docker image, `--no-editable` can be used to include the project in
the synced virtual environment from one stage, then copy the virtual environment alone (and not the
source code) into the final image.

For example:

```dockerfile title="Dockerfile"
# Install uv
FROM python:3.12-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

# Change the working directory to the `app` directory
WORKDIR /app

# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-editable

# Copy the project into the intermediate image
ADD . /app

# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable

FROM python:3.12-slim

# Copy the environment, but not the source code
COPY --from=builder --chown=app:app /app/.venv /app/.venv

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
```

### Using uv temporarily

If uv isn't needed in the final image, the binary can be mounted in each invocation:
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ uv run [OPTIONS] <COMMAND>

<p>This option is only available when running in a project.</p>

</dd><dt><code>--no-editable</code></dt><dd><p>Install any editable dependencies, including the project and any workspace members, as non-editable</p>

</dd><dt><code>--no-index</code></dt><dd><p>Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those provided via <code>--find-links</code></p>

</dd><dt><code>--no-progress</code></dt><dd><p>Hide all progress outputs.</p>
Expand All @@ -269,8 +271,6 @@ uv run [OPTIONS] <COMMAND>

<p>Implies <code>--frozen</code>, as the project dependencies will be ignored (i.e., the lockfile will not be updated, since the environment will not be synced regardless).</p>

</dd><dt><code>--non-editable</code></dt><dd><p>Install the project and any local dependencies as non-editable</p>

</dd><dt><code>--offline</code></dt><dd><p>Disable network access.</p>

<p>When disabled, uv will only use locally cached data and locally available files.</p>
Expand Down Expand Up @@ -1315,6 +1315,8 @@ uv sync [OPTIONS]
<p>May also be set with the <code>UV_NO_CONFIG</code> environment variable.</p>
</dd><dt><code>--no-dev</code></dt><dd><p>Omit development dependencies</p>

</dd><dt><code>--no-editable</code></dt><dd><p>Install any editable dependencies, including the project and any workspace members, as non-editable</p>

</dd><dt><code>--no-index</code></dt><dd><p>Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those provided via <code>--find-links</code></p>

</dd><dt><code>--no-install-package</code> <i>no-install-package</i></dt><dd><p>Do not install the given package(s).</p>
Expand All @@ -1337,8 +1339,6 @@ uv sync [OPTIONS]

</dd><dt><code>--no-sources</code></dt><dd><p>Ignore the <code>tool.uv.sources</code> table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources</p>

</dd><dt><code>--non-editable</code></dt><dd><p>Install the project and any local dependencies as non-editable</p>

</dd><dt><code>--offline</code></dt><dd><p>Disable network access.</p>

<p>When disabled, uv will only use locally cached data and locally available files.</p>
Expand Down Expand Up @@ -1873,6 +1873,8 @@ uv export [OPTIONS]
<p>May also be set with the <code>UV_NO_CONFIG</code> environment variable.</p>
</dd><dt><code>--no-dev</code></dt><dd><p>Omit development dependencies</p>

</dd><dt><code>--no-editable</code></dt><dd><p>Install any editable dependencies, including the project and any workspace members, as non-editable</p>

</dd><dt><code>--no-emit-package</code> <i>no-emit-package</i></dt><dd><p>Do not emit the given package(s).</p>

<p>By default, all of the project&#8217;s dependencies are included in the exported requirements file. The <code>--no-install-package</code> option allows exclusion of specific packages.</p>
Expand All @@ -1897,8 +1899,6 @@ uv export [OPTIONS]

</dd><dt><code>--no-sources</code></dt><dd><p>Ignore the <code>tool.uv.sources</code> table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources</p>

</dd><dt><code>--non-editable</code></dt><dd><p>Install the project and any local dependencies as non-editable</p>

</dd><dt><code>--offline</code></dt><dd><p>Disable network access.</p>

<p>When disabled, uv will only use locally cached data and locally available files.</p>
Expand Down

0 comments on commit 9fe78de

Please sign in to comment.