robocup-software icon indicating copy to clipboard operation
robocup-software copied to clipboard

Added Python venv to ubuntu-setup

Open fourpenny opened this issue 2 years ago • 5 comments

Description

The util/ubuntu-setup script now creates a Python virtual environment (rj_env) and uses it for installing our repo's Python packages

  • Helps prevent causing problems in users' global Python installation
  • Virtual environment is added to the $PYTHONPATH variable and can be used when calling our build script without additional flags/arguments

Steps to Test

  1. Run ubuntu-setup script
  2. Build soccer
  3. Run soccer (will need to activate the virtual environment with an additional command first: source rj_env/bin/activate)

It might be good for me to add that last one to the existing README in the launch instructions- I'll do that as long as this works for everyone else.

Expected result: Soccer and sim should launch without problems using packages from the virtual environment

Key Files to Review

  • util/ubuntu-setup

fourpenny avatar Aug 17 '22 20:08 fourpenny

Looks like this PR causes our CI/CD scripts to fail since they create new virtual environments by default... is that accurate?

fourpenny avatar Aug 17 '22 20:08 fourpenny

@fourpenny the reason our CI fails seems to be that we don't have python3-venv as a dependency:

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/__w/robocup-software/rj_env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

Error: Process completed with exit code 1.

Do you mind adding that in the python3/pip3 dependency list? If the build-and-test check works then that means your changes to ubuntu-setup should work on any Ubuntu 20.04 machine.

kfu02 avatar Aug 18 '22 03:08 kfu02

@kfu02

Added it to the requirements3.txt file. Anywhere else it needs to go? (Do I need to modify anything for the Dockerfiles that are used for the CI.yml file?)

fourpenny avatar Aug 18 '22 18:08 fourpenny

@fourpenny nvm, it seems I've led you astray. Take the python3-venv out of requirements3.txt and try this instead

(the tests still fail since it's expecting to have access to a venv before installing the packages in requirements3.txt)

kfu02 avatar Aug 18 '22 19:08 kfu02

@kfu02 I'm still working on getting venv properly installed on the CI container- but something else: the default public for key is wrong about 50% (or more) of the time (see this GitHub issues post: https://github.com/ros2/ros2/issues/742) when downloading and installing Foxy during our current CI script. Do you want me to try to add a fix?

fourpenny avatar Aug 19 '22 20:08 fourpenny