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

Python virtual environment #3305

Merged
merged 6 commits into from
Oct 14, 2024
Merged

Python virtual environment #3305

merged 6 commits into from
Oct 14, 2024

Conversation

Fabien-B
Copy link
Contributor

I propose to ease the use of a python virtual environment.
It will allow a much more clear python dependencies management.

I did not integrate it in the Makefile to allow testing it without risking breaking anything.

To use it, create en venv: python3 setup.py
Then source pprzEnv/bin/activate.
It can be done in your .bashrc: source $PAPARAZZI_HOME/pprzEnv/bin/activate

What are you though on that PR ?

@dewagter
Copy link
Member

@Fabien-B looks like a good idea because more and more people have python conflicts. However, in the current version it looks like you need quite some manual work to get things working. Can that be improved? It would also (temporary) make switching branches quite hard doesn't it?

@Fabien-B
Copy link
Contributor Author

Fabien-B commented Jun 14, 2024

@dewagter I don't think a 2 step process that you only have to do once is "quite some manual work" 😃 .
It can be added to the makefile, but it's maybe best to have some return on experience before doing that.
The venv files are not tracked by git, so there is absolutely no problem switching branches.
The only annoying thing is that on a branch where the .gitignore have not been updated, git will show all venv files as "untracked". But it's the only issue I can see.

dewagter
dewagter previously approved these changes Jun 14, 2024
Copy link
Member

@dewagter dewagter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, it would be added to the install.sh script. And it would need some communication.

@Fabien-B
Copy link
Contributor Author

Something like this: a04674b ?

@dewagter
Copy link
Member

dewagter commented Jun 15, 2024

Something like this: a04674b ?

Great! Thanks a lot!
PS: Can this be run several times, or will keep adding bash variables?

dewagter
dewagter previously approved these changes Jun 15, 2024
Copy link
Member

@dewagter dewagter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the install-window can be opened several times.

dewagter
dewagter previously approved these changes Jun 17, 2024
@Fabien-B
Copy link
Contributor Author

I added a guard to prevent creating the venv from itself (which can't be done), and adding the source to the .bashrc.
However, if the venv is deactivated, it is still possible to add the source multiple times in .bashrc.
As this is optional, defaulting to false, and harmless anyway, I would argue this is a reasonable compromise.

@Fabien-B
Copy link
Contributor Author

Rebased on master

@Fabien-B
Copy link
Contributor Author

@dewagter If it's ok for you, I replaced lsb_release by distro in the install script because lsb_release is not installable from pypi.
It works pretty much the same.

@dewagter
Copy link
Member

@dewagter If it's ok for you, I replaced lsb_release by distro in the install script because lsb_release is not installable from pypi. It works pretty much the same.

OK for me. I would just like the script to adapt to the distribution. For me, a project should be installed with git clone CODE followed by and by install without needing a full WIKI to survive.

@Fabien-B
Copy link
Contributor Author

Fabien-B commented Oct 3, 2024

Can we merge this ?

@dewagter
Copy link
Member

dewagter commented Oct 9, 2024

Yes

dewagter
dewagter previously approved these changes Oct 9, 2024
@gautierhattenberger
Copy link
Member

The pprzlink ref should be fixed first. Otherwise I'm okay with this.

@Fabien-B Fabien-B merged commit 32074c9 into master Oct 14, 2024
1 check passed
@Fabien-B Fabien-B deleted the python_env branch October 14, 2024 13:02
NoahWe pushed a commit to tudelft/paparazzi that referenced this pull request Nov 5, 2024
* [python] setup venv and update pprzlink.
* [supervision] open terminal in the venv if it exists.
* clean setup.py
* guard venv boostrap
* [install] Use distro instead of lsb_release.

---------

Co-authored-by: Fabien-B <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants