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
53
votes
1 answer

Packaging legacy Fortran in Python. Is it OK to use setuptools and numpy.distutils?

I am trying to make a python package distribution for some popular Fortran codes in my field. I want it to use the most standard approach with a setup.py file. The related qustion was helpful for learning how to wrap Fortran extensions. When using…
Will Martin
  • 993
  • 6
  • 18
52
votes
3 answers

Extending setuptools extension to use CMake in setup.py?

I'm writing a Python extension that links a C++ library and I'm using cmake to help with the build process. This means that right now, the only way I know how to bundle it, I have to first compile them with cmake before I can run setup.py…
loneraver
  • 1,282
  • 2
  • 15
  • 22
50
votes
3 answers

Specify where to install 'tests_require' dependencies of a distribute/setuptools package

When I run python setup.py test the dependencies listed in tests_require in setup.py are downloaded to the current directory. When I run python setup.py install, the dependencies listed in requires are instead installed to site-packages. How can I…
Danny Navarro
  • 2,733
  • 1
  • 18
  • 22
49
votes
5 answers

Python Packaging: Data files are put properly in tar.gz file but are not installed to virtual environment

I can't properly install the project package_fiddler to my virtual environment. I have figured out that MANIFEST.in is responsible for putting the non-.py files in Package_fiddler-0.0.0.tar.gz that is generated when executing python setup.py…
Bentley4
  • 10,678
  • 25
  • 83
  • 134
48
votes
3 answers

Does pip handle extras_requires from setuptools/distribute based sources?

I have package "A" with a setup.py and an extras_requires line like: extras_require = { 'ssh': ['paramiko'], }, And a package "B" that depends on util: install_requires = ['A[ssh]'] If I run python setup.py install on package B, which uses…
dsully
  • 483
  • 1
  • 5
  • 6
46
votes
6 answers

How to include license file in setup.py script?

I have written a Python extension module in C++. I plan to distribute the module with setuptools. There will be binary distributions for 32- and 64-bit Windows (built with setup.py bdist_egg) and a source distribution for UNIX-like platforms (built…
Johan Råde
  • 20,480
  • 21
  • 73
  • 110
46
votes
7 answers

Excluding a top-level directory from a setuptools package

I'm trying to put a Python project into a tarball using setuptools. The problem is that setuptools doesn't appear to like the way that the source tree was originally setup (not by me, I must add). Everything that I actually want to distribute is…
womble
  • 12,033
  • 5
  • 52
  • 66
46
votes
7 answers

"setup.py upload" is failing with "Upload failed (401): You must be identified to edit package information"

When running.. python setup.py sdist register upload ..I get the following output: running register We need to know who you are, so please choose either: 1. use your existing login, 2. register as a new user, 3. have the server generate a new…
dbr
  • 165,801
  • 69
  • 278
  • 343
45
votes
4 answers

Is it possible to express a platform-specific dependency in setup.py without building platform-specific versions of my egg?

We have a placeholder egg that contains no code and only exists for the sake of pulling down a list of dependent packages from our PyPi repository. Most of these dependent packages are platform-agnostic, however some are only used on Win32…
Daniel Fortunov
  • 43,309
  • 26
  • 81
  • 106
45
votes
5 answers

How to include and install local dependencies in setup.py in Python?

I am creating a setup.py to distribute my application. This application has a number of dependencies which can be installed via pip, it also has some custom dependencies which can not be installed from PyPI. So, I have created a…
minerals
  • 6,090
  • 17
  • 62
  • 107
45
votes
10 answers

How to Bootstrap numpy installation in setup.py

I have a project which has a C extension which requires numpy. Ideally, I'd like whoever downloads my project to just be able to run python setup.py install or use one call to pip. The problem I have is that in my setup.py I need to import numpy to…
user545424
  • 15,713
  • 11
  • 56
  • 70
44
votes
2 answers

Python setuptools: how to include a config file for distribution into /etc

How can I write setup.py so that: The binary egg distribution (bdist_egg) includes a sample configuration file and Upon installation puts it into the {prefix}/etc directory? A sample project source directory looks like this: bin/ myapp etc/ …
Victor Olex
  • 1,458
  • 1
  • 13
  • 28
43
votes
2 answers

How to reference a requirements.txt in the pyproject.toml of a setuptools project?

I'm trying to migrate a setuptools-based project from the legacy setup.py towards modern pyproject.toml configuration. At the same time I want to keep well established workflows based on pip-compile, i.e., a requirements.in that gets compiled to a…
bluenote10
  • 23,414
  • 14
  • 122
  • 178
43
votes
4 answers

Can pip install from setup.cfg, as if installing from a requirements file?

According to the setuptools documentation, setuptools version 30.3.0 (December 8, 2016) "allows using configuration files (usually setup.cfg) to define package’s metadata and other options which are normally supplied to setup() function". Similar to…
argentpepper
  • 4,202
  • 3
  • 33
  • 45
43
votes
2 answers

How can I include package_data without a MANIFEST.in file?

How can I include package_data for sdist without a MANIFEST.in file? My setup.py looks like this: import setuptools setuptools.setup( name='foo', version='2015.3', license='commercial', packages=setuptools.find_packages(), …
guettli
  • 25,042
  • 81
  • 346
  • 663