Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2007-12-28 16:55:42
Size: 999
Editor: jffwpr03
Comment: created to step through process to build python statically
Revision 5 as of 2016-08-27 08:22:20
Size: 1653
Comment: Add a link which covers building python statically.
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
This page describes the steps required to build Python statically, derived from [http://groups.google.com/group/comp.lang.python/browse_thread/thread/eba7c323a0221b97?hl=en#3314cbe8234de6c5 this thread]. It presently covers Linux, but many of the same steps apply to other OSs. The goal is to get `ldd` to say: This page describes the steps required to build Python statically, derived from [[http://groups.google.com/group/comp.lang.python/browse_thread/thread/eba7c323a0221b97?hl=en#3314cbe8234de6c5|this thread]]. It presently covers Linux, but many of the same steps apply to other OSs. The goal is to get `ldd` to say:
Line 18: Line 18:
It would be nice to have a `--enable-all-static` option in the `configure` script which would take care of all this for you. For an example, try building [http://subversion.tigris.org Subversion]. It would be nice to have a `--enable-all-static` option in the `configure` script which would take care of all this for you. For an example, try building [[http://subversion.tigris.org|Subversion]].

See http://mdqinc.com/blog/2011/08/statically-linking-python-with-cython-generated-modules-and-packages/ for a detailed example which includes both how to build a barebones static python, and adding custom modules to the binary.

== Static Modules Built Into libpythonX.X.a ==

Haven't figured out how to make {{{python}}} static, but here is how to make all of the modules static.

{{{
./configure
}}}

Edit Modules/Setup.local and add the line:

{{{
*static*
}}}

then...

{{{
./configure
make
make install
}}}

For the full answer see http://stackoverflow.com/questions/1150373/compile-the-python-interpreter-statically

Building Python Statically

/!\ This page is a placeholder until MicahElliott (or anyone) figures out all the steps to make this work.

This page describes the steps required to build Python statically, derived from this thread. It presently covers Linux, but many of the same steps apply to other OSs. The goal is to get ldd to say:

$ ldd /path/to/bin/python
not a dynamic executable

{i} Note that the --disable-shared option is not related to building Python statically.

There is a file called Modules/Setup.local which is designed for customizing how modules are built.

GCC (and LD) offer a -static option to create static executables.

It would be nice to have a --enable-all-static option in the configure script which would take care of all this for you. For an example, try building Subversion.

See http://mdqinc.com/blog/2011/08/statically-linking-python-with-cython-generated-modules-and-packages/ for a detailed example which includes both how to build a barebones static python, and adding custom modules to the binary.

Static Modules Built Into libpythonX.X.a

Haven't figured out how to make python static, but here is how to make all of the modules static.

./configure

Edit Modules/Setup.local and add the line:

*static*

then...

./configure
make
make install

For the full answer see http://stackoverflow.com/questions/1150373/compile-the-python-interpreter-statically

BuildStatically (last edited 2021-03-29 18:21:47 by WilliamWoodruff)

Unable to edit the page? See the FrontPage for instructions.