Questions tagged [setuptools]

setuptools is a set of enhancements to Python's distutils which simplify building, distribution and installation of Python packages.

setuptools is a (largely) drop-in replacement for distutils first published in 2004. Its most notable addition over the unmodified distutils tools was the ability to declare dependencies on other packages. It is currently recommended as a more regularly updated alternative to distutils that offers consistent support for more recent packaging standards across a wide range of Python versions.

The recommended pip installer runs all setup.py scripts with setuptools, even if the script itself only imports distutils.
This text is Copyright © 2001-2021 Python Software Foundation; All Rights Reserved.


Tag usage

  • Questions about setuptools-specific features should be tagged .
  • If a question is only about functionality common to both distutils and setuptools, the tag can be used in advance.
  • If it's unclear that the question author is using setuptools, the tag should be used instead.

Other related tags:

Modern alternatives to setuptools

Resources

3420 questions
71
votes
4 answers

Managing resources in a Python project

I have a Python project in which I am using many non-code files. Currently these are all images, but I might use other kinds of files in the future. What would be a good scheme for storing and referencing these files? I considered just making a…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
68
votes
4 answers

Install dependencies from setup.py

I wonder if as well as .deb packages for example, it is possible in my setup.py I configure the dependencies for my package, and run: $ sudo python setup.py install They are installed automatically. Already researched the internet but all I found…
adinanp
  • 935
  • 3
  • 8
  • 11
66
votes
5 answers

Why does "python setup.py sdist" create unwanted "PROJECT-egg.info" in project root directory?

When I run python setup.py sdist it creates an sdist in my ./dist directory. This includes a "PROJECT-egg.info" file in the zip inside my "dist" folder, which I don't use, but it doesn't hurt me, so I just ignore it. My question is why does it…
Jonathan Hartley
  • 15,462
  • 9
  • 79
  • 80
66
votes
5 answers

How to specify version ranges in install_requires (setuptools, distribute)

I want to make a package to depend the particular version range e.g. >= 0.5.0, < 0.7.0. Is it possible in install_requires option, and if so how should it be?
minhee
  • 5,688
  • 5
  • 43
  • 81
65
votes
1 answer

How to write a minimally working pyproject.toml file that can install packages?

Pip supports the pyproject.toml file but so far all practical usage of the new schema requires a 3rd party tool that auto-generates these files (e.g., poetry and pip). Unlike setup.py which is already human-writeable, pyproject.toml is not…
Keto
  • 1,470
  • 1
  • 12
  • 25
63
votes
7 answers

Automatic version number both in setup.py (setuptools) AND source code?

SITUATION: I have a python library, which is controlled by git, and bundled with distutils/setuptools. And I want to automatically generate version number based on git tags, both for setup.py sdist and alike commands, and for the library itself. For…
Sergey Vasilyev
  • 3,919
  • 3
  • 26
  • 37
60
votes
1 answer

How do setuptools, distribute, and pip relate to one another?

I've been teaching myself Python through the book "Learn Python The Hard Way" (2nd Edition). In exercise 46 it told me to read up on Pip, Distribute, and a few other packages. The documentation for pip was clear enough. It allows me to…
Ben G
  • 26,091
  • 34
  • 103
  • 170
60
votes
1 answer

Python package structure, setup.py for running unit tests

I'm not sure I'm organizing my package structure correctly or am using the right options in setup.py because I'm getting errors when I try to run unit tests. I have a structure like this: /project /bin /src /pkgname …
Nate Reed
  • 6,761
  • 12
  • 53
  • 67
60
votes
2 answers

How to set up entry_points in setup.cfg

I am moving my config from setup.py to setup.cfg and having issues setting up the entry_points parameter. At the moment I am using a hybrid approach which works, however, I would like to move the entry_points to setup.cfg. From def setup_package(): …
user465374
  • 1,521
  • 4
  • 20
  • 39
60
votes
2 answers

How to easily distribute Python software that has Python module dependencies? Frustrations in Python package installation on Unix

My goal is to distribute a Python package that has several other widely used Python packages as dependencies. My package depends on well written, Pypi-indexed packages like pandas, scipy and numpy, and specifies in the setup.py that certain…
yyk
  • 681
  • 1
  • 5
  • 8
59
votes
2 answers

install_requires based on python version

I have a module that works both on python 2 and python 3. In Python<3.2 I would like to install a specific package as a dependency. For Python>=3.2. Something like: install_requires=[ "threadpool >= 1.2.7 if python_version < 3.2.0", ], How…
iTayb
  • 12,373
  • 24
  • 81
  • 135
56
votes
4 answers

Python: Multiple packages in one repository or one package per repository?

I have a big Python 3.7+ project and I am currently in the process of splitting it into multiple packages that can be installed separately. My initial thought was to have a single Git repository with multiple packages, each with its own setup.py.…
AstrOne
  • 3,569
  • 7
  • 32
  • 54
56
votes
3 answers

How to configure __main__.py, __init__.py, and setup.py for a basic package setup?

Background: I have a directory structure like so: Package/ setup.py src/ __init__.py __main__.py code.py I want to be able to run the code in a lot of different ways. pip install Package and then python and then…
Alex Lenail
  • 12,992
  • 10
  • 47
  • 79
55
votes
4 answers

Determining version of easy_install/setuptools

I'm trying to install couchapp, which uses easy_install - and is quite explicit in stating a particular version of easy_install/setuptools is needed: 0.6c6. I seem to have easy_install already on my Mac, but there's no command-line arguments to…
pat
  • 16,116
  • 5
  • 40
  • 46
54
votes
7 answers

RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment

I have Win 10 When running: conda update conda I encountered this error: RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment. Nothing seems to help I tried to uninstall anaconda and got a…
Toly
  • 2,981
  • 8
  • 25
  • 35