-
Notifications
You must be signed in to change notification settings - Fork 283
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
enhance CMakeMake
easyblock to check whether correct Python installation was picked up by cmake
#3233
Closed
Closed
enhance CMakeMake
easyblock to check whether correct Python installation was picked up by cmake
#3233
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7e3b26a
Sanity check for python configuration
MartinsNadia 40986c8
Sanity check for Python
MartinsNadia 133e3b8
Remove legacy code, integrate python sanity check into configure section
dagonzalezfo 775dde0
Update cmakemake.py
MartinsNadia 067c4cd
teste
MartinsNadia 16b6465
Implementation of path validation for sanitycheck
MartinsNadia cfbe5e5
Fix identation
MartinsNadia 3d82787
Formatting improvements
MartinsNadia c0d5e86
Fixing whitespace
MartinsNadia f260f73
Revised version
MartinsNadia b60ecd6
Revised version - whitespace
MartinsNadia 77884b9
Improve Python check in cmakemake.py
Flamefire 492c330
Merge pull request #2 from Flamefire/patch-1
MartinsNadia c1f005a
Address review
Flamefire 4b3653b
Merge pull request #3 from Flamefire/20240625102843_new_pr_cmakemake
MartinsNadia 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 |
---|---|---|
|
@@ -160,6 +160,7 @@ def prepend_config_opts(self, config_opts): | |
if '-D%s=' % key not in cfg_configopts) | ||
self.cfg['configopts'] = ' '.join([new_opts, cfg_configopts]) | ||
|
||
|
||
def configure_step(self, srcdir=None, builddir=None): | ||
"""Configure build using cmake""" | ||
|
||
|
@@ -318,7 +319,70 @@ def configure_step(self, srcdir=None, builddir=None): | |
|
||
(out, _) = run_cmd(command, log_all=True, simple=False) | ||
|
||
return out | ||
def sanitycheck_for_configuration(self, out): | ||
self.log.info("Checking Python paths") | ||
|
||
if LooseVersion(self.cmake_version) >= '3.16' | ||
try: | ||
with open('CMakeCache.txt', 'r') as file: | ||
lines = file.readlines() | ||
# The case where CMakeCache.txt is not found | ||
except FileNotFoundError: | ||
self.log.warning("CMakeCache.txt not founf. Python paths checks skipped.") | ||
return | ||
# EBROOTPYTHON check | ||
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. And please remove this comment. It doesn't add any information to the code below |
||
if not os.getenv('EBROOTPYTHON'): | ||
self.log.warning("EBROOTPYTHON is not set.") | ||
return | ||
else: | ||
self.log.info ("Skipping Python path checks as CMake version might be lower than 3.16.") | ||
return | ||
|
||
# Initialize empty lists to store paths | ||
python_exec_path = [] | ||
python_include_path = [] | ||
python_library_path = [] | ||
|
||
# Define a regular expression to match all relevant prefixes | ||
python_prefixes = r"(Python|Python2|Python3)_" | ||
|
||
for line in lines: | ||
if line.startswith(python_prefixes + r"EXECUTABLE:FILEPATH="): | ||
python_exec_paths.append(line.split('=')[1].strip()) | ||
self.log.info("Python executable path: %s", python_exec_path[-1]) | ||
elif line.startswith(python_prefixes + r"INCLUDE_DIR:FILEPATH="): | ||
python_include_paths.append(line.split('=')[1].strip()) | ||
self.log.info("Python include path: %s", python_include_path[-1]) | ||
elif line.startswith(python_prefixes + r"LIBRARY:FILEPATH="): | ||
python_library_paths.append(line.split('=')[1].strip()) | ||
self.log.info("Python library path: %s", python_library_path[-1]) | ||
|
||
# Check if paths are found and validate paths for symlinks | ||
for path_list in [python_exec_path, python_include_path, python_library_path]: | ||
for path in path_list: | ||
if path and not os.path.exists(path): | ||
raise EasyBuildError(f"Path does not exist: {path}") | ||
|
||
# Check if paths are found and handle EBROOTPYTHON cases | ||
if any(path for path in [python_exec_path, python_include_path, python_library_path]): | ||
if not os.getenv('EBROOTPYTHON'): | ||
self.log.error("EBROOTPYTHON is not set and Python related paths are found.") | ||
elif not all(path and os.getenv('EBROOTPYTHON') in path for path in [python_exec_path, python_include_path, python_library_path]): | ||
self.log.error("Python related paths do not include EBROOTPYTHON.") | ||
else: | ||
self.log.info("Python related paths configured correctly.") | ||
else: | ||
# Handle cases where no Python paths are found | ||
self.log.error("No Python related paths found in CMakeCache.txt.") | ||
raise EasyBuildError("Python related paths not configured correctly.") | ||
|
||
ebrootpython_path = get_software_root("Python") | ||
|
||
# Validate that Python paths are consistent with EBROOTPYTHON | ||
if python_exec_path and not ebrootpython_path: | ||
raise EasyBuildError(f"Python executable path found ({python_exec_path}) but no Python dependency included. Check log.") | ||
|
||
return out | ||
|
||
def test_step(self): | ||
"""CMake specific test setup""" | ||
|
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.
Maybe use
readfile(...).split('\n')
?