3

Disclaimer: I'm still not sure I understand fully what setup.py does.

From what I understand, using a setup.py file is convenient for packages that need to be compiled or to notify Disutils that the package has been installed and can be used in another program. setup.py is thus great for libraries or modules.

But what about super simple packages that only has a foo.py file to be run? Is a setup.py file making packaging for Linux repository easier?

baldurmen
  • 669
  • 2
  • 7
  • 15
  • possible duplicate of [What is setup.py?](http://stackoverflow.com/questions/1471994/what-is-setup-py) – karthikr Aug 17 '14 at 00:04
  • 1
    I dont't agree. I'm not talking about modules only, but all packages. The linked answer is only about modules. – baldurmen Aug 17 '14 at 00:08
  • See also (not dupe, just relevant): http://stackoverflow.com/questions/2204811/pip-install-a-python-package-without-a-setup-py-file – Jason S Aug 17 '14 at 01:16

1 Answers1

4

Using a setup.py script is only useful if:

  1. Your code is a C extension, and then depends on platform-specific features that you really don't want to define manually.
  2. Your code is pure Python but depends on other modules, in which case dependencies may be resolved automatically.

For a single file or a few set of files that don't rely on anything else, writing one is not worth the hassle. As a side note, your code is likely to be more attractive to people if trying it up doesn't require a complex setup. "Installing" it is then just about copying a directory or a single file in one's project directory.

michaelmeyer
  • 7,985
  • 7
  • 30
  • 36
  • Just to be crystal clear, it thus means if I import modules that are not from the standard python distribution, I'd better use a setup.py script? – baldurmen Aug 17 '14 at 00:24
  • The question title is about **distribution**. `setup.py` is also essential for using `pip install` (not just from PyPI but also from a local zip/tar file) or for uploading to PyPI in the first place if you are distributing publicly. – Jason S Aug 17 '14 at 01:11