Copying a compiled Python from one system to another

Chris Angelico rosuav at gmail.com
Sat Oct 1 08:01:29 EDT 2016


On Sat, Oct 1, 2016 at 9:21 PM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> Long story short: I have no working systems capable of compiling the latest
> Python 3.6, and no time to upgrade my usual machines to something which
> will work.
>
> However I do have access to another machine (actually a VM) which can
> compile Python 3.6. It's not practical for me to use it as a my main
> development machine, but as a temporary measure, I thought I could compile
> 3.6 on this VM, then copy the python binary to my usual desktop machine.
>
> What sort of challenges am I likely to find? Both machines are Linux, but
> different distros.

First off, are they the same CPU architecture? If not, you're going to
have a lot of hassles. (This includes x86_64 vs i386. You *can* run a
32-bit Python on a 64-bit Linux, but it'll be a pain.) I'm going to
assume that they are.

Are both Linuxes of broadly similar vintage? The most likely problems
you'll face will be library versions - CPython will happily link
against any of several compatible versions of a library, but once it's
linked against one, it'll want to find the same version thereafter.
Worst case, you could symlink, but that could cause trouble when you
upgrade, so I'd advise against it.

In fact, your best bet might actually be to *minimize* the number of
dev libraries on the build machine. You'll have build failures in
optional modules (and thus less modules), but less chances of running
into difficulties.

Other than that, it should be possible. You'll probably want to export
the built Python as a package manager file, eg using checkinstall [1]
on Debian-based systems, as it'll be a lot easier to pick up and carry
around. But it shouldn't be too hard even working manually.

ChrisA

[1] https://wiki.debian.org/CheckInstall



More information about the Python-list mailing list