What are simple instructions for creating a Python package structure and egg?
Asked Answered
C

3

12

I just completed my first (minor) Python project, and my boss wants me to package it nicely so that it can be distributed and called from other programs easily. He suggested I look into eggs. I've been googling and reading, but I'm just getting confused. Most of the sites I'm looking at explain how to use Python eggs that were already created, or how to create an egg from a setup.py file (which I don't yet have). All I have now is an Eclipse pydev project with about 4 modules and a settings/configuration file. In easy steps, how do I go about structuring it into folders/packages and compiling it into an egg? And once it's an egg, what do I have to know about deploying/building/using it? I'm really starting from scratch here, so don't assume I know anything; simple step-by-step instructions would be really helpful...

These are some of the sites that I've been looking at so far:

I've also browsed a few SO questions but haven't really found what I need.

Thanks!

Crustaceous answered 27/5, 2010 at 15:31 Comment(0)
R
2

You should be able to find what you need in one of the following, depending on what version of Python you're using:

http://docs.python.org/distutils/
http://docs.python.org/py3k/distutils/index.html

Ryanryann answered 27/5, 2010 at 15:44 Comment(0)
P
30

All you need is read this: The Hitchhiker's Guide to Packaging

or install PasteScript using pip or easy_install, then

paster create your_package_name

and you'll get a template for your python package

Package answered 27/5, 2010 at 15:49 Comment(3)
....years later... The user was a beginner and looking for a "step by step guide" to packaging, and the Hitchiker's Guide to Packaging is just that, great job of providing exactly what was asked for.Representationalism
This is the best thing ever!Psychosurgery
But before you need to install paster like this: pip install pastescriptWhopping
I
3

You should hold to the standard packaging of distutils. Quoting James Bennett:

Please, for the love of Guido, stop using setuptools and easy_install, and use distutils and pip instead.

Starting from there, a quite standard distribution looks like:

module/
README
setup.py # follow http://docs.python.org/distutils/setupscript.html
tests/
Insensibility answered 27/5, 2010 at 15:42 Comment(2)
Unfortunately pip supposedly isn't supported on Windows, which is a pretty big flaw for a packaging system in my opinion. I know a lot of people would like Windows to go away - and Python has never been well supported on Windows - but it's a widely used platform, to say the least.Slouch
Visual Studio 2012 supports both pip and easy_install with [PVTS](pytools.codeplex.com)Boser
R
2

You should be able to find what you need in one of the following, depending on what version of Python you're using:

http://docs.python.org/distutils/
http://docs.python.org/py3k/distutils/index.html

Ryanryann answered 27/5, 2010 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.