Commit graph

4903 commits

Author SHA1 Message Date
Charlie Marsh
a7850d2a1c
Use separate types to represent raw vs. resolver markers (#6646)
## Summary

This is similar to https://github.com/astral-sh/uv/pull/6171 but more
expansive... _Anywhere_ that we test requirements for platform
compatibility, we _need_ to respect the resolver-friendly markers. In
fixing the motivating issue (#6621), I also realized that we had a bunch
of bugs here around `pip install` with `--python-platform` and
`--python-version`, because we always performed our `satisfy` and `Plan`
operations on the interpreter's markers, not the adjusted markers!

Closes https://github.com/astral-sh/uv/issues/6621.
2024-08-26 18:00:21 +00:00
Shantanu
6220532373
Test for .venv symlink (#6597)
For various reasons, I have a preference for out of tree virtual
environments. Things just work if I symlink, but I don't know that this
is guaranteed, so I thought I'd add a test for it. It looks like there's
another code path that matters (`FoundInterpreter::discover ->
PythonEnvironment::from_root`) for the higher level commands, but
couldn't spot a good place to test that.

Related discussion:
https://github.com/astral-sh/uv/issues/1495#issuecomment-1950442191 /
https://github.com/astral-sh/uv/issues/1578#issuecomment-1949911871
2024-08-26 11:44:19 -05:00
Tim de Jager
50997bcb41
Allow per dependency build isolation for setup.py projects as well (#6517)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

This changes the behavior a bit of the per-dependency build-isolation
override. That, if the dist name is known, it is passed into the
`SourceBuild::Setup` function. This allows for this override to work for
projects without a `pyproject.toml`, like `detectron2`, using the
specified requirement name. Previously only the `pyproject.toml` name
could be used, which these projects are lacking. An example of a
use-case is given in the *Test Plan* section.

Additionally, the `no_build_isolation_package` has been adding to
`InstallerSettingsRef` and used in `sync` and other commands, as this
was not done yet.

This is useful if you want to **non**-isolate a single package, even
ones without a proper `pyproject.toml`


## Test Plan

<!-- How was it tested? -->

With the following pyproject.toml.

```toml
[project]
name = "detectron-uv"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "detectron2",
    "setuptools",
    "torch",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv.sources]
detectron2 = { git = "https://github.com/facebookresearch/detectron2", rev = "bcfd464d0c810f0442d91a349c0f6df945467143" }

[tool.uv]
no-build-isolation-package = ["detectron2"]
```

The package `detectron2` is now correctly **non**-isolated. Before,
because the logic depended on getting the name from the
`pyproject.toml`, which is lacking in detectron2 you would get the
message, that the source could not be built. This was because it would
still be *isolated* in that case.

With these changes you can now install using (given that you are inside
a workspace with a venv):

```
uv pip install torch setuptools
uv sync
```

This would previously fail with something like:

```
error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: detectron2 @ git+https://github.com/facebookresearch/detectron2@bcfd464d0c810f0442d91a349c0f6df945467143
  Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/Users/tdejager/Library/Caches/uv/builds-v0/.tmptloDcZ/lib/python3.12/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tdejager/Library/Caches/uv/builds-v0/.tmptloDcZ/lib/python3.12/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
    self.run_setup()
  File "/Users/tdejager/Library/Caches/uv/builds-v0/.tmptloDcZ/lib/python3.12/site-packages/setuptools/build_meta.py", line 502, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/Users/tdejager/Library/Caches/uv/builds-v0/.tmptloDcZ/lib/python3.12/site-packages/setuptools/build_meta.py", line 318, in run_setup
    exec(code, locals())
  File "<string>", line 10, in <module>
ModuleNotFoundError: No module named 'torch'
---
  Caused by: This error likely indicates that detectron2 @ git+https://github.com/facebookresearch/detectron2@bcfd464d0c810f0442d91a349c0f6df945467143 depends on torch, but doesn't declare it as a build dependency. If detectron2 @ git+https://github.com/facebookresearch/detectron2@bcfd464d0c810f0442d91a349c0f6df945467143 is a first-party package, consider adding torch to its `build-system.requires`. Otherwise, `uv pip install torch` into the environment and re-run with `--no-build-isolation`.
  ```

**Edit**:

Some wording, used isolated where it should be **non**-isolated.
2024-08-26 16:41:27 +02:00
renovate[bot]
b68406bb56
Update tj-actions/changed-files action to v45 (#6632) 2024-08-25 22:12:03 -04:00
Charlie Marsh
ee254a8230
Use serde(transparent) for UrlString (#6633) 2024-08-25 22:11:55 -04:00
Charlie Marsh
2ec7c69861
Respect extras and markers on virtual dev dependencies (#6620)
## Summary

Closes https://github.com/astral-sh/uv/issues/6617.
2024-08-26 00:31:42 +00:00
renovate[bot]
4cba45157e
Update pre-commit dependencies (#6631) 2024-08-26 00:26:00 +00:00
renovate[bot]
a25f800aae
Update Rust crate syn to v2.0.76 (#6630) 2024-08-26 00:23:27 +00:00
renovate[bot]
f8b8aa72ce
Update Rust crate serde_json to v1.0.127 (#6629) 2024-08-26 00:21:22 +00:00
renovate[bot]
8de12fd42e
Update Rust crate serde to v1.0.209 (#6628) 2024-08-26 00:21:07 +00:00
renovate[bot]
d98d28a8ca
Update Rust crate rkyv to v0.7.45 (#6627) 2024-08-26 00:20:17 +00:00
renovate[bot]
413cf00a0c
Update Rust crate reqwest to v0.12.7 (#6626) 2024-08-26 00:15:15 +00:00
renovate[bot]
768840da49
Update Rust crate quote to v1.0.37 (#6625) 2024-08-26 00:14:55 +00:00
renovate[bot]
faf534f997
Update Rust crate jiff to v0.1.10 (#6624) 2024-08-26 00:12:26 +00:00
renovate[bot]
e4e1f384ce
Update Rust crate flate2 to v1.0.33 (#6623) 2024-08-25 20:12:14 -04:00
Charlie Marsh
a72a09e9af
Use tl fork to support unquoted hrefs (#6622)
## Summary

Closes https://github.com/astral-sh/uv/issues/6082.
2024-08-26 00:02:26 +00:00
Jp
2bfc450418
Parses wheels WHEEL and METADATA files content as email messages (#6616)
## Summary

Fixes: #6615 
Currently, some packages are not installable with `uv`, like `ziglang`
on Linux.
Everything is described in the issue! 😄 

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
I added a unit test for the problematic use case.
I also checked that previous unit test are still running in order to
ensure the backward compatibility.
2024-08-25 18:31:07 -04:00
Charlie Marsh
069b021e0f
Update lockfile after setting minimum bounds in uv add (#6618)
## Summary

If we update the project requirements, we _also_ need to update the
lockfile.

Closes https://github.com/astral-sh/uv/issues/6614.
2024-08-25 21:04:25 +00:00
Charlie Marsh
1c580723c5
Support PEP 723 scripts in GUI files (#6611)
## Summary

Just an oversight.
2024-08-25 16:08:52 +00:00
Charlie Marsh
5076f325cd
Add --refresh to tool run warning for --with dependencies (#6609)
## Summary

Closes https://github.com/astral-sh/uv/issues/6576.
2024-08-25 11:15:41 -04:00
Charlie Marsh
5b3e654dc9
Show --editable on the uv add CLI (#6608)
## Summary

`false` is the default, so like other booleans, we should show the
non-default.
2024-08-25 15:01:39 +00:00
Charlie Marsh
d0198abc10
Respect --no-build-isolation-package in uv sync (#6605)
## Summary

This was an oversight. The existing test was (correctly) failing, but
for the wrong reason (failing to build the package during _resolution_).
2024-08-25 14:15:13 +00:00
Charlie Marsh
4cbec958e1
Add FastAPI guide to overview (#6603) 2024-08-25 13:11:10 +00:00
Charlie Marsh
0dc74f619c
Remove path-absolutize dependency (#6589)
## Summary

This is now in the standard library.
2024-08-25 12:01:07 +00:00
Charlie Marsh
7fa265a11b
Use relative paths for --find-links and local registries (#6566)
## Summary

See: https://github.com/astral-sh/uv/issues/6458
2024-08-25 02:41:47 +00:00
Charlie Marsh
3902bb498d
Fix lock_requires_python fixture (#6594) 2024-08-24 18:45:03 -04:00
Charlie Marsh
31019ff140
Use logger interface for remaining audit messages (#6586) 2024-08-24 16:46:41 +00:00
Charlie Marsh
1fc45db082
Fix flaky HTTP redact test (#6583) 2024-08-24 13:49:29 +00:00
Charlie Marsh
8ee53a9e38
Clarify need to include pyproject.toml with --no-install-project (#6581)
## Summary

See: https://github.com/astral-sh/uv/issues/6573
2024-08-24 09:45:23 -04:00
Charlie Marsh
1eb97c91fd
Remove FileLocation::Path variant (#6577)
## Summary

This is redundant now that we support `file://` URLs.
2024-08-24 07:52:43 -04:00
Zanie Blue
2f94422484
Fix basic authentication tests to reflect proxy changes (#6569)
Updates the snapshot for the deployment from
https://github.com/astral-sh/pypi-proxy/pull/9 — for a while now, we've
only been failing on file requests not registry requests because the
proxy auth was setup wrong.
2024-08-24 05:59:14 +00:00
skykasko
8ca64de67e
Add example of reading script from stdin using echo (#6567)
As a non-shell-wizard, I was unfamiliar with the `EOF` syntax used in
the existing example (just above the one I added). I thought including
an example where the output of `echo` is piped to `uv run` might be more
accessible. As a bonus, it should work across more shells: the `EOF`
example doesn't work in fish because fish [doesn't support
heredocs](https://fishshell.com/docs/current/fish_for_bash_users.html#heredocs),
while the `echo` example does.

Feel free to ignore if unwanted.
2024-08-24 00:03:59 -05:00
Charlie Marsh
f7835243c5
Only use relative paths in lockfile (#6490)
For users who were using absolute paths in the `pyproject.toml`
previously, this is a behavior change: We now convert all absolute paths
in `path` entries to relative paths. Since i assume that no-one relies
on absolute path in their lockfiles - they are intended to be portable -
I'm tagging this as a bugfix.

Closes https://github.com/astral-sh/uv/pull/6438
Fixes https://github.com/astral-sh/uv/issues/6371
2024-08-23 22:19:10 -04:00
Charlie Marsh
611a9003c9
Don't canonicalize paths to user requirements (#6560) 2024-08-24 02:02:14 +00:00
Charlie Marsh
44e36a7e69
Store test temporary directories outside of /tmp (#6559)
## Summary

There's a long comment inline describing the motivation here.
2024-08-24 01:51:32 +00:00
samypr100
a959772074
feat: use multi-runner on docker publish (#6556)
## Summary

This PR parallelizes multi-platform builds using multiple workers (hence
the new docker-build / docker-publish jobs), this seems to save about ~8
minutes.

This is partial work extracted from
https://github.com/astral-sh/uv/pull/6053 than is standalone
2024-08-23 18:50:46 -05:00
Zanie Blue
deea6025a1
Bump version to 0.3.3 (#6558) 2024-08-23 18:35:55 -05:00
Charlie Marsh
3edf219882
Ignore errors in workspace discovery with --no-project (#6554)
## Summary

Closes https://github.com/astral-sh/uv/issues/6550.
2024-08-23 18:04:38 -05:00
Zanie Blue
c46ef0c68d
Update transformers test case (#6557)
cc @BurntSushi I'm not sure why this changed
1053333613/attempts/1
2024-08-23 18:04:27 -05:00
Zanie Blue
f9348a6ea3
Run tests when docs/reference generated files change (#6551)
Short-term fix for https://github.com/astral-sh/uv/issues/6352
2024-08-23 17:35:53 -05:00
Zeyad Moustafa
2419760356
docs: made uvx note more explict (#6546)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

I used `uvx` to test my code using `pytest` it was just before the
documentation and it worked pretty fine. But when I saw the docs I was
confused as it says:

> If you are running a tool in a project and the tool requires that your
project is installed, e.g., when using `pytest` or `mypy`, you'll want
to use `uv` run instead of `uvx`. Otherwise, the tool will be run in a
virtual environment that is isolated from your project.

So to make it simple if you don't recommend using `uvx` in this
situation then here is the pull request, and if not just close this pull
request. I said that I don't have to open an issue to discuss this as
it's so simple.

## Test Plan

None

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-23 17:17:37 -05:00
Charlie Marsh
b149cbe634
Remove --preview from tests (#6536)
Closes https://github.com/astral-sh/uv/issues/6532.
2024-08-23 18:12:07 -04:00
Zanie Blue
60fc2e7234
Add uv tool install example in Docker (#6547) 2024-08-23 17:09:15 -05:00
Zanie Blue
6cf5d13183
Include virtual environment interpreters in uv python find (#6521)
Previously, we excluded these and only looked at system interpreters.
However, it makes sense for this to match the typical Python discovery
experience. We could consider swapping the default... I'm not sure what
makes more sense. If we change the default (as written now) — this could
arguably be a breaking change.
2024-08-23 21:06:57 +00:00
Zanie Blue
d1cbcb30e3
Add uv sync --no-install-package to skip installation of specific packages (#6540)
Extends #6538 / #6539
See #4028

Allows excluding arbitrary packages from the sync.
2024-08-23 20:48:04 +00:00
Zanie Blue
ca50243174
Add uv sync --no-install-workspace to skip installation of all workspace members (#6539)
Extends #6538
See #4028

Another version of https://github.com/astral-sh/uv/pull/6398
2024-08-23 20:39:33 +00:00
konsti
4e82db093a
Document why we do lower bounds (#6516)
Document in the resolution concept documentation why we add lower bounds

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-23 20:28:39 +00:00
Zanie Blue
be1599ebf6
Add uv sync --no-install-project to skip installation of the project (#6538)
See #4028

A smaller version of https://github.com/astral-sh/uv/pull/6398

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-08-23 20:19:47 +00:00
Zanie Blue
e0abab8259
Add documentation for uv python find (#6527)
In part, for https://github.com/astral-sh/uv/pull/6521
2024-08-23 15:14:52 -05:00
Zanie Blue
80b5384a4d
Set VIRTUAL_ENV for uv run invocations (#6543)
If we don't do this, and `uv run` invokes something like `uv run
--isolated uv pip install foo` uv won't mutate the isolated environment,
it'll mutate whatever outer environment it finds.
2024-08-23 20:03:38 +00:00