Custom Python Runtime

J

Jack

Since the full installation of Python (from either the standard installer or
ActiveState installer) is too big for my intended use, I'd like to build a
custom distribution of Python for Windows platform, omitting some lib files,
such as audio, tk, printing, testing units, etc.

Is there a way to customize the Windows build? In my case, there is no need
to build an installer. The best way is to have everything in a directory, as
long as I know where to find Python and Python knows where to find the
necessary libs. Any online docs describing this? Thanks!
 
G

Gabriel Genellina

Jack said:
Since the full installation of Python (from either the standard installer or
ActiveState installer) is too big for my intended use, I'd like to build a
custom distribution of Python for Windows platform, omitting some lib files,
such as audio, tk, printing, testing units, etc.

Is there a way to customize the Windows build? In my case, there is no need
to build an installer. The best way is to have everything in a directory, as
long as I know where to find Python and Python knows where to find the
necessary libs. Any online docs describing this? Thanks!

Perhaps the easiest way is start with the standard distribution and
just delete whatever you don't want.
I think that the Unicode tables are rather big and could be omited if
you don't need them.
 
K

Kay Schluehr

Since the full installation of Python (from either the standard installer or
ActiveState installer) is too big for my intended use, I'd like to build a
custom distribution of Python for Windows platform, omitting some lib files,
such as audio, tk, printing, testing units, etc.

Is there a way to customize the Windows build? In my case, there is no need
to build an installer. The best way is to have everything in a directory, as
long as I know where to find Python and Python knows where to find the
necessary libs. Any online docs describing this? Thanks!


In principle it suffices to drop in just the pythonxx.dll. If you want
to isolate those scripts and additional libraries your project
requires you might try out the py2exe even when you don't finally plan
to deliver an executable. py2exe factors and copies everything needed
for a complete application. For builds you can comment out includes in
the header file python.h but this won't usually buy you that much.
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

Is there a way to customize the Windows build? In my case, there is no need
to build an installer. The best way is to have everything in a directory, as
long as I know where to find Python and Python knows where to find the
necessary libs. Any online docs describing this? Thanks!

The interpreter will search for its libraries relative to the location
of the .exe file. So if you place python.exe and pythonxy.dll into
a directory, you need to add a Lib directory

Inside Lib, the minimum file you need to have is os.py: Python will
use it as a landmark. If you run 'python.exe -S', this is all
you need.

If you want site.py to work, you also need (tested for 2.4):
- site, codecs, copy_reg, locale, ntpath, stat, types UserDict,
encodings/__init__, encodings/aliases

If you eliminate the aliasmbcs function from site.py, you can drop
codecs, locale, encodings/*.

If you eliminate the copy_reg references from os.py, you can also drop
copy_reg.

HTH,
Martin
 
T

Terry Reedy

|> Is there a way to customize the Windows build? In my case, there is no
need
| > to build an installer. The best way is to have everything in a
directory, as
| > long as I know where to find Python and Python knows where to find the
| > necessary libs. Any online docs describing this? Thanks!
|
| The interpreter will search for its libraries relative to the location
| of the .exe file. So if you place python.exe and pythonxy.dll into
| a directory, you need to add a Lib directory
|
| Inside Lib, the minimum file you need to have is os.py: Python will
| use it as a landmark. If you run 'python.exe -S', this is all
| you need.
|
| If you want site.py to work, you also need (tested for 2.4):
| - site, codecs, copy_reg, locale, ntpath, stat, types UserDict,
| encodings/__init__, encodings/aliases
|
| If you eliminate the aliasmbcs function from site.py, you can drop
| codecs, locale, encodings/*.
|
| If you eliminate the copy_reg references from os.py, you can also drop
| copy_reg.

If this information somewhere on python.org? This is at least an
occasional question here.

tjr
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

Is this information somewhere on python.org? This is at least an
occasional question here.

Part of it. The way Python finds its landmark is in the sources
(so it is on svn.python.org/projects/python/trunk/PC/getpathp.c);
the minimum set of modules is nowhere documented (and will certainly
change from release to release).

Regards,
Martin
 
G

gene tani

Since the full installation of Python (from either the standard installer or
ActiveState installer) is too big for my intended use, I'd like to build a
custom distribution of Python for Windows platform, omitting some lib files,
such as audio, tk, printing, testing units, etc.

Is there a way to customize the Windows build? In my case, there is no need
to build an installer. The best way is to have everything in a directory, as
long as I know where to find Python and Python knows where to find the
necessary libs. Any online docs describing this? Thanks!

did you look at Diet Python:

http://sourceforge.net/projects/dietpython
 
J

Jack

Thanks for all the replies. It would be great to have all customization
related information on one doc page.

A few more questions:

1. One Windows, it's possible to zip all files in a Python24.zip. I'm not
very clear if it's used in the stardard distribution. What can,
and what can not be put into this file? I suppose zip file will help
reduce the distribution size.

2. I remember trying the compiler option to strip doc strings didn't
help but maybe I didn't do it right. I had to write some code to compile
selected py files. Is there a way to compile a stripped Python with
compile time options?

3. Some files go to the Windows\system32 directory, including some win32all
files. Can they be in the current directory as python.exe?

4. Are the registry entries necessary?

Thanks
 
G

Gabriel Genellina

1. One Windows, it's possible to zip all files in a Python24.zip. I'm not
very clear if it's used in the stardard distribution. What can,
and what can not be put into this file? I suppose zip file will help
reduce the distribution size.

(Not just on Windows) pythonXX.zip is always on sys.path, and is searched
like any other path (using zipimport).
You might in principle put all the standard library there, if you wish.
py2exe, by example, searches for all dependent modules and puts then all
in a .zip file.
But zips can only contain .py/.pyc files, not dynamic libraries like
..dll/.so.
3. Some files go to the Windows\system32 directory, including some
win32all
files. Can they be in the current directory as python.exe?

..dll files? Sure.
4. Are the registry entries necessary?

No, but if you have added entries into the PythonPath key, you may need to
configure your Python search path (using a PYTHONPATH environment variable
or .pth files).
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

Jack said:
Thanks for all the replies. It would be great to have all customization
related information on one doc page.

Please put it into a wiki page, at wiki.python.org
1. One Windows, it's possible to zip all files in a Python24.zip. I'm not
very clear if it's used in the stardard distribution. What can,
and what can not be put into this file? I suppose zip file will help
reduce the distribution size.

I would have to use the source again: if you set PYTHONHOME, you
can put the entire library into the zip file. If you don't, I
think os.py really needs to exist on disk (if so, that might be
a bug, as the intention is that you can put all .py/.pyc into the
zip file).
2. I remember trying the compiler option to strip doc strings didn't
help but maybe I didn't do it right. I had to write some code to compile
selected py files. Is there a way to compile a stripped Python with
compile time options?

Sure: -OO.
3. Some files go to the Windows\system32 directory, including some win32all
files. Can they be in the current directory as python.exe?

If you don't need COM, or other dynamic embedding of pythonxy.dll, no.
4. Are the registry entries necessary?

No.

Regards,
Martin
 
J

Jack

It seems that pywintypes24.dll and pythoncom24.dll have to be in
C:\Windows\System32 directory. Otherwise I get an error.
Any way to get around that?
 
G

Gabriel Genellina

J

Jack

Gabriel, thanks for the reply. The error is that the DLL can not be found. I
think the reason is that the pyd files from pywin32 do not use the
python.exe directory. Instead, they expect pywintypes24.dll on the path.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top