Questions tagged [distutils]

Distutils is the standard packaging system for Python modules and applications.

Distutils is the standard packaging system for Python modules and applications.

It has many high and low level features used to build, distribute and install Python projects. The official documentation page provides a good overview of its capabilities.

1123 questions
84
votes
9 answers

What is the correct way to share package version with setup.py and the package?

With distutils, setuptools, etc. a package version is specified in setup.py: # file: setup.py ... setup( name='foobar', version='1.0.0', # other attributes ) I would like to be able to access the same version number from within the package: >>>…
Jace Browning
  • 11,699
  • 10
  • 66
  • 90
83
votes
4 answers

How do I run tox in a project that has no setup.py?

I would like to use tox to run my unittests in two virtualenvs, since my application has to support 2 different Python versions. My problem is that tox requires a setup.py, but I have none since my application is not a module and has its own…
Kjir
  • 4,437
  • 4
  • 29
  • 34
81
votes
6 answers

pip ignores dependency_links in setup.py

I have dependency_links in my setup.py: ... dependency_links = ['http://github.com/robot-republic/python-s3/tarball/master.tar.gz#egg=python-s3'], ... But it doesn't work. However install_requires works fine. Maybe there are another method to set…
syabro
  • 1,857
  • 2
  • 15
  • 30
75
votes
6 answers

setup.py: renaming src package to project name

Let's say you have a project called proj and in this project you have the following structure: proj/ dists/ doc/ src/ __init__.py xyz.py abc.py test/ setup.py As you can see all the content of your project is in the src…
erikbstack
  • 12,878
  • 21
  • 81
  • 115
72
votes
3 answers

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 some values and code so that the core files are not…
Wayne Walker
  • 2,316
  • 3
  • 23
  • 25
71
votes
2 answers

How to use MinGW's gcc compiler when installing Python package using Pip?

I configured MinGW and distutils so now I can compile extensions using this command: setup.py install MinGW's gcc compiler will be used and package will be installed. For that I installed MinGW and created distutils.cfg file with following…
demalexx
  • 4,661
  • 1
  • 30
  • 34
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
69
votes
4 answers

What is the proper way to work with shared modules in Python development?

I'm working toward adopting Python as part of my team's development tool suite. With the other languages/tools we use, we develop many reusable functions and classes that are specific to the work we do. This standardizes the way we do things and…
Steve Sawyer
  • 1,785
  • 4
  • 18
  • 21
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
4 answers

Cleaning build directory in setup.py

How could I make my setup.py pre-delete and post-delete the build directory?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
64
votes
4 answers

pip 10 and apt: how to avoid "Cannot uninstall X" errors for distutils packages

I am dealing with a legacy Dockerfile. Here is a very simplified version of what I am dealing with: FROM ubuntu:14.04 RUN apt-get -y update && apt-get -y install \ python-pip \ python-numpy # ...and many other packages RUN pip install -U…
elethan
  • 16,408
  • 8
  • 64
  • 87
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
63
votes
6 answers

How to tell distutils to use gcc?

I want to wrap a test project containing C++ and OpenMP code with Cython, and build it with distutils via a setup.py file. The content of my file looks like this: from distutils.core import setup from distutils.extension import Extension from…
clstaudt
  • 21,436
  • 45
  • 156
  • 239
62
votes
12 answers

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 subfolderA subfolderA1 …
Dashing Adam Hughes
  • 1,522
  • 1
  • 13
  • 12
61
votes
4 answers

How can I bundle other files when using cx_freeze?

I'm using Python 2.6 and cx_Freeze 4.1.2 on a Windows system. I've created the setup.py to build my executable and everything works fine. When cx_Freeze runs, it moves everything to the build directory. I have some other files that I would like…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
1
2
3
74 75