Commit graph

304 commits

Author SHA1 Message Date
Andrew Gallant
33480d61eb switch to jiff from chrono (#6205)
This PR migrates uv's use of `chrono` to `jiff`.

I did most of this work a while back as one of my tests to ensure Jiff
could actually be used in a real world project. I decided to revive
this because I noticed that `reqwest-retry` dropped its Chrono
dependency,
which is I believe the only other thing requiring Chrono in uv.
(Although, we use a fork of `reqwest-middleware` at present, and that
hasn't been updated to latest upstream yet. I wasn't quite sure of the
process we have for that.)

In course of doing this, I actually made two changes to uv:

First is that the lock file now writes an RFC 3339 timestamp for
`exclude-newer`. Previously, we were using Chrono's `Display`
implementation for this which is a non-standard but "human readable"
format. I think the right thing to do here is an RFC 3339 timestamp.

Second is that, in addition to an RFC 3339 timestamp, `--exclude-newer`
used to accept a "UTC date." But this PR changes it to a "local date."
That is, a date in the user's system configured time zone. I think
this makes more sense than a UTC date, but one alternative is to drop
support for a date and just rely on an RFC 3339 timestamp. The main
motivation here is that automatically assuming UTC is often somewhat
confusing, since just writing an unqualified date like `2024-08-19` is
often assumed to be interpreted relative to the writer's "local" time.
2024-08-20 11:31:46 -05:00
Charlie Marsh
81a50dcb08
Add 32-bit Windows target (#6252)
## Summary

Closes https://github.com/astral-sh/uv/issues/6245.

## Test Plan

```
❯ cargo run pip install sqlalchemy --python-platform i686-pc-windows-msvc --verbose --no-cache --reinstall
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/uv pip install sqlalchemy --python-platform i686-pc-windows-msvc --verbose --no-cache --reinstall`
DEBUG uv 0.2.37
DEBUG Searching for Python interpreter in system path
DEBUG Found `cpython-3.12.3-macos-aarch64-none` at `/Users/crmarsh/workspace/uv/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.3 environment at .venv/bin/python3
DEBUG Acquired lock for `.venv`
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.12.3
DEBUG Adding direct dependency: sqlalchemy*
DEBUG No cache entry for: https://pypi.org/simple/sqlalchemy/
WARN Skipping file for sqlalchemy: SQLAlchemy-0.1.1-py2.4.egg
WARN Skipping file for sqlalchemy: SQLAlchemy-0.1.2-py2.4.egg
WARN Skipping file for sqlalchemy: SQLAlchemy-0.1.3-py2.4.egg
WARN Skipping file for sqlalchemy: SQLAlchemy-0.1.4-py2.4.egg
DEBUG Searching for a compatible version of sqlalchemy (*)
DEBUG Selecting: sqlalchemy==2.0.32 [compatible] (SQLAlchemy-2.0.32-cp312-cp312-win32.whl)
DEBUG No cache entry for: 973e0bbf2b/SQLAlchemy-2.0.32-cp312-cp312-win32.whl.metadata
DEBUG Adding transitive dependency for sqlalchemy==2.0.32: typing-extensions>=4.6.0
DEBUG No cache entry for: https://pypi.org/simple/typing-extensions/
DEBUG Searching for a compatible version of typing-extensions (>=4.6.0)
DEBUG Selecting: typing-extensions==4.12.2 [compatible] (typing_extensions-4.12.2-py3-none-any.whl)
DEBUG No cache entry for: ad63fc0248/typing_extensions-4.12.2-py3-none-any.whl.metadata
DEBUG Tried 2 versions: sqlalchemy 1, typing-extensions 1
DEBUG Split specific environment resolution took 0.390s
Resolved 2 packages in 391ms
DEBUG Must revalidate requirement: sqlalchemy
DEBUG Must revalidate requirement: typing-extensions
DEBUG Unnecessary package: markupsafe==2.1.5
DEBUG Unnecessary package: filelock==3.15.4
DEBUG Unnecessary package: fsspec==2024.6.1
DEBUG Unnecessary package: jinja2==3.1.4
DEBUG Unnecessary package: mpmath==1.3.0
DEBUG Unnecessary package: networkx==3.3
DEBUG Unnecessary package: setuptools==72.2.0
DEBUG Unnecessary package: sympy==1.13.2
DEBUG Unnecessary package: torch==2.4.0
DEBUG No cache entry for: 973e0bbf2b/SQLAlchemy-2.0.32-cp312-cp312-win32.whl
DEBUG No cache entry for: ad63fc0248/typing_extensions-4.12.2-py3-none-any.whl
Prepared 2 packages in 150ms
DEBUG Uninstalled sqlalchemy (275 files, 25 directories)
DEBUG Uninstalled typing-extensions (7 files, 1 directory)
```
2024-08-20 14:06:25 +00:00
Charlie Marsh
3395d24959
Allow user to constrain supported lock environments (#6210)
## Summary

The strategy here is: if the user provides supported environments, we
use those as the initial forks when resolving. As a result, we never add
or explore branches that are disjoint with the supported environments.
(If the supported environments change, we ignore the lockfile entirely,
so we don't have to worry about any interactions between supported
environments and the preference forks.)

Closes https://github.com/astral-sh/uv/issues/6184.
2024-08-20 13:28:04 +00:00
Zanie Blue
c703917d99
Document the cache directory (#6229) 2024-08-19 15:51:45 -05:00
Zanie Blue
cc8fbedd37
Document the tools directory (#6228)
As in https://github.com/astral-sh/uv/pull/6227
2024-08-19 19:46:19 +00:00
Zanie Blue
b7c9ad981d
Document the Python installation directory (#6227) 2024-08-19 19:42:36 +00:00
Zanie Blue
df2ebf74d0
Document yanked packages caveat during sync (#6219)
Closes https://github.com/astral-sh/uv/issues/5928
2024-08-19 12:52:52 -05:00
Zanie Blue
c817f41951
Document the effect of ordering on package priority (#6211)
Closes https://github.com/astral-sh/uv/issues/6209
Closes https://github.com/astral-sh/uv/issues/5474
2024-08-19 11:53:28 -05:00
Zanie Blue
6bc8639ce8
Allow customizing the tool install directory with UV_TOOL_BIN_DIR (#6207)
Requested in #6067
2024-08-19 15:02:10 +00:00
Di-Is
ad8e3a2c32
Hide global option in uv generate-shell-completion (#6170)
Resolve #6152 

## Summary

## Test Plan

Execution result of `cargo run generate-shell-completion --help`

```bash
Generate shell completion

Usage: uv generate-shell-completion <SHELL>

Arguments:
  <SHELL>  The shell to generate the completion script for [possible values: bash, elvish, fish, nushell, powershell, zsh]
```

Execution result of `cargo run help generate-shell-completion`

```bash
Generate shell completion

Usage: uv generate-shell-completion <SHELL>

Arguments:
  <SHELL>
          The shell to generate the completion script for
          
          [possible values: bash, elvish, fish, nushell, powershell, zsh]
```
2024-08-17 13:34:34 -05:00
Zanie Blue
0091adfa5b
Document uv add and uv remove behavior with markers (#6163) 2024-08-16 23:16:42 +00:00
Zanie Blue
ded7300455
Disable collapsible navigation in the documentation (#5674)
Removes the collapsible sections in favor of larger font navigation
headings. I found the bold to be too distracting from the content itself
— it might be okay in the future if the navigation bar is further left.

Before:

<img width="1356" alt="Screenshot 2024-08-16 at 6 03 57 PM"
src="https://github.com/user-attachments/assets/75e49216-dc0d-4d26-a0d8-0283c29f9b81">

After:

<img width="1324" alt="Screenshot 2024-08-16 at 6 05 36 PM"
src="https://github.com/user-attachments/assets/cbce96ce-0969-46c5-80b6-e163481b8bfa">

(No change to the mobile view)

<img width="823" alt="Screenshot 2024-08-16 at 6 05 03 PM"
src="https://github.com/user-attachments/assets/b450e413-d5a4-4d2d-9905-e8eb6ac6f546">
<img width="823" alt="Screenshot 2024-08-16 at 6 05 13 PM"
src="https://github.com/user-attachments/assets/bd251ea0-58d8-456e-bdc8-4e3699061e6c">
2024-08-16 18:09:21 -05:00
Ahmed Ilyas
268c6de7fd
Support uv add -r requirements.txt (#6005)
## Summary

Resolves https://github.com/astral-sh/uv/issues/4537

- First commit avoids overwriting dependencies with different markers.
- Second commit supports adding from requirements files.

## Test Plan

`cargo test`
2024-08-16 21:57:45 +00:00
Zanie Blue
b93b0f2bcd
Show uv generate-shell-completion in CLI documentation reference (#6146)
We need to follow this with:

1) Hide a bunch of global arguments for this command
2) Add an about section for the command
2024-08-16 11:40:05 -05:00
Charlie Marsh
171c39d365
Remove 'tool' reference on uv run CLI (#6110) 2024-08-15 14:09:02 +00:00
eth3lbert
ef948619ee
Hide python options in uv tool list help (#6003)
## Summary

Closes #5982 .

## Test Plan

```
cargo run tool list --help
```

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-13 11:21:44 -05:00
Zanie Blue
f6f1bd2f14
Improve top-level help for uv tool commands (#5983)
More work needs to be done for all of the options
2024-08-12 17:35:50 +00:00
Ahmed Ilyas
2d53e35e39
Support PEP 723 scripts in uv add and uv remove (#5995)
## Summary

Resolves https://github.com/astral-sh/uv/issues/4667

## Test Plan

`cargo test`
2024-08-11 01:40:59 +00:00
Zanie Blue
921050d747
Improve the uv sync CLI documentation (#5930) 2024-08-09 14:46:32 -05:00
Zanie Blue
d6c587c21c
Improve the uv python CLI documentation (#5961) 2024-08-09 14:46:21 -05:00
Charlie Marsh
f89403f4f6
Retain and respect settings in tool upgrades (#5937)
## Summary

We now persist the `ResolverInstallerOptions` when writing out a tool
receipt. When upgrading, we grab the saved options, and merge with the
command-line arguments and user-level filesystem settings (CLI > receipt
> filesystem).
2024-08-09 18:21:49 +00:00
Zanie Blue
4df0fe9a01
Update the interface for declaring Python download preferences (#5936)
The loose consensus is that "fetch" doesn't have much meaning and that a
boolean flag makes more sense from the command line.

1. Adds `--allow-python-downloads` (hidden, default) and
`--no-python-downloads` to the CLI to quickly enable or disable
downloads
2. Deprecates `--python-fetch` in favor of the options from (1)
3. Removes  `python-fetch` in favor of a `python-downloads` setting
5. Adds a `never` variant to the enum, allowing even explicit installs
to be disabled via the configuration file

## Test plan

I tested this with various `pyproject.toml`-level settings and `uv venv
--preview --python 3.12.2` and `uv python install 3.12.2` with and
without the new CLI flags.
2024-08-09 13:10:19 -05:00
Zanie Blue
db0b44b88c
Move some documents to relevant sections (#5968) 2024-08-09 17:31:10 +00:00
Zanie Blue
3228fc5f35
Improve the uv venv CLI documentation (#5963)
This was actually in pretty good shape already!
2024-08-09 12:15:22 -05:00
Zanie Blue
4330f9718b
Improve the uv lock CLI documentation (#5932) 2024-08-09 08:51:03 -05:00
Charlie Marsh
fd1d508108
Make --upgrade imply --refresh (#5943)
## Summary

I think this seems reasonable... Otherwise, we might not go back to PyPI
to revalidate the list of available versions despite the user passing
`--upgrade`.
2024-08-08 20:11:31 -04:00
Ahmed Ilyas
cbc3274848
Add uv tool upgrade command (#5197)
## Summary

Resolves #5188. Most of the changes involve creating a new function in
`tool/common.rs` to contain the common functionality previously found in
`tool/install.rs`.

## Test Plan

`cargo test`

```console
❯ ./target/debug/uv tool upgrade black
warning: `uv tool upgrade` is experimental and may change without warning.
Resolved 6 packages in 25ms
Uninstalled 1 package in 3ms
Installed 1 package in 19ms
 - black==23.1.0
 + black==24.4.2
Installed 2 executables: black, blackd
```
2024-08-08 16:48:14 -04:00
Zanie Blue
bf0497e652
Add CLI flags to reference documentation (#5926)
Oopsies, options are only arguments that take values in Clap-land

Closes https://github.com/astral-sh/uv/issues/5924
2024-08-08 18:51:27 +00:00
Zanie Blue
d2681320d3
Improve the CLI documentation for uv remove (#5916)
Also, renames a `requirements` variable to `packages` for clarity and
fixes the definition of `frozen` for `uv add`.
2024-08-08 13:12:49 -05:00
Zanie Blue
eb6251e0ed
Improve the CLI documentation for uv add (#5914) 2024-08-08 10:52:38 -05:00
Ahmed Ilyas
acbd367ead
Support no-build-isolation-package (#5894)
## Summary

Resolves #5831 

## Test Plan

`cargo test`
2024-08-08 01:35:56 +00:00
Zanie Blue
c95bf76dfe
Replace uv help python references in CLI documentation with links (#5871)
Following #5869, the documentation has some less-than-helpful
suggestions to use `uv help python` for details — we should link to the
`uv python` section instead.
2024-08-07 12:21:09 -05:00
Zanie Blue
fe2849af6a
Improve CLI documentation for uv tree (#5870) 2024-08-07 16:59:27 +00:00
Zanie Blue
2df2092084
Improve --python CLI documentation (#5869)
Closes #4400
2024-08-07 16:37:10 +00:00
Zanie Blue
32d8ea1698
Improve documentation for uv init CLI (#5862) 2024-08-07 11:26:00 -05:00
Zanie Blue
8998149ac1
Improve CLI documentation for uv run (#5841)
Adds more long-form help to `uv run`, which renders in `uv help run` and
the CLI reference on the website.
2024-08-07 13:26:24 +00:00
konsti
68f186c409
Resolver internals docs touchups (#5850) 2024-08-07 08:32:31 +00:00
Zanie Blue
d1614c8f10
Improve CLI documentation for global options (#5834)
Slowly auditing our CLI help text
2024-08-06 20:50:29 -05:00
Zanie Blue
c0c26cc542
Improve display order of top-level commands (#5830)
Closes https://github.com/astral-sh/uv/issues/5702

Since Clap 4, the default order follows the declarations.

Also improves some descriptions.
2024-08-06 16:18:05 -05:00
Charlie Marsh
d8d9b02512
Add --no-build-isolation to uv lock et al (#5829)
## Summary

Closes https://github.com/astral-sh/uv/issues/5742.
2024-08-06 21:11:48 +00:00
Zanie Blue
12059340de
Update resolver reference documentation (#5823) 2024-08-06 13:18:23 -05:00
Charlie Marsh
089f50a845
Add --no-sources to avoid reading from tool.uv.sources (#5801)
## Summary

Closes https://github.com/astral-sh/uv/issues/5791.
2024-08-06 14:14:19 +00:00
Delgan
3a24aecb2c
Fix invalid TOML syntax in examples of "config-settings" docs (#5809)
## Summary

The snippet generated TOML errors when I copy/pasted it in my config
file, I believe there was a typo. 👍

## Test Plan

N/A
2024-08-06 08:17:54 +00:00
Charlie Marsh
6b45baf7be
Support --python-platform in uv tree (#5764)
## Summary

This allows you to set (e.g.) `--python-platform windows` to view the
resolved dependencies on Windows.

Closes https://github.com/astral-sh/uv/issues/5760.
2024-08-05 19:02:35 +00:00
Zanie Blue
865f9eeef7
Collapse policies section into reference (#5696) 2024-08-05 17:44:26 +00:00
FishAlchemist
26b3bfbedb
Fix the default value of python-preference in docs/reference/settings.md (#5755)
## Summary
After referring to https://github.com/astral-sh/uv/pull/5637 and doing
additional testing.
The default value in a stable state seems more reasonable to be
``only-system``. ``managed`` in preview.
```
cpython-3.11.9-windows-x86_64-none     C:\Users\name\AppData\Local\Programs\Python\Python311\python.exe

cpython-3.10.14-windows-x86_64-none    C:\Users\name\AppData\Roaming\uv\data\python\cpython-3.10.14-windows-x86_64-none\install\python.exe
cpython-3.10.11-windows-x86_64-none    C:\Users\name\AppData\Local\Programs\Python\Python310\python.exe

cpython-3.9.19-windows-x86_64-none     C:\Users\name\AppData\Roaming\uv\data\python\cpython-3.9.19-windows-x86_64-none\python.exe
```
test on uv 0.2.33 (build from
257007ccaf)
### Stable version
``uv venv -p 3.10`` is ``3.10.11`` (System Python)
``uv venv -p 3.9`` is ``No interpreter found``(3.9.19 for managed
Python)
``uv venv -p 3.9 --python-preference only-system`` is ``No interpreter
found``(fail)
``uv venv -p 3.9 --python-preference only-managed`` is
``3.9.19``(success)
Do not use managed Python, only use the system Python, so it can be
determined as ``only-system``.
### Preview mode
**Note:**  ``3.10.14`` is managed python, ``3.10.11`` is system python.
``uv venv -p 3.11 --preview`` is ``3.11.9`` (System Python)
``uv venv -p 3.10 --preview`` is ``3.10.14``
``uv venv -p 3.10 --preview --python-preference only-managed`` is
``3.10.14``
``uv venv -p 3.10 --preview --python-preference managed`` is ``3.10.14``
``uv venv -p 3.10 --preview --python-preference system`` is ``3.10.11``
``venv -p 3.10 --preview --python-preference only-system`` is
``3.10.11``
Prioritize the managed Python and then select the system Python, so it
can be determined as ``managed``.

-----
fixed #5754 
## Test Plan
Run website in local.

![image](https://github.com/user-attachments/assets/02b81d44-1a99-4165-aca5-6ce46345b539)
2024-08-03 23:37:40 +00:00
konsti
6e310f2702
Rewrite resolver docs (#5723)
This PR rewrites the resolver concept and adds a resolver internals page
targeted at power users.

The new resolution concept documentation has three parts:
* An introduction for people how never heard of "resolution" before, and
a motivating example what it does. I've also shoved the part about
equally valid resolutions in there.
* Features you commonly use: Non-universal vs. universal resolution,
lowest resolution amd pre-releases.
* Expert features, we don't advertise them, you'll only need them in
complex cases when you already know and i kept them to the reference
points you need in this case: Constraints, overrides and exclude-newer.

I intentionally didn't lay out any detail of the resolution itself, the
idea is that users get a vague sense of "uv has to select fitting
versions", but then they learn the options they have to use and some
common failure points without ever coming near SAT or even graphs.

The resolution internals reference page is targeted at power users who
need to understand what is going on behind the scenes. It assumes ample
prior knowledge and exists to explain the uv-specific behaviors for
someone who already understands dependency resolution conceptually and
has interacted with their dependency tree before. I had a section on the
lockfile but removed it because it found the lockfile to be too
self-documenting.

I haven't touched the readme.

Closes #5603
Closes #5238
Closes #5237

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-03 08:47:11 -05:00
eth3lbert
f2c4b9c752
Show default and possible options in CLI reference documentation (#5720)
## Summary

Closes #5692 .
2024-08-02 12:55:50 +00:00
Ahmed Ilyas
a6416aa450
Fix CLI reference URLs to subcommands (#5722)
## Summary

Currently all of these links end up 404-ed. I've added a `#` to fix the
URLs.

<img width="653" alt="Screenshot 2024-08-02 at 12 34 22"
src="https://github.com/user-attachments/assets/9b66adcc-431c-441a-8f4f-1b579472fdce">

## Test Plan

Checked manually.
2024-08-02 07:35:33 -05:00
Ahmed Ilyas
ff9f3dede1
Support build constraints (#5639)
## Summary

Partially resolves #5561. Haven't added overrides support yet but I can
add it tomorrow if the current approach for constraints is ok.

## Test Plan

`cargo test`

Manually checked trace logs after changing the constraints.
2024-08-02 02:15:58 +00:00