Skip to content

Hook uses *wrong* maturin executable #17

@jeertmans

Description

@jeertmans

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions