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

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

wants to merge 3 commits into from

Conversation

abixadamj
Copy link

There is a problem with adding local libraries for user on Linux Mint - I have created issue: #822 - this is a solution.

Copy link
Member

@carlosperate carlosperate left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @abixadamj.
If the system flag only works on debian based distros I think the flag should only be added in those platforms.
Do you know if there is any other workaround that is not so platform specific? Or do you know what causes the problem exactly?

mu/__init__.py Outdated
@@ -8,7 +8,7 @@
localedir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'locale'))
language_code = QLocale.system().name()
# DEBUG/TRANSLATE: override the language code here (e.g. to Chinese).
# language_code = 'zh'
# language_code = 'pl'
Copy link
Member

Choose a reason for hiding this comment

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

To reduce the diff it would be good to revert this change.

Copy link
Author

Choose a reason for hiding this comment

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

I'am trying, I'm not a git master ;-)

Copy link
Author

Choose a reason for hiding this comment

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

I have made revert - 2eaba0f
But I do not know what to do next. When I do pull request I see:
image

Copy link
Member

Choose a reason for hiding this comment

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

That's good, the final diff is only the new flag stuff, so we can always merge and squash to have compress all the final changes into a single commit.

@@ -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?

mu/locale/pl/LC_MESSAGES/mu.po Outdated Show resolved Hide resolved
@carlosperate
Copy link
Member

Because there has been wide changes to the user python environment (using virtual environments for running the user code with Mu), I believe this will no longer be a problem, as now the user venv should not be using the system pip.

Thank you very much for working through this issue and all the stellar debugging!

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

Successfully merging this pull request may close these issues.

3 participants