-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install python virtual environment with contributed ruamel.yaml #39
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2b3668f
RUAMEL: add contributed ruamel.yaml repo
awnawab 00afad7
YAML reader: create minimal yaml reader class that exports the same A…
awnawab 17de137
Increase CMake version to 3.20 to use cmake_path utils
awnawab 89dc4cb
VENV: install python virtualenv with ruamel and fypp
awnawab 8c4f39a
Add tests for fckit_yaml_reader
awnawab 977cb4d
Restore fckit-eval script processing of fypp
awnawab 10ca617
Disable pip upgrade warnings
awnawab 06f9346
Downgrade minimum cmake to 3.17
awnawab 7ebddc8
Make python virtual environment installation optional
awnawab b77220a
Fix copyright header dates and replace message with ecbuild_info
awnawab a18d4f0
Upgrade fypp installation to pep517
awnawab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
build/* | ||
build | ||
install/* | ||
CMakeLists.txt.user | ||
**/*.egg-info/ | ||
__pycache__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,70 @@ | ||||||
# (C) Copyright 2013 ECMWF. | ||||||
# | ||||||
# This software is licensed under the terms of the Apache Licence Version 2.0 | ||||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||||||
# In applying this licence, ECMWF does not waive the privileges and immunities | ||||||
# granted to it by virtue of its status as an intergovernmental organisation nor | ||||||
# does it submit to any jurisdiction. | ||||||
|
||||||
macro( fckit_install_venv ) | ||||||
|
||||||
# Discover only system install Python 3 | ||||||
set( Python3_FIND_VIRTUALENV STANDARD ) | ||||||
find_package( Python3 COMPONENTS Interpreter REQUIRED ) | ||||||
|
||||||
# Create a loki virtualenv | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
set( VENV_PATH ${CMAKE_CURRENT_BINARY_DIR}/venv ) | ||||||
message( STATUS "Create Python virtual environment ${VENV_PATH}" ) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||||||
execute_process( COMMAND ${Python3_EXECUTABLE} -m venv --copies "${VENV_PATH}" ) | ||||||
|
||||||
# Make the virtualenv portable by automatically deducing the VIRTUAL_ENV path from | ||||||
# the 'activate' script's location in the filesystem | ||||||
execute_process( | ||||||
COMMAND | ||||||
sed -i "s/^VIRTUAL_ENV=\".*\"$/VIRTUAL_ENV=\"$(cd \"$(dirname \"$(dirname \"\${BASH_SOURCE[0]}\" )\")\" \\&\\& pwd)\"/" "${VENV_PATH}/bin/activate" | ||||||
) | ||||||
|
||||||
# Change the context of the search to only find the venv | ||||||
set( Python3_FIND_VIRTUALENV ONLY ) | ||||||
|
||||||
# Unset Python3_EXECUTABLE because it is also an input variable | ||||||
# (see documentation, Artifacts Specification section) | ||||||
set( Python3_EXECUTABLE_CACHE ${Python3_EXECUTABLE} ) | ||||||
unset( Python3_EXECUTABLE ) | ||||||
# To allow cmake to discover the newly created venv if Python3_ROOT_DIR | ||||||
# was passed as an argument at build-time | ||||||
set( Python3_ROOT_DIR "${VENV_PATH}" ) | ||||||
|
||||||
# Find newly created python venv | ||||||
find_package( Python3 COMPONENTS Interpreter REQUIRED ) | ||||||
|
||||||
set( _pkg_name "fckit_yaml_reader") | ||||||
if( HAVE_TESTS ) | ||||||
set( _pkg_name "fckit_yaml_reader/[tests]") | ||||||
endif() | ||||||
|
||||||
message( STATUS "Install fckit_yaml_reader in virtual environment ${VENV_PATH}" ) | ||||||
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install --disable-pip-version-check ${CMAKE_CURRENT_SOURCE_DIR}/src/fckit/${_pkg_name} OUTPUT_QUIET ) | ||||||
|
||||||
# install ruamel | ||||||
message( STATUS "Install ruamel.yaml in virtual environment ${VENV_PATH}" ) | ||||||
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install --disable-pip-version-check ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ruamel.yaml-0.18.6 OUTPUT_QUIET ) | ||||||
|
||||||
# install fypp | ||||||
message( STATUS "Install fypp in virtual environment ${VENV_PATH}" ) | ||||||
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install --disable-pip-version-check ${CMAKE_CURRENT_SOURCE_DIR}/contrib/fypp-3.2-b8dd58b-20230822 OUTPUT_QUIET ) | ||||||
|
||||||
install( DIRECTORY ${VENV_PATH} DESTINATION . PATTERN "bin/*" PERMISSIONS ${install_permissions} ) | ||||||
|
||||||
# add python interpreter of venv as executable target | ||||||
set( FCKIT_VENV_EXE ${Python3_EXECUTABLE} ) | ||||||
|
||||||
# compute relative path to venv to aid with installation | ||||||
cmake_path( RELATIVE_PATH FCKIT_VENV_EXE BASE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_VARIABLE rel_venv_exe_path ) | ||||||
|
||||||
set( FYPP ${CMAKE_CURRENT_SOURCE_DIR}/tools/fckit-eval.sh ${FCKIT_VENV_EXE} -m fypp ) | ||||||
|
||||||
# reset Python3_EXECUTABLE to the system install | ||||||
set( Python3_EXECUTABLE ${Python3_EXECUTABLE_CACHE} ) | ||||||
|
||||||
endmacro() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.