Custom Python Runtime

Discussion in 'Python' started by Jack, Apr 7, 2007.

  1. Jack

    Jack Guest

    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!
     
    Jack, Apr 7, 2007
    #1
    1. Advertising

  2. Jack wrote:

    > 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.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Apr 7, 2007
    #2
    1. Advertising

  3. Jack

    Kay Schluehr Guest

    On Apr 7, 1:52 am, "Jack" <> wrote:
    > 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.
     
    Kay Schluehr, Apr 7, 2007
    #3
  4. > 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
     
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=, Apr 7, 2007
    #4
  5. Jack

    Terry Reedy Guest

    ""Martin v. Löwis"" <> wrote in message
    news:46176493$0$4042$...
    |> 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
     
    Terry Reedy, Apr 7, 2007
    #5
  6. > 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
     
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=, Apr 7, 2007
    #6
  7. Jack

    gene tani Guest

    On Apr 6, 4:52 pm, "Jack" <> wrote:
    > 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
     
    gene tani, Apr 8, 2007
    #7
  8. Jack

    Jack Guest

    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

    "Jack" <> wrote in message
    news:...
    > 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!
    >
     
    Jack, Apr 10, 2007
    #8
  9. En Tue, 10 Apr 2007 00:17:33 -0300, Jack <> escribió:

    > 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).

    --
    Gabriel Genellina
     
    Gabriel Genellina, Apr 10, 2007
    #9
  10. Jack schrieb:
    > 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
     
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=, Apr 10, 2007
    #10
  11. Jack

    Jack Guest

    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?

    >> 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.
     
    Jack, Apr 12, 2007
    #11
  12. En Thu, 12 Apr 2007 19:02:53 -0300, Jack <> escribió:

    > 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?


    Both are part of the pywin32 extensions, better ask on the python-win32
    list:
    http://mail.python.org/mailman/listinfo/python-win32

    You don't say which error you got, but abusing again my crystall ball, try
    this:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsetup/html/dlldanger1.asp

    --
    Gabriel Genellina
     
    Gabriel Genellina, Apr 12, 2007
    #12
  13. Jack

    Jack Guest

    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.

    "Gabriel Genellina" <> wrote in message
    news:...
    > En Thu, 12 Apr 2007 19:02:53 -0300, Jack <> escribió:
    >
    >> 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?

    >
    > Both are part of the pywin32 extensions, better ask on the python-win32
    > list:
    > http://mail.python.org/mailman/listinfo/python-win32
    >
    > You don't say which error you got, but abusing again my crystall ball, try
    > this:
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsetup/html/dlldanger1.asp
    >
    > --
    > Gabriel Genellina
    >
     
    Jack, Apr 13, 2007
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Klett

    using custom error pages w/ runtime errors

    Steve Klett, Nov 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    382
    Steve Klett
    Nov 12, 2003
  2. Thomas Jespersen

    Databind to an custom object at runtime

    Thomas Jespersen, Jan 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,969
    Steven Cheng[MSFT]
    Jan 17, 2004
  3. mallik
    Replies:
    0
    Views:
    393
    mallik
    Aug 9, 2004
  4. Henrik de Jong

    Add custom property at runtime to an interface

    Henrik de Jong, Aug 10, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    468
    Henrik de Jong
    Aug 10, 2004
  5. Hal Vaughan
    Replies:
    11
    Views:
    1,155
    Gordon Beaton
    May 22, 2006
Loading...

Share This Page