prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
2.88k stars 156 forks source link

problem with editable pypi packages and solve-groups #1632

Closed kcajf closed 2 weeks ago

kcajf commented 1 month ago

Checks

Reproducible example

Folder structure:

tree -h .
.
├── [ 4.0K]  my_python_proj
│   ├── [ 4.0K]  mylib
│   │   └── [    1]  __init__.py
│   └── [  155]  setup.py
├── [  16K]  pixi.lock
└── [  422]  pixi.toml

pixi.toml:

[project]
name = "proj"
version = "0.1.0"
channels = [ "conda-forge" ]
platforms = ["linux-64"]

[tasks]

[system-requirements]
linux = "4.18"

[dependencies]
python = "3.11.*"

[feature.my-feature.pypi-dependencies]
seagull = { path = "./my_python_proj", editable = true }

[environments]
env1 = { features = ["my-feature"], solve-group = "test-group" }
env2 = { features = ["my-feature"], solve-group = "test-group" }

__init__.py is empty

setup.py contains:

import setuptools

setuptools.setup(
    name="my_python_proj",
    version="0.0.0",
    packages=setuptools.find_packages(),
    install_requires=[],
)

To reproduce:

pixi --version
pixi 0.25.0

pixi run --environment env1 python -c 'import mylib'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'mylib'

If you change the solve-groups to be different (e.g. change one of them to test-group-2), import mylib will work.

Issue description

It seems that when you use solve-groups and editabled pypi packages, sometimes the packages don't end up getting included in the solve.

Expected behavior

it should be possible to import these packages

ruben-arts commented 1 month ago

He @kcajf,

I'm not able to reproduce. It wouldn't solve so I replaced seagull with my_python_proj. (which is important to contain the same name).

Then it worked as the expected behavior describes:

~/proj
❯ pixi run --environment env1 python -c 'import mylib'

~/proj took 2s
❯ pixi run -e env1 python
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mylib
>>>

Would you be able to find another reproducer? This is would be very helpful if I can properly reproduce it!

kcajf commented 1 month ago

Sorry, that was a copy-paste error. In my example, I meant for it to show:

[feature.my-feature.pypi-dependencies]
my_lib = { path = "./my_python_proj", editable = true }

For which I still see the error.

I didn't realise that the name needed to be that of the project name in setup.py(). I think it is confusing that my example does work if the solve-groups are different. Should it instead give an error that the name is wrong?

IshanArya commented 3 weeks ago

Hey, I've been really loving Pixi. However, I'm having a similar issue where I have this module: https://gitlab.inria.fr/bkerbl/simple-knn

As part of my project in the directory modules/simple-knn.

I added it to my pyproject.toml as:

simple-knn = {path = "./modules/simple-knn", editable=true}

and I get the error:

failed to solve the pypi requirements of 'default' 'linux-64'
  ├─▶ failed to resolve pypi dependencies
  ├─▶ Failed to build `simple-knn @ file:///home/nyx/projects/Genesis/modules/simple-knn`
  ├─▶ Failed to build: `simple-knn @ file:///home/nyx/projects/Genesis/modules/simple-knn`
  ╰─▶ Build backend failed to determine extra requires with `build_editable()` with exit status: 1
      --- stdout:

      --- stderr:
      Traceback (most recent call last):
        File "<string>", line 14, in <module>
        File "/home/nyx/.cache/rattler/cache/uv-cache/environments-v0/.tmpy7u8zk/lib/python3.11/site-packages/setuptools/build_meta.py", line 448, in
      get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/nyx/.cache/rattler/cache/uv-cache/environments-v0/.tmpy7u8zk/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in
      get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/nyx/.cache/rattler/cache/uv-cache/environments-v0/.tmpy7u8zk/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/home/nyx/.cache/rattler/cache/uv-cache/environments-v0/.tmpy7u8zk/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/home/nyx/.cache/rattler/cache/uv-cache/environments-v0/.tmpy7u8zk/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 12, in <module>
      ModuleNotFoundError: No module named 'torch'

I have torch installed. However, running pip install -e modules/simple-knn seems to work.

baszalmstra commented 2 weeks ago

This is because we always use build isolation. This is being addressed in: https://github.com/prefix-dev/pixi/issues/1124. Closing this issue for now. Please reopen if you feel I closed it too soon!