Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.extension
Commits
1da0b5e8
Commit
1da0b5e8
authored
11 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Replace the use of string.maketrans with something that can also work with Python3
parent
de834bdd
Branches
Branches containing commit
Tags
v0.1.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xbob/extension/__init__.py
+17
-10
17 additions, 10 deletions
xbob/extension/__init__.py
with
17 additions
and
10 deletions
xbob/extension/__init__.py
+
17
−
10
View file @
1da0b5e8
#!/usr/bin/env python
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# vim: set fileencoding=utf-8 :
# Andre Anjos <andre.anjos@idiap.ch>
# Andre Anjos <andre.anjos@idiap.ch>
# Mon 28 Jan 2013 16:40:27 CET
# Mon 28 Jan 2013 16:40:27 CET
"""
A custom build class for Bob/Python extensions
"""
A custom build class for Bob/Python extensions
"""
"""
...
@@ -92,8 +92,15 @@ def pkgconfig(package):
...
@@ -92,8 +92,15 @@ def pkgconfig(package):
for
k
,
v
in
kw
.
items
():
# remove duplicated
for
k
,
v
in
kw
.
items
():
# remove duplicated
kw
[
k
]
=
uniq
(
v
)
kw
[
k
]
=
uniq
(
v
)
try
:
# Python 3 style
maketrans
=
''
.
maketrans
except
AttributeError
:
# fallback for Python 2
from
string
import
maketrans
# adds version and HAVE flags
# adds version and HAVE flags
PACKAGE
=
package
.
upper
().
translate
(
string
.
maketrans
(
"
-
"
,
"
__
"
))
PACKAGE
=
package
.
upper
().
translate
(
maketrans
(
"
-
"
,
"
__
"
))
kw
[
'
define_macros
'
]
=
[
kw
[
'
define_macros
'
]
=
[
(
'
HAVE_%s
'
%
PACKAGE
,
'
1
'
),
(
'
HAVE_%s
'
%
PACKAGE
,
'
1
'
),
(
'
%s_VERSION
'
%
PACKAGE
,
'"
%s
"'
%
version
),
(
'
%s_VERSION
'
%
PACKAGE
,
'"
%s
"'
%
version
),
...
@@ -110,28 +117,28 @@ def uniq(seq):
...
@@ -110,28 +117,28 @@ def uniq(seq):
class
Extension
(
ExtensionBase
):
class
Extension
(
ExtensionBase
):
"""
Extension building with Bob/Python bindings.
"""
Extension building with Bob/Python bindings.
See the documentation for :py:class:`distutils.extension.Extension` for more
See the documentation for :py:class:`distutils.extension.Extension` for more
details on input parameters.
details on input parameters.
"""
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
Initialize the extension with parameters.
"""
Initialize the extension with parameters.
Bob/Python adds a single parameter to the standard arguments of the
Bob/Python adds a single parameter to the standard arguments of the
constructor:
constructor:
pkgconfig : [list]
pkgconfig : [list]
This should be a list of strings indicating the name of the bob
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
(pkg-config) modules you would like to have linked to your extension
**additionally** to ``bob-python``. Candidates are module names like
**additionally** to ``bob-python``. Candidates are module names like
"
bob-machine
"
or
"
bob-math
"
.
"
bob-machine
"
or
"
bob-math
"
.
For convenience, you can also specify
"
opencv
"
or other
'
pkg-config
'
For convenience, you can also specify
"
opencv
"
or other
'
pkg-config
'
registered packages as a dependencies.
registered packages as a dependencies.
"""
"""
modules
=
[
'
bob-python
'
]
modules
=
[
'
bob-python
'
]
if
'
pkgconfig
'
in
kwargs
and
kwargs
[
'
pkgconfig
'
]:
if
'
pkgconfig
'
in
kwargs
and
kwargs
[
'
pkgconfig
'
]:
...
@@ -170,7 +177,7 @@ class Extension(ExtensionBase):
...
@@ -170,7 +177,7 @@ class Extension(ExtensionBase):
# Filter and make unique
# Filter and make unique
for
key
in
parameters
.
keys
():
for
key
in
parameters
.
keys
():
parameters
[
key
]
=
uniq
(
parameters
[
key
])
parameters
[
key
]
=
uniq
(
parameters
[
key
])
# Tune input parameters if they were set
# Tune input parameters if they were set
if
key
in
kwargs
:
kwargs
[
key
].
extend
(
parameters
[
key
])
if
key
in
kwargs
:
kwargs
[
key
].
extend
(
parameters
[
key
])
else
:
kwargs
[
key
]
=
parameters
[
key
]
else
:
kwargs
[
key
]
=
parameters
[
key
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment