Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Core Modules
dune-common
Commits
e6d72f8f
Commit
e6d72f8f
authored
3 years ago
by
Andreas Dedner
Browse files
Options
Downloads
Patches
Plain Diff
use an external venv if active
parent
79359e69
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!960
refactor the way python is used in dune
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmake/modules/DunePythonVirtualenv.cmake
+10
-0
10 additions, 0 deletions
cmake/modules/DunePythonVirtualenv.cmake
cmake/scripts/CMakeLists.txt
+1
-0
1 addition, 0 deletions
cmake/scripts/CMakeLists.txt
cmake/scripts/venvpath.py
+24
-0
24 additions, 0 deletions
cmake/scripts/venvpath.py
with
35 additions
and
0 deletions
cmake/modules/DunePythonVirtualenv.cmake
+
10
−
0
View file @
e6d72f8f
...
...
@@ -82,6 +82,16 @@ set(DUNE_PYTHON_EXTERNAL_VIRTUALENV_FOR_ABSOLUTE_BUILDDIR ON CACHE BOOL
"Place Python virtualenv in top-level directory
\"
dune-python-env
\"
when using an absolute build directory"
)
# check if we are in a venv already
if
(
DUNE_PYTHON_VIRTUALENV_PATH STREQUAL
""
)
dune_execute_process
(
COMMAND
${
Python3_EXECUTABLE
}
${
scriptdir
}
/venvpath.py
OUTPUT_VARIABLE DUNE_PYTHON_VIRTUALENV_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif
()
# if no virtual env path set so far check dune modules
if
(
DUNE_PYTHON_VIRTUALENV_PATH STREQUAL
""
)
foreach
(
mod
${
ALL_DEPENDENCIES
}
)
if
(
IS_DIRECTORY
${${
mod
}
_DIR
}
/dune-env
)
...
...
This diff is collapsed.
Click to expand it.
cmake/scripts/CMakeLists.txt
+
1
−
0
View file @
e6d72f8f
...
...
@@ -3,6 +3,7 @@ install(FILES
conf.py.in
CreateDoxyFile.cmake
envdetect.py
venvpath.py
FinalizeHeadercheck.cmake
index.rst.in
InstallFile.cmake
...
...
This diff is collapsed.
Click to expand it.
cmake/scripts/venvpath.py
0 → 100644
+
24
−
0
View file @
e6d72f8f
import
sys
,
os
def
inVEnv
():
# check whether we are in a anaconda environment
# were the checks based on prefix and base_prefix
# seem to fail
if
"
CONDA_DEFAULT_ENV
"
in
os
.
environ
:
return
1
# If sys.real_prefix exists, this is a virtualenv set up with the virtualenv package
real_prefix
=
hasattr
(
sys
,
'
real_prefix
'
)
if
real_prefix
:
return
1
# If a virtualenv is set up with pyvenv, we check for equality of base_prefix and prefix
if
hasattr
(
sys
,
'
base_prefix
'
):
return
(
sys
.
prefix
!=
sys
.
base_prefix
)
# If none of the above conditions triggered, this is probably no virtualenv interpreter
return
0
if
__name__
==
"
__main__
"
:
if
not
inVEnv
():
print
(
""
)
else
:
print
(
sys
.
prefix
)
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