astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.84k stars 779 forks source link

uv run not respecting extra index preferences in cargo build vs pip install in a conda env #6358

Closed abazabaaa closed 3 months ago

abazabaaa commented 3 months ago

Hi,

I believe this to be a bug.

When creating a micromamba env (micromamba -n test2 python=3.11) and then installing uv with pip I am able to run the following and get a successful installation: uv pip install openeye-toolkits uv pip install openeye-toolkits Resolved 1 package in 1.04s ░░░░░░░░░░░░░░░░░░░░ [0/1] Installing wheels... warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If the cache and target directories are on different filesystems, hardlinking may not be supported. If this is intentional, set UV_LINK_MODE=copy or use --link-mode=copy to suppress this warning. Installed 1 package in 20.55s

from openeye import oechem, oegraphsim import numpy as np

# Create an OEBitVector object from a molecule fingerprint mol = oechem.OEGraphMol() oechem.OEParseSmiles(mol,'c1ccccc1') fp = oegraphsim.OEFingerPrint() oegraphsim.OEMakeMACCS166FP(fp, mol)

bitv = [0]*fp.GetSize()

# bitv = np.array([0]*fp.GetSize()) bit = fp.FirstBit() while bit != -1: bitv[bit]=1 bit=fp.NextBit(bit)

packed = np.packbits(bitv) unpacked = np.unpackbits(packed) print(packed) print(unpacked)

I then do: uv run openeyetest.py Reading inline script metadata from: openeyetest.py × No solution found when resolving script dependencies: ╰─▶ Because there are no versions of openeye-toolkits and you require openeye-toolkits, we can conclude that your requirements are unsatisfiable.

My ~/.uv/uv.toml is as follows (truncated paths and removed token): [pip] index-url = "xxxx.com/simple/" extra-index-url = ["https://token:xxxxxxxx@magpie.eyesopen.com/simple", "https://download.pytorch.org/whl/cu121"]

I have additionally tried various versions of python in the header of openeyetest.py (python==3.11.9 ; which works with the openeye-toolkits). I have exported the path to uv.toml so that it was set (export UV_CONFIG_FILE=/xxx/uv.toml)

uv --version uv 0.3.0

Other than this, things seem to be working ok.

charliermarsh commented 3 months ago

Yeah this looks wrong. We should be respecting the configuration there.

charliermarsh commented 3 months ago

Just clarifying, it does not work even with UV_CONFIG_FILE=...?

abazabaaa commented 3 months ago

Correct, is does not seem to make a difference.

export UV_CONFIG_FILE=/xxxxxx/uv.toml uv run openeyetest.py Reading inline script metadata from: openeyetest.py × No solution found when resolving script dependencies: ╰─▶ Because there are no versions of openeye-toolkits and you require openeye-toolkits, we can conclude that your requirements are unsatisfiable.

I can see it correctly set in the help. uv --help ... Global options: -q, --quiet Do not print any output -v, --verbose... Use verbose output --color Control colors in output [default: auto] [possible values: auto, always, never] --native-tls Whether to load TLS certificates from the platform's native certificate store [env: UV_NATIVE_TLS=] --offline Disable network access --no-progress Hide all progress outputs --config-file The path to a uv.toml file to use for configuration [env: UV_CONFIG_FILE=/xxxxxv/uv.toml] --no-config Avoid discovering configuration files (pyproject.toml, uv.toml) [env: UV_NO_CONFIG=] -h, --help Display the concise help for this command -V, --version Display the uv version

Use uv help for more details.

charliermarsh commented 3 months ago

Ok thanks.

abazabaaa commented 3 months ago

Just to further confirm this with an internal pypi server which I have in my uv.toml as my index-url: [pip] index-url = "xxxx.com/simple/" extra-index-url = ["https://token:[xxxxxxxx@magpie.eyesopen.com](mailto:xxxxxxxx@magpie.eyesopen.com)/simple", "https://download.pytorch.org/whl/cu121"]

I was unable to run pydingertest.py after adding "pydinger" with uv add --script pydingertest.py "pydinger" uv run pydingertest.py Reading inline script metadata from: pydingertest.py × No solution found when resolving script dependencies: ╰─▶ Because pydinger was not found in the package registry and you require pydinger, we can conclude that your requirements are unsatisfiable.

It was successful in the micromamba env with the same version of uv (0.3).

micromamba activate test2 uv pip install pydinger Resolved 23 packages in 14.19s Built pydinger==1.0.3 Built ldclient==2023.2.2 Prepared 8 packages in 6.45s ░░░░░░░░░░░░░░░░░░░░ [0/22] Installing wheels... warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If the cache and target directories are on different filesystems, hardlinking may not be supported. If this is intentional, set UV_LINK_MODE=copy or use --link-mode=copy to suppress this warning. Installed 22 packages in 31.93s

So it seems that our internal pypi server is not getting searched on the cargo version.

charliermarsh commented 3 months ago

Oh sorry -- can you change:

[pip]
index-url = "xxxx.com/simple/"
extra-index-url = ["https://token:[xxxxxxxx@magpie.eyesopen.com](mailto:xxxxxxxx@magpie.eyesopen.com)/simple", "https://download.pytorch.org/whl/cu121"]

To:

index-url = "xxxx.com/simple/"
extra-index-url = ["https://token:[xxxxxxxx@magpie.eyesopen.com](mailto:xxxxxxxx@magpie.eyesopen.com)/simple", "https://download.pytorch.org/whl/cu121"]

Settings under [pip] only apply to uv pip, but settings at the top-level apply everywhere.

abazabaaa commented 3 months ago

Fixed!!

So just to be clear, I can also have a [pip] so that my uv pip works the same?

charliermarsh commented 3 months ago

If you write it without [pip], it will also affect uv pip. It's just that if you write it with [pip], it doesn't affect uv run and other APIs. Does that make sense?

charliermarsh commented 3 months ago

In other words, you only need the version without [pip].

(We kept the [pip] table for backwards compatibility.)

abazabaaa commented 3 months ago

Yes, it makes sense.