[Python-Dev] Existence of pythonNN.zip in sys.path

2014-05-05 Thread Anthony Tuininga
Hi,

I am the author of cx_Freeze which creates "frozen" executables from Python
scripts. To this point I have been using frozen modules (compiled C) but
this has the side effect of bundling parts of Python with a cx_Freeze
release -- and this has bitten me on a number of occasions when newer
versions of Python use slightly incompatible modules. :-)

By scanning the code I discovered that Python automatically searches on
startup

/lib/pythonNN.zip

where NN is replaced by the major and minor version that is being executed.
Using this would allow me to ensure that bootstrap modules are not bundled
with cx_Freeze but acquired from the distribution that is actually using it
-- thereby eliminating the hassle noted above.

I have tested this approach and found it works flawlessly. There is,
however, no documentation that I can find for the contents of sys.path --
the documentation simply says that it is an installation default and
doesn't specify what that default is.

So my question is: can I safely make use of this "feature"? It has remained
in place since at least Python 2.6 but I don't want to assume anything.
Please advise! Thanks.

Anthony
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Existence of pythonNN.zip in sys.path

2014-05-05 Thread Anthony Tuininga
On Mon, May 5, 2014 at 3:50 PM, Paul Moore  wrote:

> On 5 May 2014 22:32, Anthony Tuininga  wrote:
> > So my question is: can I safely make use of this "feature"? It has
> remained
> > in place since at least Python 2.6 but I don't want to assume anything.
> > Please advise! Thanks.
>
> I believe this is a 100% supported feature of Python (since 2.6, as
> you mention). Some of the zip import/run features have unfortunately
> been underdocumented, and I suspect that this is simply one of those.
>
> Paul
>

That's great news. Thanks!

Anthony
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Existence of pythonNN.zip in sys.path

2014-05-05 Thread Anthony Tuininga
Thanks. I think I can live with that restriction. :-) I do not read/write
to the same zip file in the same process.

Anthony


On Mon, May 5, 2014 at 4:10 PM, Gregory P. Smith  wrote:

>
> On Mon, May 5, 2014 at 2:52 PM, Anthony Tuininga <
> anthony.tuini...@gmail.com> wrote:
>
>> On Mon, May 5, 2014 at 3:50 PM, Paul Moore  wrote:
>>
>>> On 5 May 2014 22:32, Anthony Tuininga 
>>> wrote:
>>> > So my question is: can I safely make use of this "feature"? It has
>>> remained
>>> > in place since at least Python 2.6 but I don't want to assume anything.
>>> > Please advise! Thanks.
>>>
>>> I believe this is a 100% supported feature of Python (since 2.6, as
>>> you mention). Some of the zip import/run features have unfortunately
>>> been underdocumented, and I suspect that this is simply one of those.
>>>
>>> Paul
>>>
>>
>> That's great news. Thanks!
>>
>> Anthony
>>
>
> There is at least one caveat to using a .zip file for the standard
> library: http://bugs.python.org/issue19081
>
> Never change the .zip file in use by a running process.
>
> -gps
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Existence of pythonNN.zip in sys.path

2014-05-05 Thread Anthony Tuininga
On Mon, May 5, 2014 at 4:16 PM, Nick Coghlan  wrote:

>
> On 6 May 2014 07:51, "Paul Moore"  wrote:
> >
> > On 5 May 2014 22:32, Anthony Tuininga 
> wrote:
> > > So my question is: can I safely make use of this "feature"? It has
> remained
> > > in place since at least Python 2.6 but I don't want to assume anything.
> > > Please advise! Thanks.
> >
> > I believe this is a 100% supported feature of Python (since 2.6, as
> > you mention). Some of the zip import/run features have unfortunately
> > been underdocumented, and I suspect that this is simply one of those.
>
> sys.path initialisation in general is woefully underspecified and
> thoroughly confusing :(
>
> Fixing that is actually one of the motivating forces behind the proposed
> startup improvements in PEP 432.
>
> Cheers,
> Nick.
>

Thanks for the link. I would tend to agree with your assessment. :-) I've
had to delve into the startup code a number of times to make cx_Freeze
behave itself so any help here would be much appreciated!

Anthony
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com