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

Build issues on FreeBSD if two versions of openjpeg are installed #2563

Closed
melvyn-sopacua opened this issue Jun 1, 2017 · 2 comments
Closed
Labels
Bug Any unexpected behavior, until confirmed feature. FreeBSD Installation Usually a problem with … Library Linking Linux Platform A catchall for platform-related
Projects
Milestone

Comments

@melvyn-sopacua
Copy link
Contributor

Related

PR 2554

Recap: /usr/local/include is inserted before /usr/local/include/openjpeg-2.1, which causes problems if two versions of openjpeg are installed.

Observations:

  1. It sometimes succeeds even without the fix in mentioned PR.
  2. The version specific directory is added twice.
  3. When it succeeds, openjpeg is the first package tried.
  4. As a result, converting the inline dict in the for loop in build_extensions to a collections.OrderedDict also resolves the issue.

Root cause

Ordering aside, the root cause is that packages are essentially configured twice in different ways. First pkg-config is used and then best guess directory searches are used to do the same thing.

Possible solutions

If this were to be fixed without the insert override from the PR, then fixing it relies on kits ordering. Not ideal.
A more generic approach is to use the following order of events:

  1. Based on the platform, add the needed "generic" directories, so top-level "lib" and "include" paths.
  2. Go through the pkg-config loop, but always prepend directories (in the reverse order as returned by pkg-config). Set state for found libraries.
  3. Add available libraries, but only those not already configured by pkg-config.

Analysis

Since this braindead OpenJPEG versioning is likely to be an exception, as is having two versions installed, the current fix from the PR looks "good enough" to me, but if maintainers want the approach from above, I'm happy to make a new PR as I'm in a good position to test it.

I do not actually understand, why packages found by pkg-config are revisited in the "feature" code, so that would have to be explained.

P.S.: I pretty much expect the choice will be made to not go for an elaborate fix and as such this issue logs the problem and causes.

@wiredfool
Copy link
Member

The patch for pkg-config was added to support a specific platform that would not build otherwise, IIRC NixOS. It has not been helpful on any of the dev or testing platforms, so it's not well tested.

@aclark4life aclark4life added Bug Any unexpected behavior, until confirmed feature. Library Linking Installation Usually a problem with … labels Jun 21, 2017
@aclark4life aclark4life added this to the Future milestone Jun 21, 2017
@aclark4life aclark4life changed the title Build with two openjpeg.h on FreeBSD (root cause) Build problems on FreeBSD if two versions of openjpeg are installed. Jun 21, 2017
@aclark4life aclark4life changed the title Build problems on FreeBSD if two versions of openjpeg are installed. Build issues on FreeBSD if two versions of openjpeg are installed. Jun 21, 2017
@radarhere radarhere changed the title Build issues on FreeBSD if two versions of openjpeg are installed. Build issues on FreeBSD if two versions of openjpeg are installed May 31, 2018
@aclark4life aclark4life added the Platform A catchall for platform-related label May 11, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
@radarhere
Copy link
Member

#2544 was merged, solving the immediate problem.

Pillow is searching for the latest version of OpenJPEG.

Pillow/setup.py

Lines 680 to 689 in 943a7a8

if best_version and _find_library_file(self, "openjp2"):
# Add the directory to the include path so we can include
# <openjpeg.h> rather than having to cope with the versioned
# include path
# FIXME (melvyn-sopacua):
# At this point it's possible that best_path is already in
# self.compiler.include_dirs. Should investigate how that is
# possible.
_add_directory(self.compiler.include_dirs, best_path, 0)
feature.jpeg2000 = "openjp2"

Given that, I don't see why the ordering of the paths prior to that selection is relevant.

Closing. Let us know if there are any further thoughts.

Pillow automation moved this from In progress to Closed Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature. FreeBSD Installation Usually a problem with … Library Linking Linux Platform A catchall for platform-related
Projects
No open projects
Pillow
  
Closed
Development

No branches or pull requests

4 participants