Skip to content

Find pip-compile in global path if it does not exist in venv #114

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

furushchev
Copy link
Contributor

@furushchev furushchev commented Feb 14, 2025

This PR modifies the script to locate and execute pip-compile from the global path if it is not found within the current virtual environment.

Currently, the script assumes that pip-compile is installed within the activated virtual environment. However, users may have pip-compile installed globally and installer does not install the pip-tools to the venv space in the case [1].

This change allows the script to search for `pip-compile in the system's PATH if it's not found in the virtual environment's bin directory.

[1] Such users will see the error:

Traceback (most recent call last):
  File "/home/furushchev/catkin_ws/devel/lib/catkin_virtualenv/venv_lock", line 15, in <module>
    exec(compile(fh.read(), python_script, 'exec'), context)
  File "/home/furushchev/catkin_ws/src/catkin_virtualenv/catkin_virtualenv/scripts/venv_lock", line 47, in <module>
    venv.lock(
  File "/home/furushchev/catkin_ws/src/catkin_virtualenv/catkin_virtualenv/src/catkin_virtualenv/venv.py", line 159, in lock
    pip_compile = self._venv_bin("pip-compile")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/furushchev/catkin_ws/src/catkin_virtualenv/catkin_virtualenv/src/catkin_virtualenv/venv.py", line 195, in _venv_bin
    raise RuntimeError("Binary {} not found in venv".format(binary_name))
RuntimeError: Binary pip-compile not found in venv
make[2]: *** [CMakeFiles/sound_classification_generate_virtualenv.dir/build.make:97: /home/furushchev/catkin_ws/src/jsk_recognition/sound_classification/requirements.txt] Error 1
make[1]: *** [CMakeFiles/Makefile2:788: CMakeFiles/sound_classification_generate_virtualenv.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
$ locate pip-compile 
/usr/local/bin/pip-compile

@furushchev
Copy link
Contributor Author

Just rebased origin/master.

@furushchev
Copy link
Contributor Author

@paulbovbel Thank you for your review. Please let me know if there is any problem or further comment!

@furushchev
Copy link
Contributor Author

@paulbovbel Hello! Is there any chance to get this PR merged soon?

@furushchev
Copy link
Contributor Author

@paulbovbel Hello! Can you please merge this and release this package as the EOL of the ROS1 is coming soon 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants