views:

267

answers:

6

I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?

A: 

You can download Windows EXE installers and a Linux RPM from here

http://pypi.python.org/pypi/setuptools

Then, once you have setuptools in place you can use the easy_install command to both download and install new packages. Because easy_install, also automatically downloads and installs dependencies, you might want to set up virtualenv before you actually use it. That way you can decide whether or not you want to install a bunch of packages into your system's default Python install.

Yes, this means that your users will have to have setuptools installed in order for them to use it. Of course, you could take the setuptools installers, rename them, and package them up with like NSIS and distribute that to your users. The fact is, that you have to install something, so if you don't want to put your application in the installer, you can package up setuptools instead.

Michael Dillon
So I am saying to my users, "To install my program you have to install setuptools"?
cool-RR
The question wasn't "how to install setuptools" but "what to do is the user doesn't has it".
Damien MATHIEU
If the user doesn't have it, the only thing that you can do is to get them to download the EXE or RPM and install it. Or distribute setuptools instead of your app. Edited the answer to say this.
Michael Dillon
+2  A: 

In most librarys I ever installed for python, a warning apears "You have to install setuptools". You could do it as well I think, you could add a link so the user don't have to search the internet for it.

TiPoK
+1: How about including the words "Use setuptools" in the README?
S.Lott
I think it's much the same. The exception will be raised anyway when no setuptools is installed, so you have to handle it anyway.
TiPoK
+4  A: 

The standard way to distribute packages with setuptools includes an ez_setup.py script which will automatically download and install setuptools itself - on Windows I believe it will actually install an executable for easy_install. You can get this from the standard setuptools/easy_install distribution.

Daniel Roseman
A: 

I would say it depends on what kind of user you are addressing.

If they are simply users and not Python programmers, or if they are basic programmers, using setuptools might be a little bit too much at first. For those the distutils is perfect.

For clients, I would definitely stick to distutils.

For more enthusiast programmers the setuptools would be fine.

Somehow, it also depends on how you want to distribute updates, and how often. For example, do the users have an access to the Internet without a nasty proxy setup by their company that would block setuptools? - We do have one and it's an extra step to configure and make it work on every workstation.

RedGlyph
+1  A: 

You can't assume it's installed. There are ways around that, you can fall back to distutils (but then why have setuptools in the first place) or you can install setuptools in setup.py (but I think that's evil).

Use setuptools only if you need it.

When it comes to setuptools vs distrubute, they are compatible, and choosing one over the other is mainly up to the user. The setup.py is identical.

Lennart Regebro
+2  A: 

I have used setuptools to compile many python scripts that I have written into windows EXEs. However, it has always been my understanding (from experience) that the computer running the compiled EXE does not need to have setup tools installed.

Hope that helps

inspectorG4dget