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?

3
  • possible duplicate of What is setup.py? Commented Aug 17, 2014 at 0:04
  • 1
    I dont't agree. I'm not talking about modules only, but all packages. The linked answer is only about modules. Commented Aug 17, 2014 at 0:08
  • See also (not dupe, just relevant): stackoverflow.com/questions/2204811/… Commented Aug 17, 2014 at 1:16

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.