classification
Title: wrong default module search path in help message
Type: behavior Stage: patch review
Components: Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, eric.snow, eryksun, gauravbackback, steve.dower, xiang.zhang, zach.ware
Priority: normal Keywords: easy, patch

Created on 2017-09-13 08:01 by xiang.zhang, last changed 2017-09-18 18:50 by steve.dower.

Pull Requests
URL Status Linked Edit
PR 3624 open gauravbackback, 2017-09-17 06:10
Messages (5)
msg302032 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-09-13 08:01
In python --help:

PYTHONHOME   : alternate <prefix> directory (or <prefix>:<exec_prefix>).
               The default module search path uses <prefix>/pythonX.X.

I think the default module search path should be <prefix>/lib/pythonX.X.
msg302338 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-09-16 13:48
You are right, the path is wrong on Unix-like platforms. It's os.path.join(sys.prefix, 'lib', 'python{major}.{minor}'). But the actual path may depend on the platform, too. I don't recall how Windows sets up the path.
msg302339 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-09-16 13:51
See site module, especially site._get_path()

# Same to sysconfig.get_path('purelib', os.name+'_user')
def _get_path(userbase):
    version = sys.version_info

    if os.name == 'nt':
        return f'{userbase}\\Python{version[0]}{version[1]}\\site-packages'

    if sys.platform == 'darwin' and sys._framework:
        return f'{userbase}/lib/python/site-packages'

    return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
msg302361 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-09-17 08:05
Not sure about Windows. _get_path() looks to me is used for user site-packages. getsitepackages() doesn't do the same and seems matching the current message, also the OS2 branch in py2. Let's consult Windows guys.
msg302480 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-09-18 18:50
I don't have time right this second to write it all up, but I did so in the past at https://docs.python.org/3/using/windows.html#finding-modules

Hopefully the answer you need is somewhere in that. Module search paths are complicated (but eric.snow is going to make it possible to use Python code to derive the search path at startup... right Eric? Right? :) )
History
Date User Action Args
2017-09-18 18:50:00steve.dowersetnosy: + eric.snow
messages: + msg302480
2017-09-17 08:05:45xiang.zhangsetnosy: + zach.ware, eryksun, steve.dower, gauravbackback
messages: + msg302361
2017-09-17 06:10:04gauravbackbacksetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request3614
2017-09-16 13:51:15christian.heimessetmessages: + msg302339
2017-09-16 13:48:11christian.heimessettype: behavior

messages: + msg302338
nosy: + christian.heimes
2017-09-13 08:01:11xiang.zhangcreate