On 18 Jul, 2011, at 19:15, Vinay Sajip wrote:

> I'm working on pythonv[1], a branch which aims to bring virtual environment
> creation functionality into Python itself (work on a PEP is in progress).
> 
> I've got a prototype working quite well on Linux and Windows [2], but not yet
> done any work on OS X.
> 
> The basic approach used is that the Python start up code (in getpath.c) looks
> at sys.executable and then for a configuration file env.cfg either in the
> executable's directory or one level up, and then for a line in env.cfg of the
> type
> 
> home = /path/to/python
> 
> If the file with that name and line are found, the home value sets sys.prefix
> and sys.exec_prefix, and then later on, code in site.py sets up the virtual
> environment.

I'm not sure if I like this approach, I'll read the PEP before I start 
discussing that though. One thing I want to mention beforehand: why is the file 
named 'env.cfg' instead of something starting with 'py'?  The latter is basicly 
namespacing the filename and avoids clashes with other software (although I 
don't know of any software that uses an env.cfg file).

> 
> Because of the use of sys.executable, at present pythonv makes a copy of the
> executable (and, on Windows, all DLLs) in the environment's binaries folder.
> 
> My question is, will this approach work on OS X? I can't readily build and 
> test
> on an OS X system at the moment, so I'm hoping someone can enlighten me. If a
> python executable file has sys.prefix/sys.exec_prefix pointing to a framework
> build's location, will that give the virtual environment everything it needs
> to e.g. interface to Cocoa etc? Or does any other setup need to be done?

This should work fine with a framework build, with two caveats:

1) bin/python in a framework build is not the interpreter, but a stub 
executable. The script that creates the virtual environment should copy the 
executable in Resources/Python.app/MacOS instead.   bin/python just execv-s the 
real interpreter.

2) accessing GUI functionality requires that the executable is located in an 
.app bundle, that's  why bin/python is a stub.

The latter point means that virualenvs will be slightly less functional than 
the framework install there based on unless you add more OSX specific code.  It 
should be fairly easy to get this to work though, basicly create a Python.app 
in a hidden folder in the virtualenv and copy the real interpreter into that, 
then add a bin/python that execv's that hidden Python.app.

Ronald


> 
> Thanks and regards,
> 
> Vinay Sajip
> 
> [1] https://bitbucket.org/vinay.sajip/pythonv/
> [2] http://www.red-dove.com/screencasts/pythonv/pythonv.html
> 
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to