[capi-sig] Couple of Questions About Statically Linking the Interpreter
ideasman42 at gmail.com
Tue Oct 20 22:11:25 CEST 2009
There are a few ways to set this path from C before starting python
setenv("PYTHONHOME", somepath, 1);
Heres a function that blender uses to setup python3.1's path, there
are a few blender functions here but should still be useful.
the #if0's part works too but I preferred to set the home folder directly.
/* must be called before Py_Initialize */
char *py_path_bundle= BLI_gethome_folder("python", BLI_GETHOME_ALL);
/* set the environment path */
printf("found bundled python: %s\n", py_path_bundle);
static wchar_t py_path_bundle_wchar[FILE_MAXDIR];
mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR);
On Tue, Oct 20, 2009 at 8:34 PM, Nathan Osman
<george_edison55 at hotmail.com> wrote:
> Thanks for your help. So if I bundle everything in the Lib directory with
> the application what function would I call to inform Python where the
> modules are located before I call Py_Initialize?
>> Date: Tue, 20 Oct 2009 15:02:54 +0200
>> From: ideasman42 at gmail.com
>> To: capi-sig at python.org
>> Subject: Re: [capi-sig] Couple of Questions About Statically Linking the
>> for python 2.x you can get away only with statically linked library,
>> but then you miss modules like math, struct and os
>> If you want these modules you can compile some of these into the
>> library you can build python with a modified config
>> -- quick howto --
>> edit ./Modules/Setup
>> uncomment "#*shared*" around line 152 and rename to "*static*" The
>> following modules are built into libpython2.5.a
>> uncomment: array, math, time, operator, itertools, cStringIO, cPickle,
>> zlib, _struct, _weakref, _random, binascii, collections, fcntl, spwd,
>> grp, select
>> Or you can bundle python25.zip with your application and include all
>> modules in this, however youll need zlib either compiled statically or
>> include the module unzipped in the dir.
>> Blender2.49 for example in win32 has python26.zip and zlib.pyd in the
>> current directory so python can extract the zip and open the
>> As for python 3.x, It cant even start unless it has some external modules
>> Unless there is some trick I dont know of, youll get this with a
>> static linked py3.1 and no modules...
>> Fatal Python error: Py_Initialize: can't initialize sys standard streams
>> ImportError: No module named encodings.utf_8
>> Heres some info I wrote about how to bundle python3.1 with blender.
>> On Tue, Oct 20, 2009 at 9:48 AM, Nathan Osman
>> <george_edison55 at hotmail.com> wrote:
>> > Im kind of new to the Python/C api and I had a couple q's about the
>> > interpreter.
>> > 1. If i statically link the libpython31.a library to my app are there
>> > any other files i need to include for the end users? Im using Windows, btw.
>> > 2. How do you get the interpreter output from the console when you are
>> > running within a gui environment? Can it be redirected?
>> > Thanks,
>> > George
>> > _________________________________________________________________
>> > New! Faster Messenger access on the new MSN homepage
>> > http://go.microsoft.com/?linkid=9677406
>> > _______________________________________________
>> > capi-sig mailing list
>> > capi-sig at python.org
>> > http://mail.python.org/mailman/listinfo/capi-sig
>> - Campbell
>> capi-sig mailing list
>> capi-sig at python.org
> New! Hotmail sign-in on the MSN homepage.
More information about the capi-sig