pixi icon indicating copy to clipboard operation
pixi copied to clipboard

[`0.48.0`] `index-url` config in `pypi-options` not being respected when installing build deps for editable installs

Open dhirschfeld opened this issue 1 year ago • 20 comments

Checks

  • [x] I have checked that this issue has not already been reported.
  • [x] I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

In my pyproject.toml file I specify an (internal) vcs-version package in the build-system:

[build-system]
requires = [
  "vcs-version>=1.2.0",
  "hatch-vcs>=0.4.0",
  "hatchling>=1.27.0",
]
build-backend = "hatchling.build"

...but pixi can't find it:

❯ pixi install --all
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `mypkg @ file:///home/me/code/mypkg`
  ├─▶ Failed to resolve requirements from `build-system.requires`
  ├─▶ No solution found when resolving: `vcs-version>=1.2.0`, `hatch-vcs>=0.4.0`, `hatchling>=1.27.0`
  ╰─▶ Because vcs-version was not found in the package registry and you require vcs-version>=1.2.0, we can conclude that your requirements are unsatisfiable.

...even though the package does exist in the (internal) registry:

❯ pip index versions vcs-version
vcs-version (1.2.0)
Available versions: 1.2.0, 1.1.1, 1.1.0

[!NOTE] The install seems to work the first time, after I nuke the .pixi folder and pixi.lock file, but then fails on any re-resolve.

dhirschfeld avatar Jun 09 '25 04:06 dhirschfeld

[!TIP]

The install works fine if I downgrade to 0.47.0!

dhirschfeld avatar Jun 09 '25 04:06 dhirschfeld

The actual wheel name is vcs_version-1.2.0-py3-none-any.whl, so I suspect it's related to the normalisation of the underscore... which makes me suspect it's related to this PR:

  • https://github.com/prefix-dev/pixi/pull/3775

which was added in 0.48.0:

Image

dhirschfeld avatar Jun 09 '25 04:06 dhirschfeld

hey @dhirschfeld ! Seems like a potential regression. let me look at this today

nichtmacho avatar Jun 09 '25 08:06 nichtmacho

what is your extra-index url configuration?

nichtmacho avatar Jun 10 '25 08:06 nichtmacho

I've used the following setup to try to mimic your issue: I'm running a pypi-server: pypi-server run -p 8080 ./local-pypi-packages where I have downloaded hatch-vcs ( which seems to have a similar name ) pip download hatch-vcs -d ./local-pypi-packages

and this is pixi.toml

[project]
authors = ["Bas Zalmstra <[email protected]>"]
channels = ["conda-forge"]
name = "pypi"
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]

[dependencies]
python = "~=3.11.0"

[pypi-dependencies]
hatch-vcs = "*"

[pypi-options]
extra-index-urls = [
  "http://localhost:8080",
]

And in the lock file, it records it correctly:

- pypi: http://localhost:8080/packages/hatch_vcs-0.5.0-py3-none-any.whl
      - pypi: http://localhost:8080/packages/hatchling-1.27.0-py3-none-any.whl

Could you please help me with your index configuration?

nichtmacho avatar Jun 10 '25 09:06 nichtmacho

Note: The install seems to work the first time but then any change to the deps necessitating a re-resolve fail with the error shown

dhirschfeld avatar Jun 10 '25 09:06 dhirschfeld

I can still do a pixi add --pypi boltons and it will fetch it from the pypi artifactory correctly

nichtmacho avatar Jun 10 '25 09:06 nichtmacho

I'll do some more testing. I'm hoping a -vvv might shed some light. If it's a Cloudsmith bug, that would be hard to repro 😬

dhirschfeld avatar Jun 10 '25 09:06 dhirschfeld

Could you please help me with your index configuration?

/etc/pixi/config.toml

default-channels = ["https://conda.cloudsmith.io/<org>/conda/"]

[pypi-config]
index-url ="https://dl.cloudsmith.io/<token>/<org>/python/python/simple/"

dhirschfeld avatar Jun 10 '25 11:06 dhirschfeld

❯ pixi add --pypi boltons
✔ Added boltons >=25.0.0, <26
Added these as pypi-dependencies.

Ok, that worked.

dhirschfeld avatar Jun 10 '25 11:06 dhirschfeld

It seems specific to my jupyter environment. The rest of my pyproject.toml file is pypi dependencies but jupyter is conda deps essentially because theme-material-darcula isn't available as a wheel (and no longer builds).

Try adding the below and then pixi run jupyterlab

[tool.pixi.feature.jupyter.dependencies]
anywidget = ">=0.9.13"
ipydatagrid = ">=1.3.2"
ipykernel = ">=6.29.5"
ipympl = ">=0.9.6"
ipython = ">=8.32.0"
ipywidgets = ">=8.1.5"
jupyter-server-proxy = ">=4.4.0"
jupyterlab = ">=4.3.6"
jupyterlab_execute_time = ">=3.2.0"
jupyterlab-lsp = ">=5.1.0"
line_profiler = ">=4.1.3"
pandas = "<2.3.0"  # FIXME: required by `databricks-sql-connector`
pixi-kernel = ">=0.6.1"
platformdirs = ">=4.3.8"
pylsp-mypy = ">=0.7.0"
python-lsp-ruff = ">=2.2.2"
theme-material-darcula = ">=1.0.3"
voila = ">=0.5.8"

[tool.pixi.feature.jupyter.tasks]
jupyterlab = { cmd = "jupyter lab --KernelSpecManager.ensure_native_kernel=False --KernelSpecManager.allowed_kernelspecs='pixi-kernel-python3' --LabApp.token='' --LabApp.password=''" }

dhirschfeld avatar Jun 10 '25 11:06 dhirschfeld

❯ pixi run jupyterlab
✨ Pixi task (jupyterlab in default): jupyter lab --KernelSpecManager.ensure_native_kernel=False --KernelSpecManager.allowed_kernelspecs='pixi-kernel-python3' --KernelSpecManager.allowed_kernelspecs='ark' --LabApp.token='' --LabApp.password=''
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `mypkg @ file:///home/me/code/mypkg`
  ├─▶ Failed to resolve requirements from `build-system.requires`
  ├─▶ No solution found when resolving: `vcs-version>=1.2.0`, `hatch-vcs>=0.4.0`, `hatchling>=1.27.0`
  ╰─▶ Because vcs-version was not found in the package registry and you require vcs-version>=1.2.0, we can conclude that your requirements are
      unsatisfiable.

dhirschfeld avatar Jun 10 '25 11:06 dhirschfeld

❯ rg vcs pixi.lock
276:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/vcs_version-1.2.0-py3-none-any.whl
279:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/hatch_vcs-0.5.0-py3-none-any.whl
616:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/vcs_version-1.2.0-py3-none-any.whl
619:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/hatch_vcs-0.5.0-py3-none-any.whl
744:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/vcs_version-1.2.0-py3-none-any.whl
751:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/hatch_vcs-0.5.0-py3-none-any.whl
919:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/vcs_version-1.2.0-py3-none-any.whl
926:      - pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/hatch_vcs-0.5.0-py3-none-any.whl
2849:  - vcs-version>=1.2.0 ; extra == 'build'
2850:  - hatch-vcs>=0.4.0 ; extra == 'build'
2855:  - vcs-version>=1.2.0 ; extra == 'dev'
2856:  - hatch-vcs>=0.4.0 ; extra == 'dev'
2868:  - vcs-version>=1.2.0 ; extra == 'docs'
2869:  - hatch-vcs>=0.4.0 ; extra == 'docs'
2911:  - vcs-version>=1.2.0 ; extra == 'build'
2912:  - hatch-vcs>=0.4.0 ; extra == 'build'
2924:  - vcs-version>=1.2.0 ; extra == 'docs'
2925:  - hatch-vcs>=0.4.0 ; extra == 'docs'
2967:  - vcs-version>=1.2.0 ; extra == 'build'
2968:  - hatch-vcs>=0.4.0 ; extra == 'build'
2980:  - vcs-version>=1.2.0 ; extra == 'docs'
2981:  - hatch-vcs>=0.4.0 ; extra == 'docs'
3051:  - vcs-version>=1.2.0 ; extra == 'build'
3052:  - hatch-vcs>=0.4.0 ; extra == 'build'
3093:  - vcs-version>=1.2.0 ; extra == 'dev'
3095:  - hatch-vcs>=0.4.0 ; extra == 'dev'
3265:- pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/vcs_version-1.2.0-py3-none-any.whl
3266:  name: vcs-version
3271:  - vcs-version[test] ; extra == 'dev'
3272:  - hatch-vcs>=0.4.0 ; extra == 'dev'
3536:- pypi: https://dl.cloudsmith.io/<token>/<org>/python/python/hatch_vcs-0.5.0-py3-none-any.whl
3537:  name: hatch-vcs

I have a complicated nesting of dependency groups. Let me know if you still can't repro with the jupyter feature and I'll try and create a more complete example.

dhirschfeld avatar Jun 10 '25 11:06 dhirschfeld

Everything I've been saying is wrong! I know what the real problem is now!

Image

dhirschfeld avatar Jun 12 '25 01:06 dhirschfeld

I can reproduce the problem with the below pyproject.toml

[project]
name = "bug-demo"
requires-python = ">=3.10"
version = "0.1.0"

dependencies = []

[project.optional-dependencies]
dev = ["ipython>=8.34.0"]

[build-system]
requires = [
  "my-internal-pkg",
  "hatch-vcs>=0.4.0",
  "hatchling>=1.27.0",
]
build-backend = "hatchling.build"

[tool.hatch.build]
include = ["src"]
targets.wheel.strict-naming = false
targets.wheel.packages = ["src/bug_demo"]
targets.sdist.strict-naming = false
targets.sdist.packages = ["src/bug_demo"]


[tool.pixi.project]
# channels = ["https://prefix.dev/conda-forge"]
channels = ["https://conda.cloudsmith.io/<org>/conda/"]
platforms = ["linux-64"]

[tool.pixi.pypi-options]
index-url = "https://dl.cloudsmith.io/<token>/<org>/python/python/simple/"

[tool.pixi.pypi-dependencies]
bug-demo = { path = ".", editable = true }

[tool.pixi.feature.py310.dependencies]
python = "3.10.*"

[tool.pixi.environments]
default = { features = ["py310", "dev"] }

With the below folder structure:

❯ eza -T --git-ignore ./
.
├── pyproject.toml
└── src
    └── bug_demo
        └── __init__.py

[!IMPORTANT] It works fine with 0.47.0 but fails with any newer version of pixi!

❯ pixi install
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `bug-demo @ file:///home/me/code/bug-demo`
  ├─▶ Failed to resolve requirements from `build-system.requires`
  ├─▶ No solution found when resolving: `my-internal-pkg`, `hatch-vcs>=0.4.0`, `hatchling>=1.27.0`
  ╰─▶ Because my-internal-pkg was not found in the package registry and you require my-internal-pkg, we can
      conclude that your requirements are unsatisfiable.

This always fails when trying to install the build-system.requries dependencies for the editable install but it only fails if it depends on a package only in our internal Cloudsmith PyPI registry.

I believe the problem is that for the editable install, when installing the build dependencies that the index-url isn't being passed to uv and it's trying to get the dependencies from PyPI rather than our Cloudsmith mirror.

dhirschfeld avatar Jun 12 '25 01:06 dhirschfeld

Thanks @dhirschfeld for the detailed reproduction! I will look at it today and try to reproduce it from my side

nichtmacho avatar Jun 12 '25 04:06 nichtmacho

@dhirschfeld aha! I can reproduce it. It is indeed slightly tricky - the important part is to have a package that is not present in the PyPI registry, and then index will be ignored.

You can also test it by having a private/local index that has only one package, and if you request any other, it will still succeed.

nichtmacho avatar Jun 12 '25 13:06 nichtmacho

Maybe related?

  • https://github.com/prefix-dev/pixi/issues/3937

dhirschfeld avatar Jun 12 '25 19:06 dhirschfeld

ok @dhirschfeld good news - I've found the problem :) draft PR will be soon opened

nichtmacho avatar Jun 13 '25 12:06 nichtmacho

Just mentioning so I don't forget, I think there is still an issue if your editable install is part of a custom feature rather than part of the default feature.

Will open an issue with a repro as soon as I can find the time!

dhirschfeld avatar Jul 04 '25 02:07 dhirschfeld