[Tutor] packing up python code to transfer to another machine
Chris Fuller
cfuller084 at thinkingplanet.net
Thu Feb 11 04:53:23 CET 2010
There are two obvious "gotchas". One is binary extensions. If you are using
modules that are not "pure Python", you will have to find *nux versions for
your target.
The other problem is impossible to solve in general, but most of the time,
it's less trouble than the first problem. Python is a dynamic language.
Dependencies can be created at runtime (using __import__, exec, or execfile, at
least), and it's certainly possible to write code that has unpredictable
dependencies. Usually, however, the unknown dependency is drawn from a finite
pool that is predictable. If you include all the bits that each third party
modules comes with (and the same for your code, if it does any of these
tricks), you should be Ok, but you can't prove it without analyzing the code.
If you know the package dependencies (usually documented), you can work with
that. matplotlib requires numpy, for instance. If this isn't enough, there's
the modulefinder module. Note that it won't detect dynamic dependencies, so
you have to know what third party stuff is included, and make sure you include
all of it (or less, but only if you know what you're doing). Modulefinder also
makes a lot of noise, and will include stuff you don't want or need.
Another problem is platform compatibility. If you rely on the windows API, or
filesystem idiosyncrasies, like drive letters, you'll have to fix those; but
these are less surprising and easy to catch.
Cheers
On Wednesday 10 February 2010, dwbarne at earthlink.net wrote:
> I have become a true Pythonaholic. My newest problem is....
>
> I have a rather large Python code (1.5yrs + developing!) currently running
> on Windows machines that imports several modules, some from external
> libraries. It allows the user to easily access MySQL databases and plot
> selected columns and such.
>
> I would like to bundle my (code + libraries + modules) and transfer all to
> a *nix environment, rather than just transferring my code over and then
> having to download and install all the relevant libraries again.
>
> Is this possible? I would think so with Python but am not sure.
>
> Is there a Python package that does this? If so, what?
>
> Thanks in advance.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list