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

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
Michael Felt
  • 484
  • 1
  • 4
  • 9
37
votes
4 answers

Distribute a Python package with a compiled dynamic shared library

How do I package a Python module together with a precompiled .so library? Specifically, how do I write setup.py so that when I do this in Python >>> import top_secret_wrapper It can easily find top_secret.so without having to set…
Kit
  • 30,365
  • 39
  • 105
  • 149
37
votes
3 answers

How can I run a Makefile in setup.py?

I need to compile ICU using it's own build mechanism. Therefore the question: How can I run a Makefile from setup.py? Obviously, I only want it to run during the build process, not while installing.
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
36
votes
6 answers

Python distutils, how to get a compiler that is going to be used?

For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py…
Headcrab
  • 6,838
  • 8
  • 40
  • 45
36
votes
2 answers

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. For example, I want to be able to do import foo,…
Joe J
  • 9,985
  • 16
  • 68
  • 100
36
votes
2 answers

Execute a Python script post install using distutils / setuptools

Note: distutils is deprecated and the accepted answer has been updated to use setuptools I'm trying to add a post-install task to Python distutils as described in How to extend distutils with a simple post install script?. The task is supposed to…
kynan
  • 13,235
  • 6
  • 79
  • 81
36
votes
4 answers

Speeding up build process with distutils

I am programming a C++ extension for Python and I am using distutils to compile the project. As the project grows, rebuilding it takes longer and longer. Is there a way to speed up the build process? I read that parallel builds (as with make -j) are…
Lucas
  • 738
  • 7
  • 19
36
votes
3 answers

Distributing a shared library and some C code with a Cython extension module

I'm trying to take some functions from a large C++ shared library (libbig.so) and expose them to Python via Cython. To do so, I've got a little C++ file (small.cpp) that provides a thin wrapper around the functionality from the shared library that I…
Jeff Hammerbacher
  • 4,226
  • 2
  • 29
  • 36
34
votes
2 answers

How can I add post-install scripts to easy_install / setuptools / distutils?

I would like to be able to add a hook to my setup.py that will be run post-install (either when easy_install'ing or when doing python setup.py install). In my project, PySmell, I have some support files for Vim and Emacs. When a user installs…
orestis
  • 16,305
  • 4
  • 25
  • 25
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
4 answers

Finding a file in a Python module distribution

I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the…
Paul
  • 331
  • 1
  • 4
  • 5
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

Building a ctypes-"based" C library with distutils

Following this recommendation, I have written a native C extension library to optimise part of a Python module via ctypes. I chose ctypes over writing a CPython-native library because it was quicker and easier (just a few functions with all tight…
Robie Basak
  • 6,492
  • 2
  • 30
  • 34
30
votes
2 answers

How to include third party Python packages in Sublime Text 2 plugins

I'm writing a sublime text 2 plugin that uses a module SEAPI.py which in itself imports the requests module. Since sublime text 2 uses it's own embedded python interpreter, it doesn't see the requests module installed in my ubuntu machine (I get the…
30
votes
3 answers

setup.py not installing data files

I have a Python library that, in addition to regular Python modules, has some data files that need to go in /usr/local/lib/python2.7/dist-package/mylibrary. Unfortunately, I have been unable to convince setup.py to actually install the data files…
Paul Nathan
  • 39,638
  • 28
  • 112
  • 212