-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Relax restrictions on detecting boost dependency #7909
Conversation
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.
I have nothing against these changes in principle, but the implementation needs some work.
Also, a test case would be nice.
mesonbuild/dependencies/boost.py
Outdated
if system_dirs: | ||
return system_dirs | ||
|
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.
Removing this effectively makes the above code where system_dirs
useless, which might break existing setups.
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.
I changed it to use both the system_dirs and the hard-coded lib directories
@@ -652,7 +649,7 @@ def filter_libraries(self, libs: T.List[BoostLibraryFile], lib_vers: str) -> T.L | |||
def detect_libraries(self, libdir: Path) -> T.List[BoostLibraryFile]: | |||
libs = [] # type: T.List[BoostLibraryFile] | |||
for i in libdir.iterdir(): | |||
if not i.is_file() or i.is_symlink(): |
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.
Symlinks were excluded on purpose to avoid duplicate libraries in the detection logic and because symlinks usually remove information. Please either ensure that all symlinks are resolved or that "real" paths of a library are always preferred.
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.
I changed it to resolve all the symlinks and use set() to remove duplicates
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.
Why not make libs into a set from the very beginning?
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.
No good reason. I changed it to use a set from the begining
This pull request introduces 1 alert when merging 4305227 into 42d6b37 - view on LGTM.com new alerts:
|
The symlink thing was something that confused me for quite a while. I used cget to build boost, which by default symlinks all libraries into a directory. This means there are only symlinked libraries in the lib folder. I worked around this for now, but this PR would have saved me quite a bit of time. I do agree though, that non-symlinked libraries should be preferred. Thank you for working on this! |
This pull request introduces 1 alert when merging afe2acc into 762c073 - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## master #7909 +/- ##
==========================================
- Coverage 66.43% 66.43% -0.01%
==========================================
Files 374 374
Lines 84329 84325 -4
Branches 17557 17555 -2
==========================================
- Hits 56026 56019 -7
+ Misses 23383 23379 -4
- Partials 4920 4927 +7
Continue to review full report at Codecov.
|
This does two things: * allows the library files to be symlinks * searches `lib` and `lib64` in `BOOST_ROOT` even if it finds lib directories from the compiler The first condition is needed for the homebrew on macOS because boost and boost python are provided in seperate packages and are put together in /usr/local/lib with symlinks to the library files. The both conditions are needed for high performace computing environments where dependencies are often provided in nonstandard directories with symlinks A test case was added which looks for boost libraries in seperate directories which have been symlinked to BOOST_ROOT/lib
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.
I just got one more issue, but then this is good to go.
mesonbuild/dependencies/boost.py
Outdated
@@ -561,7 +557,7 @@ def detect_lib_dirs(self, root: Path) -> T.List[Path]: | |||
# Filter out paths that don't match the target arch to avoid finding | |||
# the wrong libraries. See https://github.com/mesonbuild/meson/issues/7110 | |||
if not self.arch: | |||
return dirs + subdirs | |||
return system_dirs + dirs + subdirs |
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.
system_dirs
should also be returned here in an elif
branch since they would be ignored otherwise and should not be subject to the filtering logic below
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.
After reading #7110 I think I might be going about this wrong let me try a different approach
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.
I re-wrote it to work explicitly what I was trying to do. Now when searching BOOST_ROOT it won't use the system_dirs, but when looking in other directories like /usr/local it will
mesonbuild/dependencies/boost.py
Outdated
continue | ||
if not any([i.name.startswith(x) for x in ['libboost_', 'boost_']]): | ||
continue | ||
|
||
libs += [BoostLibraryFile(i)] | ||
return [x for x in libs if x.is_boost()] # Filter out no boost libraries | ||
libs.add(i.resolve()) |
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.
When I suggested making it into a set from the beginning, I was kind of assuming the logical next step is to consolidate this. You no longer need multiple complex filtering passes, so...
libs.add(i.resolve()) | |
libs.add(BoostLibraryFile(i.resolve())) |
And then you don't need to assign blibs and make the return line refer to a different variable. This would help reduce the size of the diff... :)
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.
I made the requested change
This boolean parameter is added to check_and_set_roots() and detect_lib_dirs() when true it will first search the compiler library directories before checking the standard lib directories. This is set to false when using BOOST_ROOT and set to true when useing other system directories like /usr/local Also simplify using a set to remove duplicate lib files Also remove the part where you search the Cellar in homebrew, this is unnescessary now that symlinks can be followed it should find boost when searching /usr/local so no need to search the Cellar
# Homebrew | ||
brew_boost = Path('/usr/local/Cellar/boost') | ||
if brew_boost.is_dir(): | ||
tmp += [x for x in brew_boost.iterdir()] | ||
|
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.
What is the reason behind removing this?
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.
On homebrew systems, boost should be detected in /usr/local/lib
instead of the cellar. Looking in the cellar made sense before when the logic couldn't follow symlinks. But since this patch adds support for following symlinks, it now finds boost in /usr/local/lib like it should. In addition, event if it somehow got to checking the cellar it wouldn't find boost_python because it is in a different homebrew formula.
This currently uses my fork of meson but it should be changed to the official repo when my PR is accepted. See mesonbuild/meson#7909
Previously the meson test case would only test boost-python on linux. With the #7909 it is now possible to use boost-python on macOS/homebrew. This enables the boost-python test on both linux and macOS. It also uses python.extension_module() instead of shared_library to make the python extension module.
This does two things:
lib
andlib64
inBOOST_ROOT
even if it finds libdirectories from the compiler
The first condition is needed for the homebrew on macs because certian
boost modules are provided by seperate packages and are put together in
a directory with symlinks to the .so files. The both conditions are
needed for high performace computing environments where dependencies are
often provided in nonstandard directories with symlinks