-
Notifications
You must be signed in to change notification settings - Fork 170
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
Check for pip configuration when an externally managed environment is detected. #979
Conversation
rosdep is designed to treat pip like an alternative system-level package manager. Deviating from this approach is not easily achievable without a significant rethinking of how pip packages are managed. In the meantime, we can at least instruct users how to restore the prior functionality. Rather than inject the environment variable / config on behalf of the user, this change instructs them to make the necessary config changes themself, keeping them informed of the change their making to the system's new default.
In addition to the test failures, this actually doesn't work as intended because |
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/rosdep-for-pip-is-broken-on-jazzy/38981/5 |
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
As of 2c76686 the installer is configured to pass |
The fallback configuration was over-indented and would never be checked.
PIP_BREAK_SYSTEM_PACKAGES=1 | ||
in your environment. | ||
|
||
For more information refer to http://docs.ros.org/en/independent/api/rosdep/html/pip_and_pep_668.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this documentation won't actually be live until the PR is merged and docs rebuild the next day. This will only affect those using rosdep from mainline or this branch. I'll wait until the docs rebuild to make a new rosdep release with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments!
Use monospace formatting when referring to the `rosdep` command / executable name and simply 'rosdep' when referring to the project. The preferred capitalization of rosdep is rosdep not Rosdep or ROSdep (and certainly not ROSDep).
fe8eb73
to
f8472d2
Compare
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
This is a fixup after two earlier changes inverted the conditional and reformatted an internal check.
from rosdep2 import InstallFailed | ||
from rosdep2.platforms.pip import EXTERNALLY_MANAGED_EXPLAINER, PipInstaller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super up on why imports are done per test function here but I am propagating the convention until I understand it better.
try: | ||
installer.get_install_command(['whatever']) | ||
assert False, 'should have raised' | ||
except InstallFailed as e: | ||
assert e.failures == [('pip', EXTERNALLY_MANAGED_EXPLAINER)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want, a more Pythonic way could be:
try: | |
installer.get_install_command(['whatever']) | |
assert False, 'should have raised' | |
except InstallFailed as e: | |
assert e.failures == [('pip', EXTERNALLY_MANAGED_EXPLAINER)] | |
with pytest.raises(InstallFailed) as exception_info: | |
installer.get_install_command(['whatever']) | |
assert exception_info.value.failures == [('pip', EXTERNALLY_MANAGED_EXPLAINER)] |
and make sure to import pytest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I'm actually going to keep this as is for now, because I don't believe the infrastructure packages ever explicitly require pytest. I think pytest is supposed to be compatible with stdlib unittest as well and utilizing that may be the preferred approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from my last minor suggestions, this looks good to me!
Using the dict access method will raise a KeyError when the config file is present but this section or value is missing.
rosdep is designed to treat pip like an alternative system-level package manager. Deviating from this approach is not easily achievable without a significant rethinking of how pip packages are managed. In the meantime, we can at least instruct users how to restore the prior functionality.
Rather than inject the environment variable / config on behalf of the user, this change instructs them to make the necessary config changes themself, keeping them informed of the change their making to the system's new default.
I added a documentation page specific to this issue with additional configuration details and recipes for CI.
Seeks to reduce friction related to #978