Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the best practices for creating Python Distributions(eggs) on(and for) Multiple Operating Systems

Ours is a python shop. We have different python packages developed inhouse and will be deployed onto customers' environments(machines).

This is how our development and release cycle happens.

Once developers complete "testing" of a package, a distribution(egg file) of the package is prepared and pushed to a central archiving place. WHen we want to deploy our software to Customers, the same distributions(egg files) will be downloaded and installed in their environment.

Assuming the "testing" happens on multiple operating systems(to check the compatibility of the API across platforms), what is the best practice to prepare distributions and be pushed to the central archiving place.

Is it best to have operating system specific eggs on the archiving server(like, samplepkg-1.0.0.win32.egg and samplepkg-1.0.0.linux.egg ? Not sure how they can be prepared in this way using setuptools. ) Or Have a single egg because API remains same across platforms ? Any other practice which is followed by the community ?

like image 590
None-da Avatar asked Feb 17 '12 11:02

None-da


People also ask

What is python setuptools used for?

Setuptools is a collection of enhancements to the Python distutils that allow developers to more easily build and distribute Python packages, especially ones that have dependencies on other packages. Packages built and distributed using setuptools look to the user like ordinary Python packages based on the distutils .

What is the command used for building a source distribution python setup py?

To build a source distribution, use the command line to navigate to the directory containing setup.py, and run the command python setup.py sdist. Run python setup.py bdist or, for Windows, python setup.py bdist_wininst to build a binary distribution.

What is Sdist and Bdist?

sdist is a "source distribution". bdist is a "binary distribution". For a pure Python project, those things are pretty close. If your project includes any extension modules, though, the sdist includes the source for those extension modules and use of the sdist will require a compiler.

Does python come with setuptools?

Usually, Yes. the setuptools is not part of the python vanilla codebase, hence not a vanilla modules. python.org installers or mac homebrew will install it for you, but if someone compile the python by himself or install it on some linux distribution he may not get it and will need to install it by himself.


2 Answers

You can use a single package if:

  1. The package does not use functions/classes that are not available on all your target platforms (see e.g. chapters 36-39 of the Python standard library reference for version 2.7.2 for stuff that you shouldn't use in that case)
  2. You are not using extensions written in C/C++ that need to be compiled for every platform.

It it generally a good idea to stay away from OS specific functions that are not available on all your target platforms. The standard library is quite well documented in that respect.

like image 153
Roland Smith Avatar answered Sep 25 '22 02:09

Roland Smith


I think that in this case, using a single package would be more complicated due to the reasons that Roland mentioned above. In your development environment you could have separate folders for separate platforms, each with the platform specific code (such as extensions/libraries written in C/C++). You would need to mimic your setuptools within these folders to produce separate eggs, but it would ultimately be less complex (I think, without knowing more about what code you are actually working with) than trying to put everything into one package.

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

like image 31
darthlukan Avatar answered Sep 24 '22 02:09

darthlukan