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

Look in wrong path to find python interpreter when using maturin develop #1108

Closed
2 tasks done
ArchGuyWu opened this issue Sep 16, 2022 · 16 comments · Fixed by #1112
Closed
2 tasks done

Look in wrong path to find python interpreter when using maturin develop #1108

ArchGuyWu opened this issue Sep 16, 2022 · 16 comments · Fixed by #1112
Labels
bug Something isn't working

Comments

@ArchGuyWu
Copy link

ArchGuyWu commented Sep 16, 2022

Bug Description

maturin looks in $VENV_ROOT instead of $VENV_ROOT\bin to find python interpreter caused maturin develop to fail

Your Python version (python -V)

Python 3.10.7

Your pip version (pip -V)

pip 22.2.2

What bindings you're using

pyo3

Does cargo build work?

  • Yes, it works

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

  • Yes

Steps to Reproduce

  1. create a virtual environment using virtualenv $VENV_NAME
  2. then run maturin develop, the command will fail due to maturin looks in $VENV_ROOT instead of $VENV_ROOT\bin to find python interpreter
@ArchGuyWu ArchGuyWu added the bug Something isn't working label Sep 16, 2022
@messense
Copy link
Member

I can't reproduce this issue, did you activate your virtual environment before executing maturin? And maturin actually looks in $VENV_ROOT\Script to find python.exe.

image

@ArchGuyWu
Copy link
Author

Yes,I've activate it.
Annotation 2022-09-16 101506

@ArchGuyWu
Copy link
Author

And I'm using virtualenv,maybe you're using another tool?

@messense
Copy link
Member

What version of maturin are you using? Your venv looks a little odd to me, usually on Windows, activation scripts are in Scripts folder not bin.

@messense
Copy link
Member

I'm also using virtualenv, quoting https://virtualenv.pypa.io/en/latest/user_guide.html#activators

For a list of shells we provide activators see activators. The location of these is right alongside the python executables ( usually Scripts folder on Windows, bin on POSIX)

@ArchGuyWu
Copy link
Author

maturin 0.13.2
The latest version in msys2 package repo

@messense
Copy link
Member

The latest version in msys2 package repo

So you are running in msys2/mingw64 shell instead of normal Windows shell? Then I guess that's the issue.

@ArchGuyWu
Copy link
Author

No,I only install packages using msys2,and run them in nushell.

@messense
Copy link
Member

Did you install Python and virtualenv via msys2? It might have odd behavior this way because it thinks it's running in POSIX? If so can you try install Python and virtualenv from official channels?

@messense
Copy link
Member

The offending code is

maturin/src/target.rs

Lines 570 to 575 in 4e533f9

let path = venv_base.as_ref().join("Scripts").join("python.exe");
if path.exists() {
path
} else {
// for conda environment
venv_base.as_ref().join("python.exe")

Because your venv does not have a Scripts folder it fallback to conda environment. We can certainly add support for bin but I'd like to know more about why it happens first.

@ArchGuyWu
Copy link
Author

I think why this happens because both archlinux and msys2 are using pacman as its package manager,and they share the same pack script.

@ArchGuyWu
Copy link
Author

That causes the pack style different from the offical windows python's.

@messense
Copy link
Member

@ArchGuyWu Can you try #1112?

@messense
Copy link
Member

I think you can install it via pip install -U https://github.com/messense/maturin/archive/refs/heads/venv-python.zip

@ArchGuyWu
Copy link
Author

Ok,I'll try it.

@ArchGuyWu
Copy link
Author

@messense It works,thanks.

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

Successfully merging a pull request may close this issue.

2 participants