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

Best Practices for integrating uv with PYTHONPATH #10948

Open
ClarkMyWords opened this issue Jan 24, 2025 · 0 comments
Open

Best Practices for integrating uv with PYTHONPATH #10948

ClarkMyWords opened this issue Jan 24, 2025 · 0 comments
Labels
question Asking for clarification or support

Comments

@ClarkMyWords
Copy link

ClarkMyWords commented Jan 24, 2025

Question

Hello,

I'm working with ROS 2 Humble, largely in Python. I'm managing an environment for a few users, and I've chosen uv as our scheme for managing virtual environments.

ROS 2 can respect Python virtual environments, but it relies on whatever is set in PYTHONPATH for those. At the moment, I am having to manually set it as such:
export PYTHONPATH=$PYTHONPATH:$VIRTUAL_ENV/lib/python3.10/site-packages

From this issue I understand that this isn't really functionallity in uv's wheelhouse, but I'm wondering if there's a reasonable way in uv to create some sort of hook that, after sourcing .venv/bin/activate, will add anything added by that venv to the PYTHONPATH? (Bonus points if this would also work for something installed via uv pip install -e ... because that doesn't place the editable package in the site-packages directory (for obvious reasons)).

I see that for something like uv run ... the --env-file argument could work, but, because of the constraints of my project, I'm using uv only for the virtual environment management, not for actually running anything.

Or, possibly, if there is any other wisdom or best-practices to dynamically set my PYTHONPATH with uv.

Thanks!

Platform

Ubuntu 22.04.5 LTS x86_64

Version

uv 0.5.24 (42fae92 2025-01-23)

@ClarkMyWords ClarkMyWords added the question Asking for clarification or support label Jan 24, 2025
@ClarkMyWords ClarkMyWords reopened this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

1 participant