-
Notifications
You must be signed in to change notification settings - Fork 180
Fix: pip support, especially pip10 (#657) #661
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
Conversation
@@ -1448,8 +1448,8 @@ def check_requirements(self, show_warning=False): | |||
missing = [] | |||
try: | |||
with open(os.path.join(req_path, req_file), 'r') as f: | |||
import pip | |||
installed_packages = [re.sub(r'-', '_', package.project_name.lower()) for package in pip.get_installed_distributions(local_only=True)] | |||
pkg_list = pquery([python_cmd, '-m', 'pip', 'list', '-l']) or "" |
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.
please note that -l
is a deprecated option
it produces following warning:
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
consider using --format=legacy
or --format=column
instead
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.
@alzix pip list -l
is for listing the locally installed python modules. -l, --local If in a virtualenv that has global access, do not list globally-installed packages.
(pressed Ctrl+Enter by accident)
The problem with using --format=legacy
is that it's not backwards compatible with pip < 10, so we can't use it either 😃
$ pip --version
pip 8.1.2 from /Library/Python/2.7/site-packages (python 2.7)
$ pip list -l --format=legacy
Usage:
pip list [options]
no such option: --format
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 think we're going to either have to live with the deprecation warning, or add pip 10 as a dependency.
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've also tried forcing the columns format using the --format=columns
option and the code above is handling it just fine:
[snip]
pkg_list = pquery([python_cmd, '-m', 'pip', 'list', '-l', '--format=columns']) or ""
[snip]
$ pip uninstall pyyaml
Uninstalling PyYAML-3.12:
Would remove:
c:\progra~1\python\lib\site-packages\pyyaml-3.12-py2.7.egg-info
c:\progra~1\python\lib\site-packages\yaml\*
Proceed (y/n)?
Your response ('') was not one of the expected responses: y, n
Proceed (y/n)? y
Successfully uninstalled PyYAML-3.12
$ mbed update --clean
[mbed] Synchronizing dependency references...
[mbed] Updating program "mbed-os-example-wifi" to latest revision in the current branch
[mbed] Updating library "esp8266-driver" to rev #264468722a97
[mbed] Updating library "mbed-os" to rev #c05d72c3c005 (tag: mbed-os-5.8.3)
[mbed] Updating library "wifi-x-nucleo-idw01m1" to rev #5871f7011d7f
[mbed] Auto-installing missing Python modules...
$ pip list | grep -i pyyaml
PyYAML 3.12
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 think you're suggesting that we don't need to worry about the deprecation warning. That's how I took it at least.
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.
Yes, exactly. Sorry that I didn't explicitly said it. Was writing this in between meetings 😀
i'm sorry for the confusion about the '-l/--local' but i vote for adding |
@alzix That would break the backwards compatibility with pip < 10. Where do you see the warning? When using mbed CLI or when using pip? I'm not seeing any warnings on Windows with pip 10.0.1 |
@alzix @theotherjimmy Note that this is now breaking the CI. |
@screamerbg I see the deprecation warning on pip 9.0.3 Linux |
@alzix I don't get any warnings from pip 9.0.3 on Mac when using mbed CLI.
I only get a warning when directly calling pip
|
@alzix I think @screamerbg is asking if you see the warning when using Mbed CLI from this branch. I don't see the warning on Linux with this branch and any version of Pip (I tried 9.0.3 and 10.0.1). |
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.
LGTM!
Thanks. Just fixed the CI issue caused by faulty pip module; |
pip.get_installed_distributions()
is no longer available in pip 10. This PR fixes this by using the user-facing commands of pip and ensure future and backwards compatibility.Also bumps Mbed CLI version to 1.5.1