xgo-dev / xgo-dev/llgo

Support virtual environment for Python

Open
#940 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

llgo-only proposal
Dominant language
LLVM
Stars
758
Forks
49
Avg merge
1d 6h
Merged PRs (30d)
138

Description

LLGo uses pkg-config to look up python lib path, however, when user is in virtual environment, the pkg-config result may not be acurate.

Example:
There's multi python version in my laptop.
Main: Python 3.13
Conda: Python 3.12.

The pkg-config result:

(base) matrix % pkg-config --libs  python3-embed
-L/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib 

After i switch environment:

(llgo)  matrix % pkg-config --libs  python3-embed 
-L/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib

It remains the same.

Even though some python virtual enviroment like Conda provides PC file for pkg-config, we cannot confirm users' virtual enviroment installation path, thus, it's hard to get the real python lib path from pkg-config.

The easy solution is that using python command to get it, like that:

python -c "import os; print('-L%s' % os.path.dirname(os.path.dirname(os.__file__)));"

Contributor guide

No contributing guide indexed for this repository

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 locating the Python library path lookup that currently invokes pkg-config for python3-embed. Compare its result with the active environment's python command, then verify the lookup uses the selected virtual environment rather than the system installation when switching between Python versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.