PyO3 / PyO3/pyo3

Running in virtualenvs on Windows

Open
#1,896 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help-wanted needs-design
Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

See also #1835

If I create a new virtualenv on Windows, install tomli into it, and run the following program:

use pyo3::prelude::*;

fn main() -> PyResult<()>{
    Python::with_gil(|py| {
        let m = PyModule::import(py, "tomli")?;
        Ok(())
    })
}

Then this fails to import tomli, despite building correctly with the virtualenv. On linux (at least Ubuntu 20.04) the equivalent works correctly.

I suspect we could investigate how pyo3::prepare_freethreaded_python sets up the interpreter - presumably on Windows it fails to detect the virtualenv, but on Linux it's fine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows virtualenv case from the issue, comparing it with the stated Ubuntu behavior. Read the interpreter setup around pyo3::prepare_freethreaded_python and investigate how the virtualenv is detected. Done means a Rust program can import tomli from a Windows virtualenv as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
backend, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.