Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: Python Test Environment

6 views
Skip to first unread message

Michael Foord

unread,
Dec 15, 2004, 7:50:47 AM12/15/04
to pytho...@python.org
Well sort of....... Highly experimental - I'm interested in ways of
improving this.

http://www.voidspace.org.uk/atlantibots/pythonutils.html#testenv

I've created a script that will build a 'test environment'. Windoze(tm)
only as it uses py2exe.

It scans your Python\Lib folder (configurable) and builds a script that
*fakes* an import of every module (along with some boilerplate). This,
more or less, amounts to everything in the standard lib. There is then a
normal setup.py to turn this into a python executable.

The result, is an executable that will run any python script. It gives
sensible values for sys.path, sys.argv and __file__.

This is useful for various purposes :

1) Easily have test environments for multiple versions of python - to
test your scripts.
2) Run any python script on a machine without python installed.
3) Deploying several scripts using py2exe - one build fits all.

Usage :

testenv <python file> arg1 arg2...

Which should be the equivalent of :
python <python file> arg1 arg2...


Sample output :
(Built with Python 2.4 - then 2.3 - prints sys.version first)

########


D:\New Folder\testenv>testenv test.py arg1 arg2 arg3
2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]

sys.path = ['D:\\New Folder\\testenv\\library.zip', 'D:\\New
Folder\\testenv', '
D:\\New Folder\\testenv']

sys.argv = ['D:\\New Folder\\testenv\\test.py', 'arg1', 'arg2', 'arg3']

import Tkinter # succeeded

import dummylibrary # succeeded

D:\New Folder\testenv>


##########

D:\Python Projects\modules in progress\py2exe-testenv\dist>testenv
test.py arg1
arg2
2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]

sys.path = ['D:\\Python Projects\\modules in
progress\\py2exe-testenv\\dist\\lib
\\shared.zip', 'D:\\Python Projects\\modules in
progress\\py2exe-testenv\\dist',
'D:\\Python Projects\\modules in progress\\py2exe-testenv\\dist']

sys.argv = ['D:\\Python Projects\\modules in
progress\\py2exe-testenv\\dist\\tes
t.py', 'arg1', 'arg2']

import Tkinter # succeeded

import dummylibrary # succeeded

D:\Python Projects\modules in progress\py2exe-testenv\dist>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm sure this can be improved in lots of ways - but already useful to
me. Comments and suggestions for improvements welcomed. Thanks go to
Bruno Thoorens for his suggestions so far.

Currently has issues collecting 'sub-packages', but I *think* only the
same issues that py2exe has. Extra modules can just be included
somewhere on sys.path.

Regards,


Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html


Richie Hindle

unread,
Dec 15, 2004, 8:56:38 AM12/15/04
to pytho...@python.org

[Michael / Fuzzyman]
> http://www.voidspace.org.uk/atlantibots/pythonutils.html#testenv

I've seen this announcement four times now - I don't whether you're seeing
problems with it, but it's definitely reaching the mailing list.

--
Richie Hindle
ric...@entrian.com

Fuzzyman

unread,
Dec 14, 2004, 6:16:32 AM12/14/04
to
Well sort of.......

More a request for comments really - to see if anyone is interested in
this.

http://www.voidspace.org.uk/atlantibots/pythonutils.html#testenv

I've created a script that will build a 'test environment'. Windoze(tm)
only as it uses py2exe.

It scans your Python\Lib folder and builds a script that *fakes* an
import of every file. This *more* or less amounts to everything in the
standard lib. There is then another script that turns this into a
python executable.

The result is an executable that will run any python script. It gives
sensible values to sys.path, sys.argv and __file__.

This is useful for two purposes :

1) Easily have test environments for multiple versions of python - to
test your scripts.
2) Run any python script on a machine without python installed.


Usage :

########

import Tkinter # succeeded

import dummylibrary # succeeded

D:\New Folder\testenv>


##########

import Tkinter # succeeded

import dummylibrary # succeeded

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm sure this can be improved in lots of ways - only about an hours
hacking or so - but already useful to me. Comments and suggestions for
improvements welcomed.

Regards,


Fuzzy

Fuzzyman

unread,
Dec 14, 2004, 11:23:17 AM12/14/04
to

Fuzzyman

unread,
Dec 15, 2004, 5:57:20 AM12/15/04
to
Well sort of....... Highly experimental - I'm interested in ways of
improving this.

http://www.voidspace.org.uk/atlantibots/pythonutils.html#testenv

I've created a script that will build a 'test environment'. Windoze(tm)
only as it uses py2exe.

It scans your Python\Lib folder (configurable) and builds a script that


*fakes* an import of every module (along with some boilerplate). This,

more or less, amounts to everything in the standard lib. There is then
a normal setup.py to turn this into a python executable.

The result is an executable that will run any python script. It gives

sensible values for sys.path, sys.argv and __file__.

This is useful for various purposes :

1) Easily have test environments for multiple versions of python - to
test your scripts.
2) Run any python script on a machine without python installed.

3) Deploying several scripts using py2exe - one build fits all.

Usage :

########

import Tkinter # succeeded

import dummylibrary # succeeded

D:\New Folder\testenv>


##########

import Tkinter # succeeded

import dummylibrary # succeeded

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm sure this can be improved in lots of ways. Comments and suggestions
for improvements welcomed. Thanks already to Bruno Thooreens for his
help.

Regards,


Fuzzy

Fuzzyman

unread,
Dec 15, 2004, 9:45:46 AM12/15/04
to
Sorry.... they're not reaching google groups, which is what I'm posting
from. From http://groups-beta.google.com/group/comp.lang.python posts
usually show up within a few minutes. The thing is, when I posted by
email it showed up in seconds...........

Anyway - sorry about that and thanks for letting me know.

Regards,
Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html

Fuzzyman

unread,
Dec 16, 2004, 6:30:45 AM12/16/04
to
This seems to work very well. I'm still tweaking the 'stdlibfinder.py'
and the setup.py - but it's still ok. In some ways it acts like a basic
'Python Runtime Environment'.

Part of the reason for building it was that in one of my jobs I don't
have python installed and can't install new programs. I'm now using
testenv with wxPython, and DrPython as an IDE - it works fine. Even SPE
seems to work fine (it complains about a missing dll and then works
anyway). I've even associated '.py' files with testenv...

I have prebuilt environments for python 2.4 and python 2.3. I'm not
making them available by http because of bandwidth concerns (4meg
zipfiles each). If anyone want to try python 2.4 without having to
install it, you're welcome to email me and I''ll send you a copy.

Regards,

Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html

sta...@hotmail.com

unread,
Dec 16, 2004, 9:13:13 AM12/16/04
to
Hi Fuzzy,
I'm quite interested in your test environment project. It would enable
me to carry my favorite working environment around on my 1gb flashdisk.
Very useful indeed, as I also sometimes am at places where I can't
install or don't want to install python and all set of libraries. What
is the missing dll SPE is complaining about? Maybe you can email me
privately out of this list to discuss this further
(s_t_...@nospam.net, replace nospam with gmx). Maybe I could offer it
as a special SPE download for python newbies, if I can convince
blender.org concerning bandwith. I rather would call it than 'movable'
python. Test environment seems more for hardcore developpers, while
this is excellent for newbies to try and play around before installing.
What is the unpacked size of this python environment? Any chance if
this would work for other platforms as well?
Stani

http://spe.pycs.net
http://www.stani.be

0 new messages