What are the best methods for creating Python (egg) distributions in (and for) several operating systems

Our python store. We have different python packages developed internally and will be deployed in a client (machine) environment.

This is how the development and release cycle goes.

As soon as the developers complete the "testing" of the package, the distribution package (egg file) of the package is prepared and placed in a central archiving location. When we want to deploy our software for clients, the same distributions (egg files) will be downloaded and installed in their environment.

Assuming that the "testing" takes place on several operating systems (in order to verify the compatibility of the API on different platforms), what is the best practice for preparing distributions and moving them to a central archiving location.

It’s best to have specific operating system eggs on the archive server (for example, samplepkg-1.0.0.win32.egg and samplepkg-1.0.0.linux.egg? Do not know how they can be prepared this way using setuptools.) Or is there one egg because the API remains the same on different platforms? Any other practice that the community follows?

+7
source share
4 answers

You can use one package if:

  • The package does not use functions / classes that are not available on all your target platforms (see, for example, chapters 36-39 of the reference to the Python standard library for version 2.7.2 for materials that you should not use in this case)
  • You do not use extensions written in C / C ++ that must be compiled for each platform.

This is usually a good idea to avoid certain OS features that are not available on all of your target platforms. The standard library is well documented in this regard.

+5
source

I think that in this case using one package would be more complicated due to the reasons that Roland spoke about. In your development environment, you can have separate folders for individual platforms, each of which has platform-specific code (for example, extensions / libraries written in C / C ++). You will need to emulate your setuptools in these folders to create individual eggs, but in the end it will be less complicated (I think, not knowing more about what code you are actually working with) than trying to put everything in one package.

In any case, reading the documentation for the standard library as well as distutils ( http://docs.python.org/distutils/ ) should help you find a solution.

+2
source

Platform-specific eggs are only for distribution of packages containing C code; otherwise, the egg files themselves are platform independent, and you only need to distribute one platform-independent egg.

If you use the unattended installation tools or pkg_resources runtime APIs to search for libraries and plugins, you can simply dump all the eggs in one directory, and the installation tool or runtime API selects which egg to install or import from.

tl; dr version: setuptools builds eggs the way they should be distributed; if you try to turn a cross-platform egg into a platform-dependent one or vice versa, you are likely to experience some pain .; -)

+1
source

If you only have python modules, save all the differences hidden in python, the same files (python std lib) or separate files (pyserial).

If you compiled the modules, this is a little more complicated.

I use the following directory structure for a project that requires a compiled extension:

./lib/display.py # frontend, platform-independent ./lib.linux-x86_64-2.6/_display.so ./lib.linux-armv5tejl-2.6/_display.so 

And this code at the beginning of the program:

 sys.path.append("lib.%s-%s-%s.%s" % ((posix.uname()[0].lower(), posix.uname()[4]) +sys.version_info[:2])) 

You can wrap a structure like this in .egg if you specify that it is not zip-safe.

0
source

All Articles