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
33
votes
2 answers

How do I force `setup.py test` to install dependencies into my `virtualenv`?

In a crusade to make my application pip-installable, I'm fighting big fights with setuptools and distribute. I assume my dependencies are correct, i.e. installing with pip install myapp should probably fill the virtual environment correctly.…
Nikolai Prokoschenko
  • 8,465
  • 11
  • 58
  • 97
33
votes
1 answer

What keyword arguments does setuptools.setup() accept?

What is the full list of keyword arguments that the setuptools.setup() function accepts? (Please include a description of what each argument means, if possible.) I have looked all over the web and I can't believe this isn't documented. I found…
cowlinator
  • 7,195
  • 6
  • 41
  • 61
33
votes
3 answers

setup_requires with Cython?

I'm creating a setup.py file for a project with some Cython extension modules. I've already gotten this to work: from setuptools import setup, Extension from Cython.Build import cythonize setup( name=..., ..., ext_modules=cythonize([…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
32
votes
3 answers

Pipenv vs setup.py

I am trying to migrate to pipenv. I traditionally used setup.py with pip and did pip install -e . to install the module as a package, so that I can achieve stuff like from myproject.xyz.abc import myClass from anywhere within the project. How do I…
khan
  • 7,005
  • 15
  • 48
  • 70
32
votes
1 answer

Distributing multiple packages using setup.py for Python

I'm trying to setup some Python packages that will share a common set of "utilities" but need to be able to distribute them as separate "packages." Assume the following structure: /packages |-setup.py |-__init__.py |-MANIFEST.in …
Rob Marshall
  • 599
  • 1
  • 4
  • 11
32
votes
2 answers

What does the `platforms` argument to `setup()` in `setup.py` do?

Looking through several projects recently, I noticed some of them use platforms argument to setup() in setup.py, though with only one value of any, i.e. #setup.py file in project's package folder ... setup( ..., platforms=['any'], …
Nikita
  • 6,101
  • 2
  • 26
  • 44
32
votes
1 answer

How can I use setuptools to generate a console_scripts entry point which calls `python -m mypackage`?

I am trying to be a good Pythonista and following PEP 338 for my package I plan on deploying. I am also trying to generate my executable scripts upon python setuptools install using setuptools entry_points{'console_scripts': ... } options. How can…
32
votes
2 answers

MANIFEST.in, package_data, and data_files clarification?

I am trying to create a Python package, and I have a directory structure like this: mypkg/ ├── __init__.py ├── module1 │   ├── x.py │   ├── y.py │   └── z.txt └── module2 ├── a.py └── b.py Then I added all the files in MANIFEST.in and when…
Sourabh
  • 1,091
  • 11
  • 13
31
votes
3 answers

How to build a source distribution without using setup.py file?

With the following package structure . ├── my_package │ └── __init__.py ├── setup.cfg └── setup.py Contents of setup.py from setuptools import setup setup() Contents of setup.cfg [metadata] name = my_package version = 0.1 [options] packages =…
platypus
  • 1,128
  • 8
  • 15
31
votes
5 answers

KeyError / frozen importlib._bootstrap error on second library import in spyder

I receive a File " ", line 978, in _get_parent_path KeyError: 'python_library' error when I import a library from a subfolder the second time in spyder, but the first time (after restarting spyder) or…
Vera
  • 769
  • 1
  • 6
  • 16
31
votes
1 answer

Using python_requires to require Python 2.7 or 3.2+

How do I use python_requires classifier in setup.py to require Python 2.7.* or 3.2+? I have tried many configurations, including this one: ~=2.7,==3,!=3.0,!=3.1,<4 but none have worked
wolfy1339
  • 784
  • 2
  • 7
  • 23
31
votes
2 answers

What is the purpose of Python setuptools?

What is the purpose of setuptools in Python? What if I do not have setuptools or never upgrade setuptools? I read the documentation, but I cannot get the answer.
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
31
votes
4 answers

setup.py sdist exclude packages in subdirectory

I have the following project structure I would like to package: ├── doc │   └── source ├── src │   ├── core │   │   ├── config │   │   │   └── log.tmpl │   │   └── job │   ├── scripts │   └── test └── tools I would like to package core under src…
oz123
  • 27,559
  • 27
  • 125
  • 187
30
votes
3 answers

"InvalidRequirement: Invalid requirement, parse error" error after updating a python package

After updating a package (IPython in my case) using pip install -U ipython running any Python script that uses entry points fails with this error: Traceback (most recent call last): File "/home/adrian/dev/indico/env/bin/indico", line 5, in…
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
30
votes
1 answer

should pytest et al. go in tests_require[] or extras_require{testing[]}?

I am writing a python program which uses py.test for testing and now one test also depends on numpy. Where in my setup.py should I add those dependencies? Currently the relevant part of my setup.py looks something like this: [...] 'version':…
Michael Große
  • 1,818
  • 1
  • 16
  • 20