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

Add numpy dependency to python wrapper. #1935

Merged

Conversation

404Vector
Copy link
Contributor

@404Vector 404Vector commented Dec 6, 2024

There was an issue with the existing PR, so I'm submitting a separate PR that resolves the Numpy dependency issue.

  • Modify pyproject.toml.
    Add numpy to package dependencies. When installing this package with pip, numpy will be installed additionally if it is not in the Python environment.

  • Modify python-related workflows.
    Modify each python workflow to explicitly install the dependencies (pyproject.toml) required for the build.

close #1919

- Additional dependencies required for the build environment
Numpy must be installed in the python environment where the build is being performed in order to build.

- Automatic installation of dependencies like a normal python package
When installing this package, if numpy does not exist in the python environment, it will be installed automatically.

Signed-off-by: HyeongSeok Kim <[email protected]>
@JeanChristopheMorinPerso
Copy link
Member

Can I ask what's the rationale for adding a dependency on numpy? Technically someone could use any other libraries that have a compatible numpy like array types.

@@ -62,6 +62,10 @@ jobs:
CIBW_SKIP: "*-win32 *_i686"
CIBW_TEST_SKIP: "*-macosx_universal2:arm64"
CIBW_ENVIRONMENT: OPENEXR_RELEASE_CANDIDATE_TAG="${{ github.ref_name }}"
CIBW_BEFORE_BUILD: |
pip install tomli

Choose a reason for hiding this comment

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

This is not needed. The build frontend (pip, build, etc) will automatically install the dependencies specified in the pyproject's build-system.requires section.

pyproject.toml Outdated
@@ -2,7 +2,7 @@
# Copyright (c) Contributors to the OpenEXR Project.

[build-system]
requires = ["scikit-build-core==0.10.7", "pybind11"]
requires = ["scikit-build-core==0.10.7", "pybind11", "numpy"]

Choose a reason for hiding this comment

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

Numpy is not needed at build time. Pybind11 doesn't need numpy and will not use numpy.

@JeanChristopheMorinPerso
Copy link
Member

Actually, never mind we indeed need to add it as a runtime dependency because pybind11::array is used instead of pybind11::buffer.

But it only needs numpy>=1.7.0.

Note that pybind11/numpy.h does not depend on the NumPy headers, and thus can be used without declaring a build-time dependency on NumPy; NumPy>=1.7.0 is a runtime dependency.

https://pybind11.readthedocs.io/en/stable/advanced/pycpp/numpy.html#arrays

But still, my comment about the build time dependency is still valid. We don't need numpy to build openexr.

@JeanChristopheMorinPerso
Copy link
Member

But I think I'll try to build locally and test locally, because I'd like to get a better traceback/backtrace.

…e numpy in build requires

- python-wheels-*yml: When testing on other PRs, I found that dependencies were not properly installed for each build case, so I added this code. However, this PR is for adding numpy dependencies, so it is not needed as @JeanChristopheMorinPerso suggested.

- pyproject.toml: If you are going to do any additional work with the build artifacts, like generating stubs, you will need numpy in your build environment, but it is not needed at the moment. I agree with the review by @JeanChristopheMorinPerso.

Signed-off-by: HyeongSeok Kim <[email protected]>
@404Vector
Copy link
Contributor Author

Can I ask what's the rationale for adding a dependency on numpy? Technically someone could use any other libraries that have a compatible numpy like array types.

@JeanChristopheMorinPerso, thank you for your review. I agree with what you said and have modified the code.

Copy link
Member

@cary-ilm cary-ilm left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks. The CI check failure is because the workflow is out of date, already fixed on the main branch.

@cary-ilm cary-ilm merged commit 89fd37e into AcademySoftwareFoundation:main Dec 16, 2024
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

numpy is not installed with the latest version of OpenEXR
3 participants