Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook uses *wrong* maturin executable #17

Open
1 task done
jeertmans opened this issue Jan 3, 2025 · 4 comments
Open
1 task done

Hook uses *wrong* maturin executable #17

jeertmans opened this issue Jan 3, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@jeertmans
Copy link

Bug Description

Hi!
I recently changed to an older machine and noticed that my code would not compile with the hook:

Uninstalled 1 package in 0.19ms
Installed 1 package in 0.43ms
failed to resolve project "/export/home/eertmans/repositories/DiffeRT/DiffeRT": pyproject.toml is invalid (does not have required fields)
building "differt_core"
maturin_import_hook [ERROR] command "/export/home/eertmans/.local/bin/maturin develop --manifest-path /export/home/eertmans/repositories/DiffeRT/DiffeRT/differt-core/Cargo.toml --color always --uv" returned non-zero exit status: 2
maturin_import_hook [ERROR] maturin output:
error: unexpected argument '--uv' found

  tip: to pass '--uv' as a value, use '-- --uv'

Usage: maturin develop <--quiet|--jobs <N>|--profile <PROFILE-NAME>|--features <FEATURES>|--all-features|--no-default-features|--target <TRIPLE>|--target-dir <DIRECTORY>|--manifest-path <PATH>|--ignore-rust-version|--verbose...|--color <WHEN>|--frozen|--locked|--offline|--config <KEY=VALUE>|-Z <FLAG>|--timings=<FMTS>|--future-incompat-report|ARGS>

For more information, try '--help'.

ImportError while loading conftest '/export/home/eertmans/repositories/DiffeRT/DiffeRT/differt/src/differt/conftest.py'.
differt/src/differt/__init__.py:3: in <module>
    from ._version import VERSION
differt/src/differt/_version.py:1: in <module>
    from differt_core import __version__  # Re-export version from code module
.venv/lib/python3.11/site-packages/maturin_import_hook/project_importer.py:151: in find_spec
    spec, rebuilt = self._rebuild_project(package_name, project_dir)
.venv/lib/python3.11/site-packages/maturin_import_hook/project_importer.py:261: in _rebuild_project
    maturin_output = develop_build_project(self.find_maturin(), resolved.cargo_manifest_path, settings)
.venv/lib/python3.11/site-packages/maturin_import_hook/_building.py:181: in develop_build_project
    raise MaturinError(msg)
E   maturin_import_hook.error.MaturinError: Failed to build package with maturin

I know --uv option was added as of maturin>=1.6, but this constraint is already specified in my pyproject.toml:

[build-system]
build-backend = "maturin"
requires = ["maturin>=1.6,<2"]

So I checked and, indeed, my global maturin executable was too old:

$ maturin --version   
maturin 1.5.1

and upgrading it to >=1.6 now works.

Is there a way for this hook to use the same maturin executable as the one from the build backend? I guess this can be hard, especially as the place where the build dependencies are installed is probably not obvious.

Otherwise, I think it could be nice to include some words about this in the docs.

What do you think?

Steps to Reproduce

  1. Create dummy repo that uses uv;
  2. Specify the build dependencies as above;
  3. Install hook with --detect-uv;
  4. Install maturin<1.6 globally;
  5. Trigger the hook.

Please provide the output of python -m maturin_import_hook version (or provide manually)

OS: Linux-6.8.0-51-generic-x86_64-with-glibc2.39
Python: CPython 3.11.10
maturin-import-hook: 0.2.0
maturin: maturin 1.8.1
rustc: rustc 1.83.0 (90b35a623 2024-11-26)
pip: ?

Does maturin develop work when run manually for your project?

  • Yes/No (leave blank if not applicable)
@jeertmans jeertmans added the bug Something isn't working label Jan 3, 2025
@mbway
Copy link
Collaborator

mbway commented Jan 3, 2025

I think the build backend gets downloaded automatically by the installer so it's not persistent on your system. I suppose the import hook could also do this as an option

@davidhewitt
Copy link
Member

Passing thought: an easier first step might be for the hook to warn (or error?) if the maturin version on the path doesn't match the requested one in the pyproject.toml.

@jeertmans
Copy link
Author

I think the build backend gets downloaded automatically by the installer so it's not persistent on your system. I suppose the import hook could also do this as an option

Yes, this is what I thought when saying that it might not be obvious.

@jeertmans
Copy link
Author

jeertmans commented Jan 3, 2025

Passing thought: an easier first step might be for the hook to warn (or error?) if the maturin version on the path doesn't match the requested one in the pyproject.toml.

I think this would be a great addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants