Questions tagged [setup.py]
setup.py is a Python script required by libraries packaged and distributed with Distutils.
1,759
questions
1593
votes
10
answers
1.2m
views
What is setup.py?
What is setup.py and how can it be configured or used?
941
votes
18
answers
540k
views
python setup.py uninstall
I have installed a python package with python setup.py install.
How do I uninstall it?
914
votes
22
answers
820k
views
Why is python setup.py saying invalid command 'bdist_wheel' on Travis CI?
My Python package has a setup.py which builds fine locally on Ubuntu Trusty and on a fresh Vagrant Ubuntu Trusty VM when I provision it like this:
sudo apt-get install python python-dev --force-yes --...
880
votes
43
answers
960k
views
error: Unable to find vcvarsall.bat
I tried to install the Python package dulwich:
pip install dulwich
But I get a cryptic error message:
error: Unable to find vcvarsall.bat
The same happens if I try installing the package manually:
...
444
votes
24
answers
984k
views
Python 3: ImportError "No Module named Setuptools"
I'm having troubles with installing packages in Python 3.
I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get:
importerror "No ...
402
votes
25
answers
298k
views
Standard way to embed version into Python package?
Is there a standard way to associate version string with a Python package in such way that I could do the following?
import foo
print(foo.version)
I would imagine there's some way to retrieve that ...
247
votes
5
answers
116k
views
requirements.txt vs setup.py
I started working with Python. I've added requirements.txt and setup.py to my project. But, I am still confused about the purpose of both files. I have read that setup.py is designed for ...
167
votes
6
answers
414k
views
How do I install Python packages in Google's Colab?
In a project, I have e.g. two different packages, How can I use the setup.py to install these two packages in the Google's Colab, so that I can import the packages?
155
votes
3
answers
111k
views
Difference between 'python setup.py install' and 'pip install'
I have an external package I want to install into my python virtualenv from a tar file.
What is the best way to install the package?
I've discovered 2 ways that can do it:
Extract the tar file, then ...
133
votes
7
answers
64k
views
Post-install script with Python setuptools
Is it possible to specify a post-install Python script file as part of the setuptools setup.py file so that a user can run the command:
python setup.py install
on a local project file archive, or
...
114
votes
7
answers
289k
views
No module named setuptools
I want to install setup file of twilio. When I install it through given command it is given me an error:
No module named setuptools.
Could you please let me know what should I do?
I am using ...
114
votes
6
answers
50k
views
pip install . creates only the dist-info not the package
I am trying to make a python package which I want to install using pip install . locally. The package name is listed in pip freeze but import <package> results in an error No module named <...
112
votes
4
answers
45k
views
When to use pip requirements file versus install_requires in setup.py?
I'm using pip with virtualenv to package and install some Python libraries.
I'd imagine what I'm doing is a pretty common scenario. I'm the maintainer on several libraries for which I can specify ...
108
votes
4
answers
43k
views
Difference between entry_points/console_scripts and scripts in setup.py?
There are basically two ways to install Python console scripts to my path by setup.py:
setup(
...
entry_points = {
'console_scripts': [
'foo = package.module:func',
...
98
votes
3
answers
66k
views
What is the difference between `extras_require()` and `install_requires()` in setup.py?
I am trying to understand the difference between extras_require() and install_requires() in setup.py but haven't been able to get it. Both are used for installing Python dependencies, but what's the ...
89
votes
8
answers
57k
views
distutils: How to pass a user defined parameter to setup.py?
How can I pass a user-defined parameter both from the command line and setup.cfg configuration file to distutils' setup.py script?
I want to write a setup.py script, which accepts my package specific ...
76
votes
3
answers
42k
views
How may I override the compiler (GCC) flags that setup.py uses by default?
I understand that setup.py uses the same CFLAGS that were used to build Python. I have a single C extension of ours that is segfaulting. I need to build it without -O2 because -O2 is optimizing out ...
69
votes
5
answers
30k
views
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, ...
64
votes
8
answers
61k
views
Using an extra python package index url with setup.py
Is there a way to use an extra Python package index (ala pip --extra-index-url pypi.example.org mypackage) with setup.py so that running python setup.py install can find the packages hosted on pypi....
63
votes
12
answers
43k
views
How to add package data recursively in Python setup.py?
I have a new library that has to include a lot of subfolders of small datafiles, and I'm trying to add them as package data. Imagine I have my library as so:
library
- foo.py
- bar.py
data
...
50
votes
9
answers
45k
views
Is it possible to include subdirectories using dist utils (setup.py) as part of package data?
Basically my python package is setup like:
module
\_examples
\_folder1
\_file1.py
\_file2.py
\_folder2
\_file1.py
\_file2.py
Basically I want to just use:
package_data = {
...
50
votes
2
answers
44k
views
Specifying command line scripts in pyproject.toml
I'm trying to add a pyproject.toml to a project that's been using setup.py in order to enable support by pipx. I'd like to specify the command line scripts the project includes in pyproject.toml, but ...
50
votes
6
answers
44k
views
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 ...
49
votes
5
answers
16k
views
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 ...
49
votes
1
answer
59k
views
Install python packages to correct anaconda environment
I've setup anaconda and created a python 3.3 environment. Now I wanted to install some package (dataset). The install instructions ask to clone the git repo and run
python setup.py install
but now ...
48
votes
4
answers
27k
views
make distutils in Python automatically find packages
When describing a python package in setup.py in distutils in Python, is there a way to make it so automatically get every directory that has a __init__.py in it and include that as a subpackage?
ie ...
46
votes
7
answers
59k
views
How can you bundle all your python code into a single zip file?
It would be convenient when distributing applications to combine all of the eggs into a single zip file so that all you need to distribute is a single zip file and an executable (some custom binary ...
44
votes
1
answer
21k
views
Specifying optional dependencies in pypi python setup.py
How do I specify optional dependencies in python's setup.py ?
Here's my stab at specifying an optional dependency for an open source library of mine but it doesn't seem to do much.
https://github....
43
votes
2
answers
30k
views
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',
...
43
votes
2
answers
15k
views
Setting up setup.py for packaging of a single .py file and a single data file without needing to create any folders
Project tree:
$.
├── happy_birthday-art.txt
├── happy_birthday.py
├── MANIFEST.in
├── README.rst
└── setup.py
setup.py
from setuptools import setup
setup(
name='Happy_birthday',
py_modules=...
40
votes
2
answers
70k
views
Python setup.py: How to get find_packages() to identify packages in subdirectories
I'm trying to create a setup.py file where find_packages() recursively finds packages. In this example, foo, bar, and baz are all modules that I want to be installed and available on the python path. ...
40
votes
1
answer
15k
views
What is the graft command in Python's MANIFEST.in file?
I found a Python project with a MANIFEST.in file. I can guess at the meaning of much of it, but I am unclear on the meaning of the line:
graft tools
37
votes
3
answers
11k
views
setup.py: restrict the allowable version of the python interpreter
I have a Python library. Unfortunately I have not updated it to work with Python 3 yet.
In its setup.py, I added
install_requires=['python<3'],
My intent was to not allow this package to be ...
35
votes
2
answers
13k
views
Using setup.py to install python project as a systemd service
I have a python project and I want to be able to install it using something like python setup.py install so that the installation automatically creates a systemd service.
I'm having some trouble, ...
33
votes
11
answers
74k
views
Why can't I find ansible when I install it using setup.py?
Because I had some trouble with Ansible (I'm on mac) which seemed to be fixed in the latest dev version today I uninstalled ansible through pip (sudo pip uninstall ansible) and reinstalled the latest ...
33
votes
1
answer
18k
views
How to include docs directory in python distribution
I have a python project with the following structure:
Clustering (project name)
clustering (package)
clustering.py and other modules
tests (sub-package)
test_clustering.py and ...
32
votes
2
answers
13k
views
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
......
32
votes
1
answer
13k
views
Is there complete documentation for `setup.cfg`?
The Python Packaging Tutorial recommends that "Static metadata (setup.cfg) should be preferred. Dynamic metadata (setup.py) should be used only as an escape hatch when absolutely necessary. setup....
31
votes
1
answer
20k
views
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
31
votes
6
answers
16k
views
pip install PyQt IOError
I'm trying to install PyQt package with pip, but I get this error:
~$ pip install PyQt
Downloading/unpacking PyQt
Downloading PyQt-x11-gpl-4.8.3.tar.gz
(9.8Mb): 9.8Mb downloaded Running
setup.py ...
31
votes
1
answer
14k
views
Any python function to get "data_files" root directory?
This should be a very common question for developers who used "setup.py" to build installation packages and it should be asked before but I couldn't find the proper answer anywhere.
In setup.py
from ...
30
votes
3
answers
12k
views
python setup.py sdist only including .py source from top level module
I have a setup.py:
from setuptools import setup
setup(
...
packages=['mypackage'],
test_suite='mypackage.tests',
...
)
python setup.py sdist creates a file that includes ...
30
votes
3
answers
13k
views
Is there a simple way to convert setup.py to pyproject.toml
We have multiple python projects, and are considering converting them to use pyproject.toml instead of setup.py.
Is there a simple way to automate this?
30
votes
5
answers
12k
views
Force compiler when running python setup.py install
Is there a way to explicitly force the compiler for building Cython extensions when running python setup.py install? Where setup.py is of the form:
import os.path
import numpy as np
from setuptools ...
30
votes
1
answer
3k
views
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 ...
28
votes
5
answers
21k
views
How to force a python wheel to be platform specific when building it?
I am working on a python2 package in which the setup.py contains some custom install commands. These commands actually build some Rust code and output some .dylib files that are moved into the python ...
28
votes
2
answers
24k
views
Cython setup.py for several .pyx
I would like to cythonize faster. Code for one .pyx is
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("MyFile.pyx")
)
What if i want to ...
28
votes
2
answers
2k
views
how to set bug tracker url in setup.py script
I have just discovered the pypi web UI have a field 'Bug tracker URL' in edit of egg metadata.
This field exists so I guess it is supported in setup.py but I can't find anything about this using ...
27
votes
3
answers
8k
views
How to use setup.py to install dependencies only?
I am not interested in installing my package itself but I am interested installing all the dependencies used by my package. Is there a way to do this using setup.py? It seems setup.py installs my ...
27
votes
2
answers
5k
views
How to build a C extension in keeping with PEP 517, i.e. with pyproject.toml instead of setup.py?
I want to build a C extension for CPython. I could do it traditionally with a setup.py file. However, for the reasons mentioned in PEP 517, I would prefer a declarative approach using a pyproject.toml....