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

Python wheel setup gets version from OpenEXR.pc/Imath.pc #1536

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/wrappers/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ if(NOT "${CMAKE_PROJECT_NAME}" STREQUAL "OpenEXR")
find_package(OpenEXR)
endif()

get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

add_library (PyOpenEXR SHARED OpenEXR.cpp)

set (Python_ADDITIONAL_VERSIONS 3)
Expand Down
38 changes: 20 additions & 18 deletions src/wrappers/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,30 @@
/~https://github.com/AcademySoftwareFoundation/openexr/issues
"""

# Get the version and library suffix for both OpenEXR and Imath from
# the .pc pkg-config file.

version = []
with open('src/lib/OpenEXRCore/openexr_version.h', 'r') as f:
txt = f.read()
for name in ('MAJOR', 'MINOR', 'PATCH'):
version.append(re.search(
f'VERSION_{name} ([0-9]*)', txt).group(0).split(' ')[-1])
version_major, version_minor, version_patch = version
version = f"{version_major}.{version_minor}.{version_patch}"
def pkg_config(var, pkg):
with open(f'./openexr.install/lib/pkgconfig/{pkg}.pc', 'r') as f:
return re.search(f'{var}([^ \n]+)', f.read()).group(1)

imath_libsuffix = pkg_config("libsuffix=", "Imath")
openexr_libsuffix = pkg_config("libsuffix=", "OpenEXR")
openexr_version = pkg_config("Version: ", "OpenEXR")
openexr_version_major, openexr_version_minor, openexr_version_patch = openexr_version.split('.')

libs=[]
libs_static=[f'OpenEXR-{version_major}_{version_minor}',
f'IlmThread-{version_major}_{version_minor}',
f'Iex-{version_major}_{version_minor}',
f'Imath-{version_major}_{version_minor}',
f'OpenEXRCore-{version_major}_{version_minor}'
libs_static=[f'OpenEXR{openexr_libsuffix}',
f'IlmThread{openexr_libsuffix}',
f'Iex{openexr_libsuffix}',
f'Imath{imath_libsuffix}',
f'OpenEXRCore{openexr_libsuffix}',
]
definitions = [('PYOPENEXR_VERSION_MAJOR', f'{version_major}'),
('PYOPENEXR_VERSION_MINOR', f'{version_minor}'),
('PYOPENEXR_VERSION_PATCH', f'{version_patch}'),]
definitions = [('PYOPENEXR_VERSION_MAJOR', f'{openexr_version_major}'),
('PYOPENEXR_VERSION_MINOR', f'{openexr_version_minor}'),
('PYOPENEXR_VERSION_PATCH', f'{openexr_version_patch}'),]
if platform.system() == "Windows":
definitions = [('PYOPENEXR_VERSION', f'\\"{version}\\"')]
definitions = [('PYOPENEXR_VERSION', f'\\"{openexr_version}\\"')]
extra_compile_args = []
if platform.system() == 'Darwin':
extra_compile_args += ['-std=c++11',
Expand Down Expand Up @@ -64,7 +66,7 @@
url = '/~https://github.com/AcademySoftwareFoundation/openexr',
description = "Python bindings for the OpenEXR image file format",
long_description = DESC,
version=version,
version=openexr_version,
ext_modules=[
Extension('OpenEXR',
['OpenEXR.cpp'],
Expand Down