This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: What should happen if someone runs ./python -m ensurepip in the build environment?
Type: Stage:
Components: Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dstufft, ncoghlan, ned.deily, r.david.murray
Priority: normal Keywords:

Created on 2013-12-26 17:25 by r.david.murray, last changed 2022-04-11 14:57 by admin.

Messages (3)
msg206948 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-12-26 17:25
Someone on IRC reported doing this, and it (logically enough) gave a permission error trying to install into /opt.  That may be exactly what it should do...but if he'd done it as root, presumably it would have tried to install PIP without python having been installed first, which might be wrong.

(Donald says it would indeed install it, creating the directories as needed.)
msg226573 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-09-08 11:47
The whole sys.path initialisation scheme is pretty broken when running from a source checkout, so the short answer is "it won't work, and it isn't really fixable in a maintenance release".

System Python 3:

sys.path = [
    '/home/ncoghlan/devel/py3k',
    '/usr/lib64/python33.zip',
    '/usr/lib64/python3.3',
    '/usr/lib64/python3.3/plat-linux',
    '/usr/lib64/python3.3/lib-dynload',
    '/home/ncoghlan/.local/lib/python3.3/site-packages',
    '/usr/lib64/python3.3/site-packages',
    '/usr/lib/python3.3/site-packages',
]

My source checkout:

sys.path = [
    '/home/ncoghlan/devel/py3k',
    '/usr/local/lib/python35.zip',
    '/home/ncoghlan/devel/py3k/Lib',
    '/home/ncoghlan/devel/py3k/Lib/plat-linux', 
    '/home/ncoghlan/devel/py3k/build/lib.linux-x86_64-3.5',
    '/home/ncoghlan/devel/py3k/Modules',                
    '/home/ncoghlan/.local/lib/python3.5/site-packages',
]                                                                                                                

We should probably have an explicit check for that in ensurepip so it bails out as an unsupported operation rather than doing something weird. Looking in sys.path for "os.path.join(os.path.dirname(sys.executable), 'Lib')" should be a fairly reliable indicator that we're running from a source checkout.

Actually *fixing* it to do something sensible would require a lot of work on the sys.path initialisation code, and I frankly consider that impractical given the current state of getpath.c.
msg226574 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-09-08 11:51
Note that if I find time to implement the startup sequence redesign for PEP 432/issue #22257 (which is finally starting to look like it may actually happen some time in the next few months), a proper fix may end up being possible for 3.5.

We shouldn't bet on that, though, and the explicit failure is definitely the best we'll be able to do for 3.4 and the 2.7 backport.
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64270
2014-09-08 11:51:44ncoghlansetmessages: + msg226574
2014-09-08 11:47:39ncoghlansetmessages: + msg226573
2014-09-08 08:31:22ned.deilysetnosy: + ncoghlan, ned.deily, dstufft

versions: + Python 2.7, Python 3.4, Python 3.5
2013-12-26 17:25:26r.david.murraycreate