Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify more than one include directories for setup.py from command line?

Here I found how to write setup.py file for compiling my own C/C++ modules for python, but I can't specify more than one include directories from command line.

Please tell me the syntax how should I specify a list of directories from command line for setup.py.

like image 332
Samvel Hovsepyan Avatar asked Jun 27 '14 15:06

Samvel Hovsepyan


People also ask

What directory is setup py?

To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

What is PIP setuptools?

Setuptools is a collection of enhancements to the Python distutils that allow developers to more easily build and distribute Python packages, especially ones that have dependencies on other packages.

Is setup py deprecated?

You may still find advice all over the place that involves invoking setup.py directly, but unfortunately this is no longer good advice because as of the last few years all direct invocations of setup.py are effectively deprecated in favor of invocations via purpose-built and/or standards-based CLI tools like pip, build ...


3 Answers

I found the solution it should look like this

python setup.py build_ext --inplace --library-dirs=lib_dir1;lib_dir2 --include-dirs=inc_dir1;inc_dir2
like image 65
Samvel Hovsepyan Avatar answered Oct 03 '22 02:10

Samvel Hovsepyan


The help for setup.py tells, you can specify multiple values delimited by ":"

Shortened output:

$ python setup.py build_ext --help
Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package

Options for 'build_ext' command:
  --include-dirs (-I)  list of directories to search for header files
                       (separated by ':')
like image 29
Jan Vlcinsky Avatar answered Oct 03 '22 02:10

Jan Vlcinsky


alternative option inside setup.py:

#! /bin/python
environ['CPPFLAGS'] = '-I/usr/local/opt/openssl/include -I/usr/include -I/usr/local/include'
environ['LDFLAGS'] = '-L/usr/local/opt/lib1/lib -L/usr/local/opt/lib2/lib'

alternative option from unix cli:

#! /bin/bash
export CPPFLAGS='-I/usr/local/opt/openssl/include -I/usr/include -I/usr/local/include'
export LDFLAGS='-L/usr/local/opt/lib1/lib -L/usr/local/opt/lib2/lib'

fyi, I used the environ example to install pycurl from my projects setup.py after searching for a long time.

like image 43
jmunsch Avatar answered Oct 03 '22 00:10

jmunsch