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

GH-45530: [Python][Packaging] Add pyarrow.libs dir to get_library_dirs #45766

Merged

Conversation

amoeba
Copy link
Member

@amoeba amoeba commented Mar 13, 2025

Rationale for this change

To run test_cython on Windows, we need a copy of msvcp140.dll in the library search path.

What changes are included in this PR?

  • Updated pa.get_library_dirs() behavior to add the pyarrow.libs folder to the library search path

Are these changes tested?

Not yet.

Are there any user-facing changes?

Only a bugfix.

Closes #45530

This comment was marked as outdated.

@amoeba
Copy link
Member Author

amoeba commented Mar 13, 2025

@github-actions crossbow submit wheel-windows-*

Copy link

Revision: f70dc96

Submitted crossbow builds: ursacomputing/crossbow @ actions-ba017247bc

Task Status
wheel-windows-cp310-cp310-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions
wheel-windows-cp312-cp312-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313t-amd64 GitHub Actions
wheel-windows-cp39-cp39-amd64 GitHub Actions

Comment on lines 426 to 428
pyarrow_libs_dir = _os.path.join(
python_base_install, "Lib", "site-packages", "pyarrow.libs"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess the Python stdlib includes a site module that can give you the location of the current executable's site-packages dir which may be a better approach than this.

Copy link
Member

Choose a reason for hiding this comment

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

what if we use the current folder and substitute pyarrow with pyarrow.libs?
_os.path.dirname(_os.path.abspath(__file__)) --> that's how we add it below

It feels slightly hardcoded and I am not sure if all environments (virtualenv, system installed python, conda installed python) would replicate this folder structure.

Copy link
Member

Choose a reason for hiding this comment

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

Even better, perhaps take a look at the kind of patch generated by delvewheel itself, since it also has to compute the path to the mangled dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

Delvewheel uses a patch similar to what @raulcd mentions. From our patched wheel,

# start delvewheel patch
def _delvewheel_patch_1_10_0():
    import os
    if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'pyarrow.libs'))):
        os.add_dll_directory(libs_dir)

I'll try this out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in 9e2526c. Testing now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Crossbow jobs look good with the new routine.

Can you two please take another look @pitrou @raulcd

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Mar 13, 2025
@amoeba
Copy link
Member Author

amoeba commented Mar 13, 2025

It looks like that worked. From the raw log:

2025-03-13T18:14:15.2800896Z Python313\Lib\site-packages\pyarrow\tests\test_cython.py ..              [ 67%]

@amoeba amoeba marked this pull request as ready for review March 13, 2025 19:13
@amoeba amoeba requested review from raulcd and pitrou March 13, 2025 19:13
@amoeba amoeba changed the title [Python][Packaging] Add pyarrow.libs dir to get_library_dirs GH-45530: [Python][Packaging] Add pyarrow.libs dir to get_library_dirs Mar 13, 2025
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

Thanks!!!

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Mar 14, 2025
Comment on lines 426 to 428
pyarrow_libs_dir = _os.path.join(
python_base_install, "Lib", "site-packages", "pyarrow.libs"
)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, no, this is inflexible. Packages are indeed often installed in site-packages, but they could be elsewhere on PYTHONPATH.

I think this should really be using the pyarrow.libs directory that is next to the current package's directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in 9e2526c. Testing now.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Mar 14, 2025
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Mar 15, 2025
@amoeba
Copy link
Member Author

amoeba commented Mar 15, 2025

@github-actions crossbow submit wheel-windows-*

Copy link

Revision: 9e2526c

Submitted crossbow builds: ursacomputing/crossbow @ actions-472ec229f4

Task Status
wheel-windows-cp310-cp310-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions
wheel-windows-cp312-cp312-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313t-amd64 GitHub Actions
wheel-windows-cp39-cp39-amd64 GitHub Actions

@amoeba amoeba requested a review from pitrou March 15, 2025 20:11
@amoeba
Copy link
Member Author

amoeba commented Mar 15, 2025

I pushed up a few changes to address PR feedback and this PR is now passing on crossbow and is ready for a final review.

Edit: Pushed one more minor change after I wrote this.

Copy link
Member

@raulcd raulcd left a comment

Choose a reason for hiding this comment

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

Thanks @amoeba

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Mar 17, 2025
@pitrou pitrou merged commit bc0b858 into apache:main Mar 17, 2025
16 checks passed
@pitrou pitrou removed the awaiting merge Awaiting merge label Mar 17, 2025
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit bc0b858.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 3 possible false positives for unstable benchmarks that are known to sometimes produce them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI][Python] Windows wheels job fail on test_cython_api
4 participants