Issue2360

classification
Title: Not installing pip on Jython
Type: Severity: urgent
Components: Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: darjus Nosy List: alex.gronholm, darjus, memoselyk, seletz, thavihaz909, zyasoft
Priority: urgent Keywords:

Created on 2015-05-27.20:23:37 by thavihaz909, last changed 2016-01-19.18:37:04 by zyasoft.

Messages
msg10084 (view) Author: Thavidu (thavihaz909) Date: 2015-05-27.20:23:37
jython, python, pip
msg10085 (view) Author: Thavidu (thavihaz909) Date: 2015-05-27.20:25:06
When I initially install Jython (with pip & Setup Tools selected) it gives me the following error at 90% completion of the installation. So pip & Setup Tools are not installed at the initial installation too.

Traceback (most recent call last):
  File "C:\jython2.7.0\Lib\runpy.py", line 161, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\jython2.7.0\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\jython2.7.0\Lib\ensurepip\__main__.py", line 4, in <module>
    ensurepip._main()
  File "C:\jython2.7.0\Lib\ensurepip\__init__.py", line 220, in _main
    bootstrap(
  File "C:\jython2.7.0\Lib\ensurepip\__init__.py", line 123, in bootstrap
    _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "C:\jython2.7.0\Lib\ensurepip\__init__.py", line 45, in _run_pip
    import pip
  File "C:\Users\thavihaz\AppData\Local\Temp\tmpen1gi_\pip-1.6-py2.py3-none-any.
whl\pip\__init__.py", line 10, in <module>
  File "C:\Users\thavihaz\AppData\Local\Temp\tmpen1gi_\pip-1.6-py2.py3-none-any.
whl\pip\util.py", line 17, in <module>
  File "C:\Users\thavihaz\AppData\Local\Temp\tmpen1gi_\pip-1.6-py2.py3-none-any.
whl\pip\locations.py", line 109, in <module>
  File "C:\Users\thavihaz\AppData\Local\Temp\tmpen1gi_\pip-1.6-py2.py3-none-any.
whl\pip\locations.py", line 90, in _get_build_prefix
AttributeError: 'module' object has no attribute 'geteuid'
msg10138 (view) Author: Alex Grönholm (alex.gronholm) Date: 2015-07-06.12:58:02
This is 2.7.0 final? It installed fine for me on Windows, setuptools and pip included. Can you try again and see if you can reproduce it?
msg10153 (view) Author: Stefan Eletzhofer (seletz) Date: 2015-07-16.14:38:34
So I believe this is a bug in the PIP package.  The code passage tries to check for ownership of the TEMP directory and uses os.getuid() which does
not exist on windows.
msg10154 (view) Author: Stefan Eletzhofer (seletz) Date: 2015-07-16.14:40:32
And yes, this is the final package.  Tried several times.  Get the same error consistently.

This used to work, I have a windows jython installation using the final package which HAS pip, upgrading that results in the same error.
msg10155 (view) Author: Stefan Eletzhofer (seletz) Date: 2015-07-16.14:51:17
Looking closer, it appears that  the culprit is sys.platform returning NOT "win32" on windows.  The offending code is skipped if sys.platform is "win32", and jython returns e.g. "java1.7.0_76"
msg10156 (view) Author: Stefan Eletzhofer (seletz) Date: 2015-07-16.14:59:06
Added a issue for this at the pypa pip repo:
https://github.com/pypa/pip/issues/2979

Will try to fix/patch/hack this to work :p
msg10157 (view) Author: Stefan Eletzhofer (seletz) Date: 2015-07-16.15:18:42
Ok the latest development branch does install cleanly on jython/windows.

It seems that the bundled versions are broken?
msg10329 (view) Author: Darjus Loktevic (darjus) Date: 2015-10-08.12:51:41
I believe the reason for this confusion/issue is the following commit:

➜  jython  hg log ./lib-python/2.7/ensurepip/__init__.py
changeset:   7528:e7afa7fd1e5b
user:        Jim Baker <jim.baker@rackspace.com>
date:        Tue Jan 13 00:28:38 2015 -0700
files:       CPythonLib.includes Lib/ensurepip/__init__.py Lib/ensurepip/_bundled/pip-1.6-py2.py3-none-any.whl Lib/ensurepip/_bundled/setuptools-11.3.1-py2.py3-none-any.whl Lib/test/test_support.py lib-python/2.7/ensurepip/__init__.py lib-python/2.7/ensurepip/__main__.py lib-python/2.7/ensurepip/_uninstall.py lib-python/2.7/test/_mock_backport.py lib-python/2.7/test/test_ensurepip.py
description:
Initial support for ensurepip module

Copies over ensurepip backport from CPython 2.7.9. The main
modification is that Jython needs modified wheels, with the wheels in
wheels in Lib/ensurepip/_bundle built as follows:

* setuptools from setuptools-11.3.1 release
* pip from https://github.com/jythontools/pip

To build wheels, build with ant using a clean release:

1. jython27 ez_setup.py
2. in checkout of https://github.com/jythontools/pip, jython27 setup.py install
3. in checkout of https://github.com/jythontools/wheel, jython27 setup.py install
4. copy output of jpip wheel of pip, setuptools into _bundle

Rebuild Jython and validate with jython27 -m ensurepip. This should be
automated!

This new support needs to be further tested (and likely debugged) on
Windows. Note that some of the tests in test_ensurepip are currently
failing.
msg10330 (view) Author: Jim Baker (zyasoft) Date: 2015-10-08.14:12:21
I don't know about intermediate steps on pip development, but using trunk/master for both pip and setuptools, I get the following with Jython trunk:

$ dist/bin/jython -m pip install pytest
Collecting pytest
/Users/jbaker/jythondev/jython27/dist/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:84: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  warnings.warn(
  Could not find a version that satisfies the requirement pytest (from versions: )
No matching distribution found for pytest
/Users/jbaker/jythondev/jython27/dist/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:84: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  warnings.warn(

which is because of our current lack of support of SSLContext, per bug #2390

The same issue also occurs if we attempt to upgrade pip, via jython -m pip install --upgrade pip


re the hg log posted in msg10329 - note that we have debugged on windows, which required getting support for jython.exe
msg10397 (view) Author: Jim Baker (zyasoft) Date: 2015-10-29.01:06:18
As of https://hg.python.org/jython/rev/b256a80cbbc5, we are using the latest pip (7.1.2) and setuptools (18.4) wheels and no longer use Jython-specific ones.

We need to further test, but this should be part of the release candidate testing of course.
msg10441 (view) Author: Darjus Loktevic (darjus) Date: 2015-11-08.22:52:03
Hey Jim,

Not sure for you, but for me pip no longer working because of the shebang:

➜  jython  head dist/bin/pip
#!"/usr/bin/env /Users/darjus/Documents/jython/dist/bin/jython"

the quotes eff it up.
msg10450 (view) Author: Jim Baker (zyasoft) Date: 2015-11-10.16:27:35
I'm pretty sure this is because you don't have bin/jython linked/copied to bin/jython.py

We should make this part of the standard ant build, not just in the installer.
msg10480 (view) Author: Jim Baker (zyasoft) Date: 2015-11-14.16:15:41
This is not fixed when used with the jython-installer.jar from all-jars (which is our most important product!). It's likely related to #2430. So yet another RC blocker, and almost certainly a minor patch in the bundled wheel, most likely setuptools. The usual suspect will be an os.name vs os._name problem.

Like #2430, we will need to get this upgraded in upstream if we want this to go away.
msg10514 (view) Author: memoselyk (memoselyk) Date: 2015-12-02.16:29:03
I have experienced this issue, these are my 2 cents:

IMHO, the error is triggered by two conditions:
 1. sys.platform returns "javaM.m.p_u". (that's the same than jython 2.5.2, so it might be ok)
 2. Something (probably `import pip`) when pip.exe is run creates a %TEMP%\pip_build_<username> folder, that raises an `OSError` in the `os.mkdir` because that temporary directory already exists.

To be able to solve this problem, we need to answer 2 questions:
 1. This is an issue with pip "1.6dev", are we still using that version? Message 10397, indicates that we are using a newer pip.
 2. If so, will this issue be fixed by preventing the temp folder for being created if pip is already installed, or by fixing the path the code takes take the True branch of the `if sys.platform == 'win32':` conditional.
msg10605 (view) Author: Darjus Loktevic (darjus) Date: 2016-01-07.23:58:53
Since nothing is happening with https://bitbucket.org/vinay.sajip/distlib/pull-requests/5

I have rebuilt latest pip with this change and now we again have modified version of pip in our ensurepip:
https://github.com/jythontools/jython/commit/0676eadbb68e749c165da815984823f50ca8dad2

Works on Mac OS X, but I'd love for someone to test on Windows.
msg10606 (view) Author: Alex Grönholm (alex.gronholm) Date: 2016-01-08.00:01:11
Last time I needed a PR to get through there I emailed Vinay. He responded fairly quickly and pulled my changes.
msg10608 (view) Author: Jim Baker (zyasoft) Date: 2016-01-08.03:25:51
Tried it on Windows 8 just now. The problem is that it installs bin\pip, not bin\pip.exe (like in 2.7.0) and it is a script instead of a self-executing archive that then links against jython.exe. I'm pretty sure this is one of those one-line fixes to make it happen.

So here's the content of bin\pip

#!c:\jython2.7.1b3\bin\jython.exe

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Too bad windows doesn't support shebang scripts!
msg10613 (view) Author: Darjus Loktevic (darjus) Date: 2016-01-10.07:58:24
Hey guys, I think I've fixed Windows support: https://github.com/jythontools/jython/commit/fcfdef9c78b0ba027b3c35875e984d50cd5432ca via https://bitbucket.org/vinay.sajip/distlib/pull-requests/5

But I've tried it by using wine not real Windows. Please try the latest and let me know if it solves the problem (or not).
msg10614 (view) Author: Jim Baker (zyasoft) Date: 2016-01-10.20:33:14
Verified working on Windows. See my comments on that PR (https://bitbucket.org/vinay.sajip/distlib/pull-requests/5).

Note that we still need to fix setuptools, so we can get the behavior of the patch again we had in #2298. Also in my comments in that PR.
msg10633 (view) Author: Darjus Loktevic (darjus) Date: 2016-01-11.12:35:20
Alright, i think i got a fix for setuptools: https://bitbucket.org/pypa/setuptools/pull-requests/169

Amazing is that Jython is getting better compat wise, I've removed much more code setuptools than added, hooray!
msg10638 (view) Author: Darjus Loktevic (darjus) Date: 2016-01-12.09:06:31
The fix for setuptools has been included: https://github.com/jythontools/jython/commit/a99bd0cf662d7eae22c88a6c06a931d2dbd09877
History
Date User Action Args
2016-01-19 18:37:04zyasoftsetstatus: pending -> closed
2016-01-12 09:06:32darjussetmessages: + msg10638
2016-01-11 12:35:21darjussetmessages: + msg10633
2016-01-10 20:33:15zyasoftsetmessages: + msg10614
2016-01-10 07:58:24darjussetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg10613
2016-01-08 03:25:52zyasoftsetmessages: + msg10608
2016-01-08 00:01:11alex.gronholmsetmessages: + msg10606
2016-01-07 23:58:54darjussetmessages: + msg10605
2015-12-30 00:03:15zyasoftsetmilestone: Jython 2.7.1
2015-12-02 16:29:04memoselyksetnosy: + memoselyk
messages: + msg10514
2015-11-14 16:15:41zyasoftsetstatus: pending -> open
priority: urgent
messages: + msg10480
resolution: accepted
severity: normal -> urgent
2015-11-10 16:27:35zyasoftsetmessages: + msg10450
2015-11-08 22:52:04darjussetresolution: fixed -> (no value)
messages: + msg10441
2015-10-29 01:06:18zyasoftsetstatus: open -> pending
resolution: fixed
messages: + msg10397
2015-10-08 14:12:21zyasoftsetnosy: + zyasoft
messages: + msg10330
2015-10-08 12:51:42darjussetassignee: darjus
messages: + msg10329
nosy: + darjus
2015-07-16 15:18:43seletzsetmessages: + msg10157
2015-07-16 14:59:07seletzsetmessages: + msg10156
2015-07-16 14:51:18seletzsetmessages: + msg10155
2015-07-16 14:40:33seletzsetmessages: + msg10154
2015-07-16 14:38:35seletzsetnosy: + seletz
messages: + msg10153
2015-07-06 12:58:02alex.gronholmsetnosy: + alex.gronholm
messages: + msg10138
2015-05-27 20:25:06thavihaz909setmessages: + msg10085
2015-05-27 20:23:37thavihaz909create