Commit graph

76 commits

Author SHA1 Message Date
Silvano Cerza
0b106908aa
Add job to test PyPy venv creation on Windows (#5079)
## Summary

This PR adds a new job to test that PyPy venvs are correctly created on
Windows and they contain all the expected binaries.

## Test Plan

Just let CI run.
2024-07-15 16:20:19 -05:00
Silvano Cerza
c2ef825d7b
Add pypy executables when calling uv venv (#5047)
## Summary

Should fix #2092.

This PR changes `uv venv` so it also creates symlinks to `pypy` on Unix
and copies executables on Windows when creating a new environment using
PyPy.

I found a bit of discrepancy between creation of a venv using `python`
and `uv`, as using `python` brings all the executables with it. While
`uv` brings only those without any version number, at least on Windows.
The behaviour is different on Unix as we take the versioned symlinks
too.

Some examples below.

`python -m venv` generates the following `Scripts` folder.
```
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         7/14/2024     15:41           2031 activate
-a----         7/14/2024     15:41           1029 activate.bat
-a----         7/14/2024     15:41           9033 Activate.ps1
-a----         7/14/2024     15:41            393 deactivate.bat
-a----         7/14/2024     15:40          27648 libffi-8.dll
-a----         7/14/2024     15:41       44290560 libpypy3.10-c.dll
-a----         7/14/2024     15:41         108424 pip.exe
-a----         7/14/2024     15:41         108424 pip3.10.exe
-a----         7/14/2024     15:41         108424 pip3.exe
-a----         7/14/2024     15:41          79360 pypy.exe
-a----         7/14/2024     15:41          79360 pypy3.10.exe
-a----         7/14/2024     15:41          79360 pypy3.10w.exe
-a----         7/14/2024     15:41          79360 pypy3.exe
-a----         7/14/2024     15:41          79360 pypyw.exe
-a----         7/14/2024     15:41          79360 python.exe
-a----         7/14/2024     15:41          79360 python3.10.exe
-a----         7/14/2024     15:41          79360 python3.exe
-a----         7/14/2024     15:41          79360 pythonw.exe
```

`uv venv` instead generates this. 
```
-a----         7/14/2024     16:27           3360 activate
-a----         7/14/2024     16:27           2251 activate.bat
-a----         7/14/2024     16:27           2627 activate.csh
-a----         7/14/2024     16:27           4191 activate.fish
-a----         7/14/2024     16:27           3875 activate.nu
-a----         7/14/2024     16:27           2766 activate.ps1
-a----         7/14/2024     16:27           2378 activate_this.py
-a----         7/14/2024     16:27           1728 deactivate.bat
-a----         7/13/2024     19:19          27648 libffi-8.dll
-a----         7/13/2024     19:19       44290560 libpypy3.10-c.dll
-a----         7/14/2024     16:27           1215 pydoc.bat
-a----         7/13/2024     19:19          79360 pypy.exe
-a----         7/13/2024     19:19          79360 pypyw.exe
-a----         7/13/2024     19:19          79360 python.exe
-a----         7/13/2024     19:19          79360 pythonw.exe
```

## Test Plan

To verify the correct behaviour:

1. Download and install PyPy from [official
website](https://www.pypy.org/download.html)
2. Call `uv venv -p <path_to_pypy_>`
3. Run `.\.venv\Scripts\activate` on Windows or
`./.venv/Scripts/activate` on Unix
4. Run `pypy`

I thought of writing some automated tests but I couldn't rely on `uv
python install` command to install PyPy as it's not in the list of
installable Python builds.
2024-07-15 13:28:31 -05:00
Zanie Blue
09ae7a93d1
Add integration test for PyPy (#5048) 2024-07-15 11:11:51 -05:00
Charlie Marsh
b629ab89c5
Set absolute URLs prior to uploading to PyPI (#5038)
## Summary

Closes https://github.com/astral-sh/uv/issues/5030.
2024-07-13 17:29:21 +00:00
Jo
4bdcec9622
Fix Fedora system test (#5034)
Seems like the latest
[`fedora:41`](https://hub.docker.com/layers/library/fedora/rawhide/images/sha256-c037a87094660ceda037ee319b17f59559241d2a3580d1d0f414e72b0a8f3827?context=explore)
(pushed at Jul 12, 2024 at 22:05 UTC) docker image has removed the
`python3` package, causing our current [CI
failure](2740152817).
2024-07-13 10:25:03 -05:00
Ibraheem Ahmed
a4e9b63d5b
Fix benchmarks CI job (#5023) 2024-07-12 17:57:12 -04:00
Ibraheem Ahmed
aff9c9bd91
Switch to Current-Thread Tokio Runtime (#4934)
## Summary

Move completely off tokio's multi-threaded runtime. We've slowly been
making changes to be smarter about scheduling in various places instead
of depending on tokio's general purpose work-stealing, notably
https://github.com/astral-sh/uv/pull/3627 and
https://github.com/astral-sh/uv/pull/4004. We now no longer benefit from
the multi-threaded runtime, as we run on all I/O on the main thread.
There's one remaining instance of `block_in_place` that can be swapped
for `rayon::spawn`.

This change is a small performance improvement due to removing some
unnecessary overhead of the multi-threaded runtime (e.g. spawning
threads), but nothing major. It also removes some noise from profiles.

## Test Plan

```
Benchmark 1: ./target/profiling/uv (resolve-warm)
  Time (mean ± σ):      14.9 ms ±   0.3 ms    [User: 3.0 ms, System: 17.3 ms]
  Range (min … max):    14.1 ms …  15.8 ms    169 runs
 
Benchmark 2: ./target/profiling/baseline (resolve-warm)
  Time (mean ± σ):      16.1 ms ±   0.3 ms    [User: 3.9 ms, System: 18.7 ms]
  Range (min … max):    15.1 ms …  17.3 ms    162 runs
 
Summary
  ./target/profiling/uv (resolve-warm) ran
    1.08 ± 0.03 times faster than ./target/profiling/baseline (resolve-warm)
```
2024-07-09 18:21:16 -04:00
samypr100
eee90a340c
feat: re-enable std in uv-trampoline (#4722)
## Summary

Partially closes #1917

This PR picks up on some of the great work from #1864 and opted to keep
`panic_immediate_abort` (for size reasons). I split the PR in different
isolated commits in case we want to separate/cherry-pick them out.

1. The first commit ports mostly all std changes from that PR into this
PR. Binary sizes stayed the same ~16kb.
2. The second commit migrates our existing usage of windows-sys to
windows for a safer ffi calls with Results!. It also changes all large
unsafe blocks to be isolated to the actual unsafe calls, and switches
some areas to use std such as getenv port ( which seemed buggy! ) from
launcher.c. In addition, this also adds more error checking in order to
match some missing assertions from distlib's launcher.c. Note, due to
the additional .text data, the binary sizes increased to ~20.5kb, but we
can cut back on some of the added error msgs as needed.
3. The third commit switches to using xwin for building on all 3
supported trampoline targets for sanity, and adds a CI bloat check for
core::fmt and panic as a precaution. Sadly, this will invalidate the
xwin cache on the first run.

## Test Plan

Most changes were tested on a couple of local GUI apps and console apps,
also tested some of the error states manually by using SetLastError at
different points in the code and/or passing in invalid handles.

I'm not sure how far we can get with migrating some of the other calls
without increasing binary size substantially. An initial attempt at
using std::path didn't seem so bad size wise when I tried it (~1k). On
other cases, such as std::process::exit added ~10k to the total binary
size.

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-07-06 20:38:45 +00:00
Zanie Blue
dd7da6af5f
Change "toolchain" to "python" (#4735)
Whew this is a lot.

The user-facing changes are:

- `uv toolchain` to `uv python` e.g. `uv python find`, `uv python
install`, ...
- `UV_TOOLCHAIN_DIR` to` UV_PYTHON_INSTALL_DIR`
- `<UV_STATE_DIR>/toolchains` to `<UV_STATE_DIR>/python` (with
[automatic
migration](https://github.com/astral-sh/uv/pull/4735/files#r1663029330))
- User-facing messages no longer refer to toolchains, instead using
"Python", "Python versions" or "Python installations"

The internal changes are:

- `uv-toolchain` crate to `uv-python`
- `Toolchain` no longer referenced in type names
- Dropped unused `SystemPython` type (previously replaced)
- Clarified the type names for "managed Python installations"
- (more little things)
2024-07-03 07:44:29 -05:00
konsti
42415997b1
Reactivate python 3.13 in CI (#4761)
https://github.com/actions/setup-python/issues/888#issuecomment-2205466950
2024-07-03 11:28:45 +02:00
samypr100
f43a8bbd6f
Upgrade to Rust 1.79 (#4754)
## Summary

Updates default toolchain to
[1.79](https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html).
There didn't seem to be any breaking changes besides xwin now requiring
lld llvm linker.

## Test Plan

Existing tests.
2024-07-02 23:50:47 -05:00
Zanie Blue
948c0f151b
Add retries to system-test-opensuse setup which flakes during database updates (#4622)
e.g. failure at
2681531811

Seems to be some sort of issue where they're updating their package
repository / database causing a spurious failure. I've seen this fail a
lot lately.
2024-06-28 15:24:43 -05:00
Zanie Blue
d2108bf360
Separate CI test runs from the matrix (#4518)
So we can skip them when there are not code changes and still enforce
our required checks (xref #4438)

Otherwise, the names are dynamic and they are forever expected (see
#4426 for example)
2024-06-25 10:29:30 -05:00
Zanie Blue
7e574f5e20
Avoid running most of CI for non-code changes (#4438)
Running these test suites is both expensive and wasteful when there
aren't relevant changes.
2024-06-21 16:42:01 +00:00
Zanie Blue
76c26db444
Move virtual environment test context into main context (#4370)
It was becoming problematic that the virtual environment test context
diverged from the other one i.e. we had to implement filtering twice.
This combines the contexts and tweaks the `TestContext` API and
filtering mechanisms for Python versions. Combined with my previous
changes to the test context at #4364 and
https://github.com/astral-sh/uv/pull/4368 this finally unblocks the
snapshots for test cases in #4360 and
https://github.com/astral-sh/uv/pull/4362.
2024-06-18 09:11:47 -05:00
Zanie Blue
631994c485
Remove cargo dev fetch-python (#4337)
This has been fully replaced by `uv toolchain install`
2024-06-17 18:49:06 +00:00
konsti
bbd961c251
Fix python3.13 on windows CI job by pinning older version (#4192)
See https://github.com/actions/setup-python/issues/888

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-06-10 11:49:24 +00:00
Charlie Marsh
e7c573cfcb
Fix existing typos and enable typos in CI (#4184) 2024-06-10 01:50:54 +00:00
konsti
f92447772e
Support x86 windows (#3873)
Add trampolines for x86 windows.

Closes https://github.com/astral-sh/uv/issues/3660.
2024-05-28 16:07:39 +00:00
Zanie Blue
30e780e1dd
Add persistent storage of installed toolchains (#3797)
Extends #3726 

Moves toolchain storage out of `UV_BOOTSTRAP_DIR` (`./bin`) into the
proper user data directory as defined by #3726.

Replaces `UV_BOOTSTRAP_DIR` with `UV_TOOLCHAIN_DIR` for customization.
Installed toolchains will be discovered without opt-in, but the idea is
still that these are not yet user-facing.
2024-05-27 03:54:49 +00:00
Zanie Blue
c2a58cd303
Add integration test for GitHub Actions CI patterns (#3805) 2024-05-23 23:25:06 -05:00
Ibraheem Ahmed
0d2f3fc4e4
Add airflow benchmark (#3643)
## Summary

This seems to be one of the most consistent benchmark cases we have in
terms of standard deviation:
```
➜  hyperfine "target/profiling/main pip compile scripts/requirements/airflow.in" --runs 200
Benchmark 1: target/profiling/main pip compile scripts/requirements/airflow.in
  Time (mean ± σ):     292.6 ms ±   6.6 ms    [User: 414.1 ms, System: 194.2 ms]
  Range (min … max):   282.7 ms … 320.1 ms    200 runs
```

For smaller benchmarks, scispacy and dtlssocket seem to be a bit more
consistent than our current jupyter benchmark, but it hasn't given us
any problems so I'll leave it for now.
2024-05-23 13:25:54 -04:00
Zanie Blue
17ec349437
Add test case for Conda CI (#3773)
Integration test coverage for #3769 

Failure against `main` on
2530051001

Rebased against #3771 to check for fix
2024-05-22 21:37:26 +00:00
Zanie Blue
845d788c91
Drop Python patch test flag from default features (#3746) 2024-05-22 17:19:25 +00:00
Charlie Marsh
472ab144d5
Remove maturin_editable test (#3718)
## Summary

I personally think this isn't worth continuing to maintain.
2024-05-22 11:10:04 +02:00
Zanie Blue
d540d0f28b
Rewrite Python interpreter discovery (#3266)
Updates our Python interpreter discovery to conform to the rules
described in #2386, please see that issue for a full description of the
behavior. Briefly, we now will search for interpreters that satisfy a
requested version without stopping at the first Python executable.
Additionally, if retrieving information about an interpreter fails we
will continue to search for a working interpreter. We also add the
plumbing necessary to request Python implementations other than CPython,
though we do not add support for other implementations at this time.

A major internal goal of this work is to prepare for user-facing managed
toolchains i.e. fetching a requested version during `uv run`. These APIs
are not introduced, but there is some managed toolchain handling as
required for our test suite.

Some noteworthy implementation changes:

- The `uv_interpreter::find_python` module has been removed in favor of
a `uv_interpreter::discovery` module.
- There are new types to help structure interpreter requests and track
sources
- Executable discovery is implemented as a big lazy iterator and is a
central authority for source precedence
- `uv_interpreter::Error` variants were split into scoped types in each
module
- There's much more unit test coverage, but not for Windows yet

Remaining work:

- [x] Write new test cases
- [x] Determine correct behavior around executables in the current
directory
- _Future_: Combine `PythonVersion` and `VersionRequest`
- _Future_: Consider splitting `ManagedToolchain` into local and remote
variants
- _Future_: Add Windows unit test coverage
- _Future_: Explore behavior around implementation precedence (i.e.
CPython over PyPy)

Refactors split into:

- #3329 
- #3330 
- #3331
- #3332

Closes #2386
2024-05-21 14:37:23 -05:00
Zanie Blue
dfd6ccf0f9
Move maturin test coverage into CI (#3714)
This test can take over 60s to run, which is too much for a unit test.
We'll run it in a separate CI job to retain coverage.
2024-05-21 19:17:48 +00:00
samypr100
d88bef9704
feat: move to cargo-xwin for clippy (#3600)
## Summary

Move to cargo-xwin for clippy

Closes #3507
2024-05-16 21:15:03 -05:00
samypr100
790206beb1
feat: speed up windows jobs using ReFS (#3522)
## Summary

Switch to using Virtual HD + ReFS to speed up windows jobs.

Closes #3508
2024-05-13 11:15:54 -05:00
Charlie Marsh
aa6b853d78
Run cargo shear in CI (#3534) 2024-05-12 21:44:58 -04:00
konsti
714adebbd7
Avoid stack overflows on more windows tests (#3344)
Fix windows CI by increasing the debug stack size on windows:
*
2455300039
*
2455094999
*
2455094926
*
2455081040
2024-05-03 12:21:00 +00:00
Ibraheem Ahmed
1d2c57a259
Run resolve/install benchmarks in ci (#3281)
## Summary

Runs resolver benchmarks in CI with CodSpeed.
2024-04-30 13:39:42 -04:00
samypr100
430ac7c45c
ci: add system test for rocky 9 (#3224)
## Summary

Adding rockylinux:9 per discussion in
https://github.com/astral-sh/uv/pull/3178

## Test Plan

More CI system tests.
2024-04-23 18:12:27 -04:00
Charlie Marsh
2c52111006
Fix failing system-test-macos-x86_64 test (#3218)
## Summary

GitHub recently changed `macos-latest` to `macos-12`, so the x86 test
started failing. I've migrated the tests to use dedicated labels, rather
than the aliases.

See:
https://github.blog/changelog/2024-01-30-github-actions-macos-14-sonoma-is-now-available/
2024-04-23 14:37:26 -04:00
Charlie Marsh
41b29b2dc4
Add support for embedded Python on Windows (#3161)
## Summary

References:
-
cad550030a/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py (L58-L68)
- https://github.com/pypa/virtualenv/pull/2353
- https://github.com/pypa/virtualenv/issues/2368

Closes https://github.com/astral-sh/uv/issues/1656.
2024-04-22 13:34:27 -04:00
Zanie Blue
52472cef6e
Run Windows tests with a subset of features (#3040)
Separates Windows tests from the rest because it's a pain and drops the
`python-patch` feature from testing so we can use the GitHub Actions
Python versions which bootstrap in 0 seconds instead of 2 minutes.
2024-04-16 08:14:19 -05:00
Zanie Blue
4ea909bfc2
Use the larger runner for Windows clippy runs (#3044)
Running clippy can apparently be longer than the tests in
https://github.com/astral-sh/uv/pull/3040
2024-04-15 21:16:40 -05:00
Charlie Marsh
ab9cc78b7a
Deduplicate symbolic links between purelib and platlib (#3002)
## Summary

This PR adds system install tests to verify the behavior described in
#2798. It turns out this behavior _also_ affects Fedora and Amazon
Linux, we just didn't have the right conditions enabled (specifically,
you need to create the virtualenv with `python -m venv` to get these
symlinks), so the test suite was expanded to capture that.

The issue itself is also fixed by way of deduplicating the
`site-packages` entries.

Closes: https://github.com/astral-sh/uv/issues/2798
2024-04-12 17:08:56 -04:00
samypr100
98fd9d7d14
ci: re-enable centos compatible testing (#3005)
## Summary

Closes #2915

## Test Plan

Rocky Linux is a viable and more stable alternative to test
compatibility with Centos and RHEL systems.
2024-04-12 03:52:03 +00:00
Zanie Blue
520cd4689b
Add ecosystem test for flask (#2971)
Alternative to:

- https://github.com/astral-sh/uv/pull/2967
- #2946 

Both of those are big and fail.

I'd like to generalize this coverage though.
2024-04-10 16:51:40 +00:00
Zanie Blue
44e39bdca3
Replace Python bootstrapping script with Rust implementation (#2842)
See https://github.com/astral-sh/uv/issues/2617

Note this also includes:
- #2918 
- #2931 (pending)

A first step towards Python toolchain management in Rust.

First, we add a new crate to manage Python download metadata:

- Adds a new `uv-toolchain` crate
- Adds Rust structs for Python version download metadata
- Duplicates the script which downloads Python version metadata
- Adds a script to generate Rust code from the JSON metadata
- Adds a utility to download and extract the Python version

I explored some alternatives like a build script using things like
`serde` and `uneval` to automatically construct the code from our
structs but deemed it to heavy. Unlike Rye, I don't generate the Rust
directly from the web requests and have an intermediate JSON layer to
speed up iteration on the Rust types.

Next, we add add a `uv-dev` command `fetch-python` to download Python
versions per the bootstrapping script.

- Downloads a requested version or reads from `.python-versions`
- Extracts to `UV_BOOTSTRAP_DIR`
- Links executables for path extension

This command is not really intended to be user facing, but it's a good
PoC for the `uv-toolchain` API. Hash checking (via the sha256) isn't
implemented yet, we can do that in a follow-up.

Finally, we remove the `scripts/bootstrap` directory, update CI to use
the new command, and update the CONTRIBUTING docs.

<img width="1023" alt="Screenshot 2024-04-08 at 17 12 15"
src="57bd3cf1-7477-4bb8-a8e9-802a00d772cb">
2024-04-10 11:22:41 -05:00
Zanie Blue
ee9059978a
Add ecosystem test for Prefect (#2942)
Reproduced https://github.com/astral-sh/uv/issues/2941 and confirmed
fix.

We probably ought to have some ecosystem test coverage — this seems like
a good starting point we can extend to other projects in the future.
2024-04-09 21:29:39 -05:00
Zanie Blue
31860565f6
Disable CentOS system check (#2916)
This is broken (see https://github.com/astral-sh/uv/issues/2915) and not
a priority since we have Amazon Linux coverage
2024-04-08 21:33:31 +00:00
renovate[bot]
e3ebd4de10
Update debian Docker tag to v12 (#2896) 2024-04-08 09:34:48 -04:00
renovate[bot]
356a26646c
Update fedora Docker tag to v41 (#2898) 2024-04-07 23:41:49 -05:00
Alex Waygood
345b767874
Improve renovate config (#2802) 2024-04-03 11:48:39 +00:00
Zander
4b2e67955f
fixed uv can't create .venv for cpython-x86 on Windows (#2707)
Adaptation to the win32 platform is added.

https://docs.python.org/3/library/sysconfig.html#sysconfig.get_platform


## Summary

fixed uv can't create .venv for cpython-x86 on Windows 

[uv can't create .venv for cpython-x86 on Windows
](https://github.com/astral-sh/rye/issues/952)

---------

Co-authored-by: Nashan <34827878+zhuang1234@users.noreply.github.com>
2024-04-02 20:45:53 -05:00
Zanie Blue
ba1e9ef182
Add Homebrew system check test (#2736)
Following #2735 adds a system check that uses Homebrew. I think we were
never were actually using Homebrew's Python in the past, we were mislead
or something changed in the runners recently that broke it.
2024-04-01 14:50:45 +00:00
Zanie Blue
472d302ef0
Fix extra CI checks on macOS (#2735)
Alternative to https://github.com/astral-sh/uv/pull/2729 since we're
having problems with the Homebrew Python.
2024-03-30 14:55:34 +00:00
Zanie Blue
0ae285d4b8
Use standard pip instead of pipx (#2733)
An attempt to solve macOS CI failures e.g.
2325653817
2024-03-30 14:12:17 +00:00