Linking against python for tests that depend on a pyo3_extension

Open
#3,889 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, rust

Research direction

Start with the pyo3_extension documentation and the rules_rust handling of rust_test targets, then compare this with Cargo's extension-module feature behavior. Check how a rules_python toolchain exposes Python libraries and define documentation showing how tests can link libpython without changing extension-module builds.

Written by the indexing model from the issue text.

Description

awaiting-response pyo3

We have a pyo3_extension target which builds a python extension module. As I understand it, this builds as if the extension-module feature is enabled so that the library does not link against python. But in some tests we would like to link against libpython so that tests can use pyo3 features such as PyResult. Is there any documentation about how to do this with rules_rust? In cargo we can disable the extension-module feature when running tests and everything works as expected. Is there a dependency I can get from a rules_python toolchain for example to link libpython into a particular rust_test target?

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

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.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.