9

I write tons of python scripts, and I find myself reusing lots code that I've written for other projects. My solution has been to make sure the code is separated into logical modules/packages (this one's a given). I then make them setuptools-aware and publish them on PyPI. This allows my other scripts to always have the most up-to-date code, I get a warm fuzzy feeling because I'm not repeating myself, and my development, in general, is made less complicated. I also feel good that there MAY be someone out there that finds my code handy for something they're working on, but it's mainly for selfish reasons :)

To all the pythonistas, how do you handle this? Do you use PyPI or setuptools (easy_install)? or something else?

2
  • @Jeremy: this is a question and an answer in the question. You should rephrase the question in simple terms, and then you should put YOUR method for doing it as the first answer to the question. The best way for managing modules will be voted to the top... you never know, it may be yours. Sep 25, 2008 at 23:17
  • I actually thought about that as soon as I posted this. I will definitely do so next time. Sep 26, 2008 at 1:59

3 Answers 3

1

I have been doing the same thing. Extract common functionality, pretty the code up with extra documentation and unit tests/ doctests, create an easy_install setup.py, and then release on PyPi. Recently, I created a single Google Code site where I manage the source and keep the wiki up to date.

1

What kind of modules are we talking about here? If you're planning on distributing your projects to other python developers, setuptools is great. But it's usually not a very good way to distribute apps to end users. Your best bet in the latter case is to tailor your packaging to the platforms you're distributing it for. Sure, it's a pain, but it makes life for end users far easier.

For example, in my Debian system, I usually don't use easy_install because it is a little bit more difficult to get eggs to work well with the package manager. In OS X and windows, you'd probably want to package everything up using py2app and py2exe respectively. This makes life for the end user better. After all, they shouldn't know or care what language your scripts are written in. They just need them to install.

1
  • I publish my stuff to PyPI primarily for myself. Its usefulness to other developers or end users is really a secondary concern :) Sep 26, 2008 at 1:58
0

I store it all offline in a logical directory structure, with commonly used modules grouped as utilities. This means it's easier to control which versions I publish, and manage. I also automate the build process to interpret the logical directory structure.

Not the answer you're looking for? Browse other questions tagged or ask your own question.