[Distutils] pythonv, take two

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue Mar 29 15:45:50 CEST 2011


Carl Meyer <carl <at> oddbird.net> writes:

> Thanks for the additional digging in here. I think your analysis is
> right - it actually occurred to me yesterday that this could be the
> problem, and I filed a bug to track it here:

> 3. The fully-reliable fix would be to somehow give the copied binary a
> hint where to find the right standard library, and this would involve
> adding something to the algorithm in getpath.c. The hint could take the
> form of a key in the config file, but I'd really like to avoid fully
> parsing the config-file in C and then again in Python later on. The hint
> could also be some kind of specially-formatted comment line at the top
> of the config file, which would require less C code to find and parse?
> 
> Any thoughts on this (or alternative solutions I haven't thought of) are
> most welcome.
> 

Hi Carl,

I've been thinking about the C-level configuration some more (cpythonv issue
#6). Suppose we have a virtual env at absolute path <testenv>, and in
<testenv>/bin we have a copied, non-installed Python, obtained from absolute
path <pythonsrc>. Say we provide the location of the source in the
configuration, and that this is read in getpath.c. Logically, it should just
replace the argv0_path value, and if the subsequent logic is unchanged, at the
point that site.py's main() runs,  you would have (on Linux i686):

sys.prefix, sys.exec_prefix would have values set from the configure script
('/usr/local' by default).
sys.path would be ['/usr/local/lib/python33.zip', '<pythonsrc>/Lib',
'<pythonsrc>/Lib/plat-linux2', '<pythonsrc>/build/lib.linux-i686-3.3']

which seems OK.

If a virtual environment is in absolute path <testenv>, then after the call to
virtualize() in site.py, we would have sys.prefix and sys.exec_prefix both set
to <testenv>. Since sys.executable still points to <testenv>/bin, the code in
sysconfig.py appears not to be doing the right thing, e.g.
sysconfig._PROJECT_BASE would be <testenv>/bin, which seems wrong.

So it seems as if site.py and/or sysconfig.py might need further changes, as
well as changes to getpath.c. What do you think?

Regards,

Vinay Sajip



More information about the Distutils-SIG mailing list