Skip to content
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

Keep only one flavor of the same libs in collect_libs() #11527

Merged
merged 5 commits into from Jul 28, 2022

Conversation

SpaceIm
Copy link
Contributor

@SpaceIm SpaceIm commented Jun 25, 2022

closes #11282
closes #11526

Changelog: Fix: In conans.tools.collect_libs and conan.tools.files.collect_libs, avoids to list other flavors (version, soversion) of the same dylib on macOS, so that behavior is consistent on Linux & macOS.
Docs: conan-io/docs#2610

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

Indeed, it happens all the time with symlinks
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be less concerned of something breaking if this didn't remove existing tests.
Also, it would be great if it added one or more tests that actually cover the intended use cases with symlinks.

If there is some risk of breaking, then I'd recommend to do it only in the new conan.tools space, but no in conans.client.tools

"times with a different file extension" % name)
else:
result.append(name)
real_lib = os.path.basename(os.path.realpath(os.path.join(lib_folder, f)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit tricky way to follow symlinks and obtain the name, otherwise it seems very redudant. Better put a comment directly about this line to explain it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't os.path.realpath the most straightforward way to find real file?

conanfile.cpp_info.libdirs = ["lib", "custom_folder"]
result = collect_libs(conanfile)
assert ["mylib"] == result
assert "Library 'mylib' was either already found in a previous "\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this test is being removed? Maybe it is fine to remove the warning check, but this test should still work and result == ["mylib"]?
Also, it is also that necessary to remove the warning? If collect_libs() is decided to use one specific name in a group of related ones, isn't it good to show some information about this?

Copy link
Contributor Author

@SpaceIm SpaceIm Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the first assert is still valid. The second assert fails if I keep the warning, because now there is a first pass grouping the same libs in all folders, either symlinks or real file, and it loses the capability to track duplicated real files (but it can still detect libs with different extensions). Displaying a warning for symlinks is unnecessary noise. I can try to track duplicated real files, but I'm not sure it's worth the effort and overhead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add tests for symlinks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, lets keep the first asset, and I agree, not worth the effort to keep the warning, it can be removed.

@memsharded memsharded added this to the 1.51 milestone Jun 29, 2022
@SpaceIm
Copy link
Contributor Author

SpaceIm commented Jun 29, 2022

This test should be skipped on windows.

@SpaceIm SpaceIm requested a review from memsharded June 29, 2022 19:20
@czoido czoido self-requested a review July 28, 2022 06:54
@memsharded memsharded merged commit b52e7f3 into conan-io:develop Jul 28, 2022
@SpaceIm SpaceIm deleted the bugfix/collect_libs_macos branch July 28, 2022 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants