Skip to content

Use user-specified library search paths in RUSTFLAGS in auditwheel #2676

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

Merged
merged 4 commits into from
Jul 13, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 12, 2025

Fixes #2096

When repairing wheels for manylinux/musllinux compliance, maturin's auditwheel implementation now considers library search paths specified in RUSTFLAGS via -L options, in addition to the existing sources:

  • Paths from <target>-gcc --print-sysroot
  • linked_paths from cargo build script output (cargo:rustc-link-search)

Changes

  • Added rustflags parsing: Uses the rustflags crate to parse cargo configuration and extract -L library search paths from RUSTFLAGS
  • Extended auditwheel integration: Modified get_policy_and_libs() to include rustflags library paths when finding external dependencies
  • Preserved backward compatibility: All existing functionality remains unchanged

Example

Users can now specify additional library search paths in their cargo configuration:

# .cargo/config.toml
[build]
rustflags = [
    "-L", "dependency=/usr/local/lib",
    "-L", "/custom/lib/path",
    "-C", "opt-level=3"
]

These paths will now be considered during wheel repair, improving compatibility for projects that link against libraries in non-standard locations.

Testing

  • Added comprehensive tests for rustflags parsing functionality
  • All existing tests continue to pass
  • Code passes clippy and formatting checks

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: messense <1556054+messense@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Please implement @PyO3/maturin/issues/2096 Use user-specified library search paths in RUSTFLAGS in auditwheel Jul 12, 2025
@Copilot Copilot AI requested a review from messense July 12, 2025 23:15
Copilot finished work on behalf of messense July 12, 2025 23:15
…eview

Co-authored-by: messense <1556054+messense@users.noreply.github.com>
@Copilot Copilot AI requested a review from messense July 13, 2025 02:42
Copilot finished work on behalf of messense July 13, 2025 02:42
@messense
Copy link
Member

@copilot please fix clippy warnings

Co-authored-by: messense <1556054+messense@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 13, 2025

@copilot please fix clippy warnings

Fixed the clippy warning by removing the redundant use rustflags; import in commit 4579df2. The code now uses fully qualified names and passes all clippy checks.

Copilot finished work on behalf of messense July 13, 2025 03:12
@messense messense marked this pull request as ready for review July 13, 2025 04:11
@messense messense merged commit 7bb2209 into main Jul 13, 2025
42 checks passed
@messense messense deleted the copilot/fix-b26080d2-c1ef-4e55-a218-fbc0213e76fa branch July 13, 2025 04:33
Copilot AI added a commit that referenced this pull request Jul 13, 2025
…2676)

Fixes #2096

When repairing wheels for manylinux/musllinux compliance, maturin's
auditwheel implementation now considers library search paths specified
in `RUSTFLAGS` via `-L` options, in addition to the existing sources:

- Paths from `<target>-gcc --print-sysroot`
- `linked_paths` from cargo build script output
(`cargo:rustc-link-search`)

## Changes

- **Added rustflags parsing**: Uses the `rustflags` crate to parse cargo
configuration and extract `-L` library search paths from `RUSTFLAGS`
- **Extended auditwheel integration**: Modified `get_policy_and_libs()`
to include rustflags library paths when finding external dependencies
- **Preserved backward compatibility**: All existing functionality
remains unchanged

## Example

Users can now specify additional library search paths in their cargo
configuration:

```toml
# .cargo/config.toml
[build]
rustflags = [
    "-L", "dependency=/usr/local/lib",
    "-L", "/custom/lib/path",
    "-C", "opt-level=3"
]
```

These paths will now be considered during wheel repair, improving
compatibility for projects that link against libraries in non-standard
locations.

## Testing

- Added comprehensive tests for rustflags parsing functionality
- All existing tests continue to pass
- Code passes clippy and formatting checks

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: messense <1556054+messense@users.noreply.github.com>
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Aug 6, 2025
https://build.opensuse.org/request/show/1297806
by user mia + dimstar_suse
- Update to 1.9.3
  * Add support for RISC-V architecture in manylinux
    gh#PyO3/maturin#2694
  * pyproject.toml: bump setuptools for PEP 639
    gh#PyO3/maturin#2698
  * Fix PEP 639 support for source distributions
    gh#PyO3/maturin#2704
  * Fix relative README rewrite in source distributions
    gh#PyO3/maturin#2705

- Update to 1.9.2
  * Respect PEP 621 dynamic fields when merging Cargo.toml metadata
    gh#PyO3/maturin#2672
  * Only use all_features=true in sdist when local path
    dependencies exist
    gh#PyO3/maturin#2674
  * auditwheel: add manylinux_2_26 policy
    gh#PyO3/maturin#2677
  * Use user-specified library search paths in RUSTFLAGS in
    auditwheel
    gh#PyO3/maturin#2676
  * pyproject.toml: add license-files
    gh#PyO3/maturin#2690
  * Update manylinux/musllinux
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.

Use user-specified library search paths in RUSTFLAGS in auditwheel
2 participants