Skip to content

Conversation

@JenniferWang
Copy link

Summary:

The Problem

Basically currently the monarch wheel cannot be installed by uv:

ImportError: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

Root Cause

The root cause is

  • monarch wheel is built in Conda environment with rpaths baked into the compiled .so files
  • uv installs Python in a different location (~/.local/share/uv/python/...), and therefore the baked-in paths don't exist in uv environments

Proper Fix

There are workaround for uv installation, e.g. set LD_LIBRARY_PATH to point to uv's Python library directory, but I think we should do a proper fix to the monarch build since ChatGPT said "Best practice is not to link extensions against libpython on Unix; the loader resolves Python symbols from the running interpreter. PyO3’s extension-module feature exists to avoid linking to libpython altogether. Manylinux guidance and PyO3 docs echo this." https://github.com/pypa/manylinux/issues/69?utm_source=chatgpt.com

This diff is an attempt to use extension-module feature and roughly does two things

  • Turn on the feature (in BUCK)
  • Remove the hardcoded rpath from setup.py

Appendix

Workaround by setting LD_LIBRARY_PATH

  1. Find your uv Python location:
uv run python -c "import sys; print(sys.executable)"
# Example output: /home/user/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/bin/python3.12
  1. Set LD_LIBRARY_PATH:
# For Python 3.12 (adjust version as needed)
export LD_LIBRARY_PATH="$HOME/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib:$LD_LIBRARY_PATH"

Differential Revision: D86537232

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 11, 2025

@JenniferWang has exported this pull request. If you are a Meta employee, you can view the originating Diff in D86537232.

Summary:

## The Problem
Basically currently the monarch wheel cannot be installed by `uv`:
```
ImportError: libpython3.10.so.1.0: cannot open shared object file: No such file or directory
```

## Root Cause
The root cause is 
- monarch wheel is built in Conda environment with rpaths baked into the compiled `.so` files
- `uv` installs Python in a different location (`~/.local/share/uv/python/...`), and therefore the baked-in paths don't exist in uv environments

## Proper Fix 
There are workaround for `uv` installation, e.g.  set `LD_LIBRARY_PATH` to point to `uv`'s Python library directory, but I think we should do a proper fix to the monarch build since ChatGPT said "Best practice is not to link extensions against libpython on Unix; the loader resolves Python symbols from the running interpreter. PyO3’s extension-module feature exists to avoid linking to libpython altogether. Manylinux guidance and PyO3 docs echo this." https://github.com/pypa/manylinux/issues/69?utm_source=chatgpt.com

This diff is an attempt to use ` extension-module` feature and roughly does two things
* Turn on the feature (in BUCK)
* Remove the hardcoded `rpath` from `setup.py`

-----
## Appendix

Workaround by setting `LD_LIBRARY_PATH`

1. Find your uv Python location:

```bash
uv run python -c "import sys; print(sys.executable)"
# Example output: /home/user/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/bin/python3.12
```

2. Set LD_LIBRARY_PATH:

```bash
# For Python 3.12 (adjust version as needed)
export LD_LIBRARY_PATH="$HOME/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib:$LD_LIBRARY_PATH"
```

Differential Revision: D86537232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant