Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Chaofan Chen
ogs
Commits
e95efea8
Commit
e95efea8
authored
3 years ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[cmake] Added find Python setup for OGS_USE_PIP.
parent
63c4705e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/cmake/Features.cmake
+5
-0
5 additions, 0 deletions
scripts/cmake/Features.cmake
scripts/cmake/PythonCreateVirtualEnv.cmake
+19
-0
19 additions, 0 deletions
scripts/cmake/PythonCreateVirtualEnv.cmake
scripts/cmake/PythonSetup.cmake
+22
-15
22 additions, 15 deletions
scripts/cmake/PythonSetup.cmake
with
46 additions
and
15 deletions
scripts/cmake/Features.cmake
+
5
−
0
View file @
e95efea8
...
@@ -14,6 +14,11 @@ add_feature_info(
...
@@ -14,6 +14,11 @@ add_feature_info(
Python-interface OGS_USE_PYTHON
Python-interface OGS_USE_PYTHON
"Python boundary conditions and source terms (OGS_USE_PYTHON)"
"Python boundary conditions and source terms (OGS_USE_PYTHON)"
)
)
add_feature_info
(
Python-environment
OGS_USE_PIP
"Automatic Python dependency handling with a virtual environment (OGS_USE_PIP)"
)
add_feature_info
(
PETSc OGS_USE_PETSC
"Parallel processing (OGS_USE_PETSC)"
)
add_feature_info
(
PETSc OGS_USE_PETSC
"Parallel processing (OGS_USE_PETSC)"
)
add_feature_info
(
add_feature_info
(
Tests OGS_BUILD_TESTING
"Unit and benchmarks tests (OGS_BUILD_TESTING)"
Tests OGS_BUILD_TESTING
"Unit and benchmarks tests (OGS_BUILD_TESTING)"
...
...
This diff is collapsed.
Click to expand it.
scripts/cmake/PythonCreateVirtualEnv.cmake
0 → 100644
+
19
−
0
View file @
e95efea8
# cmake-lint: disable=C0103
message
(
STATUS
"┌─ PythonCreateVirtualEnv.cmake"
)
list
(
APPEND CMAKE_MESSAGE_INDENT
"│ "
)
# Prefer unix location over frameworks (Apple-only)
set
(
Python_FIND_FRAMEWORK LAST
)
# Prefer more recent Python version
set
(
Python_FIND_STRATEGY VERSION
)
find_package
(
Python
${
python_version
}
COMPONENTS Interpreter REQUIRED
)
execute_process
(
COMMAND
${
Python_EXECUTABLE
}
-m venv .venv
WORKING_DIRECTORY
${
PROJECT_BINARY_DIR
}
)
list
(
POP_BACK CMAKE_MESSAGE_INDENT
)
message
(
STATUS
"└─ End PythonCreateVirtualEnv.cmake"
)
This diff is collapsed.
Click to expand it.
scripts/cmake/PythonSetup.cmake
+
22
−
15
View file @
e95efea8
# cmake-lint: disable=C0103
# cmake-lint: disable=C0103
# Prefer unix location over frameworks (Apple-only)
if
(
OGS_USE_PIP
)
set
(
Python_FIND_FRAMEWORK LAST
)
set
(
Python_ROOT_DIR
${
PROJECT_BINARY_DIR
}
/.venv
)
# Prefer more recent Python version
set
(
Python_FIND_STRATEGY VERSION
)
set
(
_python_componets Interpreter
)
if
(
OGS_USE_PYTHON OR OGS_USE_PIP
)
set
(
CMAKE_REQUIRE_FIND_PACKAGE_Python TRUE
)
set
(
CMAKE_REQUIRE_FIND_PACKAGE_Python TRUE
)
if
(
NOT EXISTS
${
PROJECT_BINARY_DIR
}
/.venv
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-DPROJECT_BINARY_DIR=
${
PROJECT_BINARY_DIR
}
-Dpython_version=
${
ogs.minimum_version.python
}
-P
${
PROJECT_SOURCE_DIR
}
/scripts/cmake/PythonCreateVirtualEnv.cmake
WORKING_DIRECTORY
${
PROJECT_BINARY_DIR
}
COMMAND_ECHO STDOUT
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
unset
(
_OGS_PYTHON_PACKAGES_SHA1 CACHE
)
endif
()
else
()
# Prefer unix location over frameworks (Apple-only)
set
(
Python_FIND_FRAMEWORK LAST
)
# Prefer more recent Python version
set
(
Python_FIND_STRATEGY VERSION
)
endif
()
endif
()
set
(
_python_componets Interpreter
)
if
(
OGS_USE_PYTHON
)
if
(
OGS_USE_PYTHON
)
set
(
CMAKE_REQUIRE_FIND_PACKAGE_Python TRUE
)
list
(
APPEND _python_componets Development
)
list
(
APPEND _python_componets Development
)
endif
()
endif
()
find_package
(
find_package
(
...
@@ -20,14 +35,6 @@ if(OGS_USE_PIP)
...
@@ -20,14 +35,6 @@ if(OGS_USE_PIP)
set
(
OGS_PYTHON_PACKAGES
""
set
(
OGS_PYTHON_PACKAGES
""
CACHE INTERNAL
"List of Python packages to be installed via pip."
CACHE INTERNAL
"List of Python packages to be installed via pip."
)
)
if
(
NOT EXISTS
${
PROJECT_BINARY_DIR
}
/.venv
)
execute_process
(
COMMAND
${
Python_EXECUTABLE
}
-m venv .venv
WORKING_DIRECTORY
${
PROJECT_BINARY_DIR
}
)
unset
(
_OGS_PYTHON_PACKAGES_SHA1 CACHE
)
endif
()
set
(
Python_ROOT_DIR
${
PROJECT_BINARY_DIR
}
/.venv
)
set
(
Python_ROOT_DIR
${
PROJECT_BINARY_DIR
}
/.venv
)
if
(
MSVC
)
if
(
MSVC
)
set
(
Python_EXECUTABLE
${
Python_ROOT_DIR
}
/Scripts/python.exe
)
set
(
Python_EXECUTABLE
${
Python_ROOT_DIR
}
/Scripts/python.exe
)
...
...
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