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
Merge requests
!62
Add CONDA_PREFIX to the search path
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add CONDA_PREFIX to the search path
conda-prefix
into
master
Overview
3
Commits
3
Pipelines
5
Changes
1
Merged
Amir MOHAMMADI
requested to merge
conda-prefix
into
master
7 years ago
Overview
3
Commits
3
Pipelines
5
Changes
1
Expand
0
0
Merge request reports
Viewing commit
26a19b12
Prev
Next
Show latest version
1 file
+
34
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
26a19b12
Add CONDA_PREFIX to the search path of pkg-config
· 26a19b12
Amir MOHAMMADI
authored
7 years ago
bob/extension/pkgconfig.py
+
30
−
25
Options
@@ -7,12 +7,35 @@ import os
import
sys
import
subprocess
import
logging
from
.utils
import
uniq
,
uniq_paths
,
find_executable
from
.utils
import
uniq
,
uniq_paths
,
find_executable
,
construct_search_paths
def
call_pkgconfig
(
cmd
,
paths
=
None
):
"""
Runs a command as a subprocess and raises if that does not work
Returns the exit status, stdout and stderr.
def
call_pkgconfig
(
cmd
,
paths
=
None
):
"""
Calls pkg-config with a constructed PKG_CONFIG_PATH environment variable.
The PKG_CONFIG_PATH variable is constructed using
:any:`construct_search_paths`.
Parameters
----------
cmd : [str]
A list of commands to be given to pkg-config.
paths : [str]
A list of paths to be added to PKG_CONFIG_PATH.
Returns
-------
returncode : int
The exit status of pkg-config.
stdout : str
The stdout output of pkg-config.
stderr : str
The stderr output of pkg-config.
Raises
------
OSError
If the `pkg-config
'
executable is not found.
"""
# locates the pkg-config program
@@ -20,27 +43,8 @@ def call_pkgconfig(cmd, paths=None):
if
not
pkg_config
:
raise
OSError
(
"
Cannot find `pkg-config
'
- did you install it?
"
)
# sets the PKG_CONFIG_PATH taking into consideration:
# 1. BOB_PREFIX_PATH, if set
# 2. the paths set by the user
# 3. the current python executable prefix
# 1. BOB_PREFIX_PATH
bob_prefix
=
os
.
environ
.
get
(
'
BOB_PREFIX_PATH
'
,
False
)
if
bob_prefix
:
bob_prefix
=
bob_prefix
.
split
(
os
.
pathsep
)
pkg_path
=
[
os
.
path
.
join
(
k
,
'
lib
'
,
'
pkgconfig
'
)
for
k
in
bob_prefix
]
else
:
pkg_path
=
[]
# 2. user path
if
paths
:
pkg_path
+=
paths
# 3. adds the current python executable prefix
pkg_path
.
append
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
sys
.
executable
)),
'
lib
'
,
'
pkgconfig
'
))
# Make unique to avoid searching twice
pkg_path
=
uniq_paths
(
pkg_path
)
pkg_path
=
construct_search_paths
(
prefixes
=
paths
,
suffix
=
os
.
sep
+
'
lib
'
+
os
.
sep
+
'
pkgconfig
'
)
env
=
os
.
environ
.
copy
()
var
=
os
.
pathsep
.
join
(
pkg_path
)
@@ -83,6 +87,7 @@ def version():
return
stdout
.
strip
()
class
pkgconfig
:
"""
A class for capturing configuration information from pkg-config
Loading