PyO3 / maturin

Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages
https://maturin.rs
Apache License 2.0
3.71k stars 254 forks source link

can't find crate `num_enum_derive` #2167

Closed paulstretenowich closed 1 month ago

paulstretenowich commented 1 month ago

Bug Description

Hi, I'm having hard time installing maturin with a can't find crate error. For more details in the issue leading me here Cf. https://github.com/pydantic/pydantic-core/issues/1370 I tried both pip install maturin and cargo install --locked maturin but I end up with:

error[E0463]: can't find crate for `num_enum_derive`
  --> /project/6007512/C3G/analyste_dev/software/rust/rust-1.79.0/registry/src/index.crates.io-6f17d22bba15001f/num_enum-0.7.2/src/lib.rs:10:11
   |
10 | pub use ::num_enum_derive::{
   |           ^^^^^^^^^^^^^^^ can't find crate

Please let me know if I can provide any complementary information. Thanks in advance for the help.

Your maturin version (maturin --version)

NA

Your Python version (python -V)

Python 3.12.2

Your pip version (pip -V)

pip 24.1.1

What bindings you're using

None

Does cargo build work?

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

Steps to Reproduce

Just pip install maturin or cargo install --locked maturin.

konstin commented 1 month ago

Can you share a reproducer and instructions that compile with cargo and fail with maturin?

paulstretenowich commented 1 month ago

I first tried the getting started here and it compiles and runs. Then I tried https://serde.rs/enum-number.html which also compiles and runs. Do you have anything else in mind you want me to try? I'm very new to Rust overall so I apology in advance if I'm not clear enough.

messense commented 1 month ago

We do have num_enum_derive listed in lockfile https://github.com/PyO3/maturin/blob/fd119cd30ed16ca734d763e3e8fd48caf7809afd/Cargo.lock#L1440-L1450

How did you install/build your Rust toolchain? Can you try a different one from rustup? Try Rust 1.80 or older version like 1.74?

konstin commented 1 month ago

In addition, what operating system and version are you on, what does ldd --version say?

paulstretenowich commented 1 month ago

I installed rust following the doc aka curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s --. I'm on an HPC so I installed it (as long as python) to a custom folder using module files. I just tried with 1.80 and I have the same error message. Do you want me to also try with 1.74? For the OS:

$ ldd --version
ldd (Gentoo 2.37-r3 (patchset 5)) 2.37
konstin commented 1 month ago

What is the architecture of the node you're using? I'm asking because normally pip install maturin shouldn't need to compile on a recent gentoo.

paulstretenowich commented 1 month ago

On the logging node I'm in there is an "Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz". I just tested out of the python venv I was in and without having rust module loaded and I could pip install maturin, I'm not sure to understand why though.

konstin commented 1 month ago

That's a normal, modern system, i'm surprised there's these compilation errors. As pip install maturin works, i'd say maturin works as it should.

Another thing you could try for rust compilation error is clearing cargo caches.

paulstretenowich commented 1 month ago

I remember trying clearing the cache and it was still failing. To give you more logs: The install failing was:

Looking in links: /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2020/avx512, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo/avx512, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2020/avx2, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo/avx2, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2020/g
eneric, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo/generic, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/generic
Collecting maturin
  Using cached maturin-1.7.0.tar.gz (188 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: maturin
  Building wheel for maturin (pyproject.toml) ... error

And the one succeeding did:

Looking in links: /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2023/x86-64-v4, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2023/x86-64-v3, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2023/generic, /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/generic
Processing /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/generic/pydantic-2.8.2+computecanada-py3-none-any.whl
Processing /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/generic/annotated_types-0.7.0+computecanada-py3-none-any.whl (from pydantic)
Processing /cvmfs/soft.computecanada.ca/custom/python/wheelhouse/gentoo2023/generic/pydantic_core-2.20.1+computecanada-cp312-cp312-linux_x86_64.whl (from pydantic)
Requirement already satisfied: typing-extensions>=4.6.1 in ./lib/python3.12/site-packages (from pydantic) (4.12.2+computecanada)
Installing collected packages: pydantic-core, annotated-types, pydantic
Successfully installed annotated-types-0.7.0+computecanada pydantic-2.8.2+computecanada pydantic-core-2.20.1+computecanada
konstin commented 1 month ago

Maybe your admin put an odd pip config? You should be using maturin from https://pypi.org/project/maturin/, e.g. https://files.pythonhosted.org/packages/2b/f9/98ba27c5f7c031f12d11cb64651c44730eb566cd10b3080f9a498c210b7e/maturin-1.7.0-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl, i'm not sure what they are doing with that wheelhouse. It looks like in the succeeding attempt you're using wheels your admins put there, you should look at the cluster docs or (lacking docs) talk to the cluster admins and ask what's up with that pip configuration.

paulstretenowich commented 1 month ago

I'll keep that in mind and ask them. In the meantime as it seems to be working for now I guess we can close this ticket and if I find anything relevant I can add later for others. Many thanks for your help!