Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.extension
Commits
bb3070c1
Commit
bb3070c1
authored
Feb 05, 2013
by
André Anjos
💬
Browse files
Change bob_modules -> pkgconfig so it is clear; Update README
parent
ead5b6ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.rst
View file @
bb3070c1
...
...
@@ -9,3 +9,60 @@ in the ``setup_requires`` field of your ``setup.py`` file.
Building with ``zc.buildout`` is possible using the ``develop`` recipe in
`xbob.buildout <http://pypi.python.org/pypi/xbob.buildout>`_. Follow the
instructions described on that package for this recipe.
Preparing for C++ Compilation
-----------------------------
Creating C++/Python bindings should be trivial. Firstly, edit your ``setup.py``
so that you include the following::
from xbob.extension import Extension
...
setup(
name="xbob.myext",
version="1.0.0",
...
setup_requires=[
'xbob.extension',
],
...
ext_modules=[
Extension("xbob.myext._myext",
[
"xbob/myext/ext/file1.cpp",
"xbob/myext/ext/file2.cpp",
"xbob/myext/ext/main.cpp",
],
pkgconfig = [ #bob modules you depend on
'bob-math',
'bob-sp',
]
),
... #add more extensions if you wish
],
...
)
These modifications will allow you to compile extensions that are linked
against the named ``pkg-config`` modules. You can specify the modules of
Bob you want to link against. You **don't** have to specify ``bob-python``,
which is automatically added. Furthermore, you can specify any ``pkg-config``
module and that will be linked in (for example, ``opencv``). Other modules and
options can be set manually using `the standard options for python extensions
<http://docs.python.org/2/extending/building.html>`_. To hook-in the building
on the package through ``zc.buildout``, add the following section to your
``buildout.cfg``::
[xbob.myext]
recipe = xbob.buildout:develop
If you need to build multiple eggs, you will need **one entry per project** on
your ``buildout.cfg``. This includes, possibly, dependent projects. Currently,
``zc.buildout`` ignores the ``setup_requires`` entry on your ``setup.py`` file.
The recipe above creates a new interpreter that hooks that package in and
builds the project considering variables like ``prefixes`` into consideration.
setup.py
View file @
bb3070c1
...
...
@@ -11,7 +11,7 @@ from setuptools import setup, find_packages
setup
(
name
=
"xbob.extension"
,
version
=
"0.1.
0
"
,
version
=
"0.1.
1
"
,
description
=
"Helps projects building Python/C++ extensions for Bob"
,
license
=
"GPLv3"
,
author
=
'Andre Anjos'
,
...
...
xbob/extension/__init__.py
View file @
bb3070c1
...
...
@@ -94,7 +94,7 @@ class Extension(ExtensionBase):
Bob/Python adds a single parameter to the standard arguments of the
constructor:
bob_modules
: [list]
pkgconfig
: [list]
This should be a list of strings indicating the name of the bob
(pkg-config) modules you would like to have linked to your extension
...
...
@@ -107,18 +107,13 @@ class Extension(ExtensionBase):
modules
=
[
'bob-python'
]
if
kwargs
.
has_key
(
'
bob_modules
'
)
and
kwargs
[
'
bob_modules
'
]:
if
isinstance
(
kwargs
[
'
bob_modules
'
],
(
str
,
unicode
)):
modules
.
append
(
kwargs
[
'
bob_modules
'
])
if
kwargs
.
has_key
(
'
pkgconfig
'
)
and
kwargs
[
'
pkgconfig
'
]:
if
isinstance
(
kwargs
[
'
pkgconfig
'
],
(
str
,
unicode
)):
modules
.
append
(
kwargs
[
'
pkgconfig
'
])
else
:
modules
.
extend
(
kwargs
[
'
bob_modules
'
])
modules
.
extend
(
kwargs
[
'
pkgconfig
'
])
if
kwargs
.
has_key
(
'bob_modules'
):
del
kwargs
[
'bob_modules'
]
# OpenCV module comes at the back
if
'opencv'
in
modules
:
modules
.
remove
(
'opencv'
)
modules
.
append
(
'opencv'
)
if
kwargs
.
has_key
(
'pkgconfig'
):
del
kwargs
[
'pkgconfig'
]
# Only one instance of each
modules
=
uniq
(
modules
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment