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

Adding --system option to pip (Linux Mint problem) #836

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mu/interface/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def run_pip(self):
text area.
"""
package = self.to_add.pop()
args = ['-m', 'pip', 'install', package, '--target',
args = ['-m', 'pip', 'install', package, '--system', '--target',
Copy link
Member

Choose a reason for hiding this comment

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

Based on pypa/pip#3826 it sounds like this is a debian specific flag patched into pip, is that right?
If that is the case and we run this in any other platform this is likely going to return an error. In macOS:

$ pip install requests --system
Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

no such option: --system

Copy link
Author

Choose a reason for hiding this comment

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

Look at:
#822

maybe...
'''
f = open("/etc/lsb-release",'r')

f.readlines()

['DISTRIB_ID=LinuxMint\n',
'DISTRIB_RELEASE=19\n',
'DISTRIB_CODENAME=tara\n',
'DISTRIB_DESCRIPTION="FREE_DESKTOP_2019.004c"\n']
'''
and check DISTRIB_ID against 'Debian/Ubuntu/LinuxMint/....' ?
And then add --system flag ?
I can make function like debian_detect() which returns True if it will be Debian or other... and then we could add --system to pip. I know, this will be "a hack', but I cannot see any other way to make it works.

Copy link
Member

@carlosperate carlosperate May 12, 2019

Choose a reason for hiding this comment

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

But do we understand the original problem? Perhaps there is a different workaround or fix.

The issue linked inside #822 is about mixing the target and user flags in pip, which is not being done in this file. Is it possible the user flag is being added somewhere else?

Copy link
Author

Choose a reason for hiding this comment

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

As I investigated the problem, in Debian's based distros the only way to install libs using pip in users directory (via --target) is when you use --system option. And the only place I found in source is : @@ -447,7 +447,7 @@ def run_pip(self): - so i decided to place my --system there.

Copy link
Member

Choose a reason for hiding this comment

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

But the --system flag has been added by debian to pip as a patch to install the package in the "system python directory", which is the opposite of what Mu should be doing, as it needs to install the package in a special location.

Based on your error output in #822 it looks like the problem here could be that somehow the final command executed includes both the flags user and target:

File "/usr/lib/python3.6/distutils/command/install.py", line 274, in finalize_options
raise DistutilsOptionError("can't combine user with prefix, "
distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

In this case the user flag will try to install the package in the user home directory (not good), and the target flag will try to install it in the location indicated by Mu (good, but contradictory to the other flag). Because of this, the system flag "fixes" the problem by "cancelling out" the user flag.

However, if this is the case, where is the user flag coming from? I think that's the thing we need to figure out.

Copy link

Choose a reason for hiding this comment

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

Hi, I manage to find a pip.conf file inside .pip folder in my home directory. It has a parameter "user=true" in it. When I changed this parameter to false, I could finally use the -t option on pip.

Copy link
Member

Choose a reason for hiding this comment

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

Good find @Saziba!
Were you installing packages with the default Mu installation, or did you edit the source code as well?

self.module_dir]
self.process = QProcess(self)
self.process.setProcessChannelMode(QProcess.MergedChannels)
Expand Down