auditwheel-emscripten 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/.pre-commit-config.yaml +1 -1
  2. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/CHANGELOG.md +20 -11
  3. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/PKG-INFO +23 -20
  4. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/README.md +21 -18
  5. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/cli/main.py +52 -6
  6. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/repair.py +1 -1
  7. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/show.py +31 -7
  8. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/pyproject.toml +1 -1
  9. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_repair.py +1 -1
  10. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_show.py +40 -2
  11. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/.flake8 +0 -0
  12. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/.github/workflows/deploy.yml +0 -0
  13. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/.github/workflows/test.yml +0 -0
  14. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/.gitignore +0 -0
  15. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/LICENSE +0 -0
  16. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/__init__.py +0 -0
  17. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/cli/__init__.py +0 -0
  18. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/emscripten_tools/__init__.py +0 -0
  19. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/emscripten_tools/diagnostics.py +0 -0
  20. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/emscripten_tools/utils.py +0 -0
  21. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/emscripten_tools/webassembly.py +0 -0
  22. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/exports.py +0 -0
  23. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/function_type.py +0 -0
  24. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/imports.py +0 -0
  25. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/lib_utils.py +0 -0
  26. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/module.py +0 -0
  27. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/py.typed +0 -0
  28. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/wasm_utils.py +0 -0
  29. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/auditwheel_emscripten/wheel_utils.py +0 -0
  30. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/paths.py +0 -0
  31. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl +0 -0
  32. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/elf +0 -0
  33. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/galpy-1.8.0-cp310-cp310-emscripten_3_1_14_wasm32.whl +0 -0
  34. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libcrypto.so +0 -0
  35. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libgeos.so +0 -0
  36. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libgeos.so.3.10.3 +0 -0
  37. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libgeos_c.so +0 -0
  38. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libgeos_c.so.1 +0 -0
  39. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libgeos_c.so.1.16.1 +0 -0
  40. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libgeos_c.wasm +0 -0
  41. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/libssl.so +0 -0
  42. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_data/numpy-1.22.4-cp310-cp310-emscripten_3_1_14_wasm32.whl +0 -0
  43. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_exports.py +0 -0
  44. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_function_type.py +0 -0
  45. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_imports.py +0 -0
  46. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_utils.py +0 -0
  47. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/test/test_wheel_utils.py +0 -0
  48. {auditwheel_emscripten-0.1.0 → auditwheel_emscripten-0.2.0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  exclude: (^auditwheel_emscripten/emscripten_tools/)
2
2
  default_language_version:
3
- python: "3.12"
3
+ python: "3.13"
4
4
  repos:
5
5
  - repo: https://github.com/pre-commit/pre-commit-hooks
6
6
  rev: "v5.0.0"
@@ -7,26 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ### Changed
11
+
12
+ - The output format of `pyodide auditwheel show` has been simplified to be more `ldd`-like. It also shows the location of the dependencies in the wheel
13
+ using the runtime path of the shared libraries.
14
+
15
+ - `pyodide auditwheel show` now accepts `-r`, `--with-runtime-paths` option to show the runtime paths of the shared libraries in the wheel.
16
+
17
+ - `auditwheel.show()` function now returns the runtime paths of the shared libraries in the wheel as well.
18
+
10
19
  ## [0.1.0] - 2025-04-04
11
20
 
12
21
  ### Changed
13
22
 
14
23
  - `auditwheel repair` command now updates the DYLINK RPATH section of the wasm module.
15
- ([#41](https://github.com/ryanking13/auditwheel-emscripten/pull/41))
24
+ ([#41](https://github.com/pyodide/auditwheel-emscripten/pull/41))
16
25
 
17
26
  ## [0.0.16] - 2024-07-05
18
27
 
19
28
  ### Fixed
20
29
 
21
30
  - Fixed incorrect extra dependency for typer
22
- ([#32](https://github.com/ryanking13/auditwheel-emscripten/pull/32))
31
+ ([#32](https://github.com/pyodide/auditwheel-emscripten/pull/32))
23
32
 
24
33
  ## [0.0.15] - 2024-06-17
25
34
 
26
35
  ### Fixed
27
36
 
28
37
  - Support Pyodide>=0.26.0 wheels that has "pyodide" platform tag.
29
- ([#31](https://github.com/ryanking13/auditwheel-emscripten/pull/31))
38
+ ([#31](https://github.com/pyodide/auditwheel-emscripten/pull/31))
30
39
 
31
40
  ## [0.0.14] - 2023-12-23
32
41
 
@@ -35,19 +44,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
44
  - Changed the behavior of the `repair` command. It does not update `needed` section anymore
36
45
  and only copies the shared libraries to the wheel.
37
46
  Also, `copy` command is deprecated in favor of `repair`.
38
- ([#25](https://github.com/ryanking13/auditwheel-emscripten/pull/25))
47
+ ([#25](https://github.com/pyodide/auditwheel-emscripten/pull/25))
39
48
 
40
49
  ## [0.0.13] - 2023.06.08
41
50
 
42
51
  - Added py.typed file.
43
- ([#16](https://github.com/ryanking13/auditwheel-emscripten/pull/16))
52
+ ([#16](https://github.com/pyodide/auditwheel-emscripten/pull/16))
44
53
 
45
54
  ## [0.0.12] - 2023.02.13
46
55
 
47
56
  ### Fixed
48
57
 
49
58
  - Added license file to the distribution.
50
- ([#10](https://github.com/ryanking13/auditwheel-emscripten/pull/10))
59
+ ([#10](https://github.com/pyodide/auditwheel-emscripten/pull/10))
51
60
 
52
61
  ## [0.0.11] - 2023.02.06
53
62
 
@@ -55,26 +64,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55
64
 
56
65
  - Added `--show-type` option to `exports` and `imports` command, which will
57
66
  show the type of the functions in the output.
58
- ([#9](https://github.com/ryanking13/auditwheel-emscripten/pull/9))
67
+ ([#9](https://github.com/pyodide/auditwheel-emscripten/pull/9))
59
68
 
60
69
  ## [0.0.10] - 2023.01.26
61
70
 
62
71
  ### Changed
63
72
 
64
73
  - Removed extra message from CLI commands.
65
- ([#8](https://github.com/ryanking13/auditwheel-emscripten/pull/8))
74
+ ([#8](https://github.com/pyodide/auditwheel-emscripten/pull/8))
66
75
  - Changed the output format of `exports` and `imports` CLI command in order to
67
76
  make it easier to parse with `grep`.
68
- ([#8](https://github.com/ryanking13/auditwheel-emscripten/pull/8))
77
+ ([#8](https://github.com/pyodide/auditwheel-emscripten/pull/8))
69
78
 
70
79
  ## [0.0.9] - 2022.12.20
71
80
 
72
81
  ### Fixed
73
82
 
74
83
  - `pyodide auditwheel show` now will work on modules with .wasm suffix
75
- ([#7](https://github.com/ryanking13/auditwheel-emscripten/pull/7))
84
+ ([#7](https://github.com/pyodide/auditwheel-emscripten/pull/7))
76
85
 
77
86
  ### Changed
78
87
 
79
88
  - Changed the CLI entry point name from `pyodide audit` to `pyodide auditwheel`
80
- ([#5](https://github.com/ryanking13/auditwheel-emscripten/pull/5))
89
+ ([#5](https://github.com/pyodide/auditwheel-emscripten/pull/5))
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auditwheel_emscripten
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: auditwheel-like tool for Pyodide
5
- Project-URL: Home, https://github.com/ryanking13/auditwheel-emscripten
5
+ Project-URL: Home, https://github.com/pyodide/auditwheel-emscripten
6
6
  Author-email: Gyeongjae Choi <def6488@gmail.com>
7
7
  License: Mozilla Public License Version 2.0
8
8
  ==================================
@@ -391,7 +391,7 @@ Description-Content-Type: text/markdown
391
391
  # auditwheel-emscripten
392
392
 
393
393
  [![PyPI Latest Release](https://img.shields.io/pypi/v/auditwheel-emscripten.svg)](https://pypi.org/project/auditwheel-emscripten/)
394
- ![Test Status](https://github.com/ryanking13/auditwheel-emscripten/actions/workflows/test.yml/badge.svg)
394
+ ![Test Status](https://github.com/pyodide/auditwheel-emscripten/actions/workflows/test.yml/badge.svg)
395
395
 
396
396
  auditwheel-like tool for wheels targeting Emscripten platform
397
397
 
@@ -429,26 +429,29 @@ Python-in-the-browser using Emscripten.
429
429
  ```
430
430
 
431
431
  ```sh
432
- # wget https://cdn.jsdelivr.net/pyodide/v0.21.3/full/Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
433
- $ pyodide auditwheel show Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
434
-
435
- The following external shared libraries are required:
436
- {
437
- │ 'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'],
438
- │ 'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']
439
- }
432
+ $ pyodide auditwheel show shapely-2.0.7-cp313-cp313-pyodide_2025_0_wasm32.whl
433
+ shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so:
434
+ libgeos_c.so
435
+
436
+ shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so:
437
+ libgeos_c.so
440
438
  ```
441
439
 
442
440
  ```sh
443
- $ pyodide auditwheel repair --libdir <directory which contains libgeos_c.so> Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
444
-
445
- Repaired wheel has following external shared libraries:
446
- {
447
- │ 'Shapely.libs/libgeos.so.3.10.3': [],
448
- │ 'Shapely.libs/libgeos_c.so': ['libgeos.so.3.10.3'],
449
- │ 'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'],
450
- │ 'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']
451
- }
441
+ $ pyodide auditwheel repair --libdir <directory which contains libgeos_c.so> shapely-2.0.7-cp313-cp313-pyodide_2025_0_wasm32.whl
442
+ shapely/lib.cpython-313-wasm32-emscripten.so:
443
+ libgeos_c.so => shapely.libs/libgeos_c.so
444
+
445
+ shapely/_geometry_helpers.cpython-313-wasm32-emscripten.so:
446
+ libgeos_c.so => shapely.libs/libgeos_c.so
447
+
448
+ shapely/_geos.cpython-313-wasm32-emscripten.so:
449
+ libgeos_c.so => shapely.libs/libgeos_c.so
450
+
451
+ shapely.libs/libgeos.so:
452
+
453
+ shapely.libs/libgeos_c.so:
454
+ libgeos.so => shapely.libs/libgeos.so
452
455
  ```
453
456
 
454
457
 
@@ -1,7 +1,7 @@
1
1
  # auditwheel-emscripten
2
2
 
3
3
  [![PyPI Latest Release](https://img.shields.io/pypi/v/auditwheel-emscripten.svg)](https://pypi.org/project/auditwheel-emscripten/)
4
- ![Test Status](https://github.com/ryanking13/auditwheel-emscripten/actions/workflows/test.yml/badge.svg)
4
+ ![Test Status](https://github.com/pyodide/auditwheel-emscripten/actions/workflows/test.yml/badge.svg)
5
5
 
6
6
  auditwheel-like tool for wheels targeting Emscripten platform
7
7
 
@@ -39,26 +39,29 @@ Python-in-the-browser using Emscripten.
39
39
  ```
40
40
 
41
41
  ```sh
42
- # wget https://cdn.jsdelivr.net/pyodide/v0.21.3/full/Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
43
- $ pyodide auditwheel show Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
44
-
45
- The following external shared libraries are required:
46
- {
47
- │ 'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'],
48
- │ 'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']
49
- }
42
+ $ pyodide auditwheel show shapely-2.0.7-cp313-cp313-pyodide_2025_0_wasm32.whl
43
+ shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so:
44
+ libgeos_c.so
45
+
46
+ shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so:
47
+ libgeos_c.so
50
48
  ```
51
49
 
52
50
  ```sh
53
- $ pyodide auditwheel repair --libdir <directory which contains libgeos_c.so> Shapely-1.8.2-cp310-cp310-emscripten_3_1_14_wasm32.whl
54
-
55
- Repaired wheel has following external shared libraries:
56
- {
57
- │ 'Shapely.libs/libgeos.so.3.10.3': [],
58
- │ 'Shapely.libs/libgeos_c.so': ['libgeos.so.3.10.3'],
59
- │ 'shapely/speedups/_speedups.cpython-310-wasm32-emscripten.so': ['libgeos_c.so'],
60
- │ 'shapely/vectorized/_vectorized.cpython-310-wasm32-emscripten.so': ['libgeos_c.so']
61
- }
51
+ $ pyodide auditwheel repair --libdir <directory which contains libgeos_c.so> shapely-2.0.7-cp313-cp313-pyodide_2025_0_wasm32.whl
52
+ shapely/lib.cpython-313-wasm32-emscripten.so:
53
+ libgeos_c.so => shapely.libs/libgeos_c.so
54
+
55
+ shapely/_geometry_helpers.cpython-313-wasm32-emscripten.so:
56
+ libgeos_c.so => shapely.libs/libgeos_c.so
57
+
58
+ shapely/_geos.cpython-313-wasm32-emscripten.so:
59
+ libgeos_c.so => shapely.libs/libgeos_c.so
60
+
61
+ shapely.libs/libgeos.so:
62
+
63
+ shapely.libs/libgeos_c.so:
64
+ libgeos.so => shapely.libs/libgeos.so
62
65
  ```
63
66
 
64
67
 
@@ -1,9 +1,9 @@
1
1
  from pathlib import Path
2
2
 
3
3
  import typer
4
- from rich.pretty import pprint
5
4
 
6
5
  from .. import function_type, get_exports, get_imports, repair, show
6
+ from ..show import locate_dependency
7
7
  from ..wheel_utils import unpack_if_wheel
8
8
 
9
9
  app = typer.Typer()
@@ -14,18 +14,55 @@ def main():
14
14
  """Auditwheel-like tool for emscripten wheels and shared libraries."""
15
15
 
16
16
 
17
+ def print_dylib(
18
+ library: str,
19
+ deps: list[str],
20
+ runtime_paths: list[str],
21
+ libraries: list[str],
22
+ show_runtime_paths: bool = False,
23
+ ):
24
+ """
25
+ Print shared library dependencies and runtime paths.
26
+ The output looks similar to the output of `ldd`
27
+ """
28
+ print(f"{library}:")
29
+
30
+ for dep in deps:
31
+ line = f"\t{dep:>10}"
32
+ deppath = locate_dependency(library, dep, libraries, runtime_paths)
33
+ if deppath:
34
+ line += f" => {deppath}"
35
+ print(line)
36
+
37
+ if show_runtime_paths and runtime_paths:
38
+ print("\n\tRuntime search paths:")
39
+ for path in runtime_paths:
40
+ print(f"\t {path}")
41
+
42
+ print()
43
+
44
+
17
45
  @app.command("show")
18
46
  def _show(
19
47
  wheel_or_so_file: Path = typer.Argument(
20
48
  ..., help="Path to wheel or a shared library file."
21
- )
49
+ ),
50
+ show_runtime_paths: bool = typer.Option(
51
+ False,
52
+ "-r",
53
+ "--with-runtime-paths",
54
+ help="Show runtime paths.",
55
+ ),
22
56
  ):
23
57
  """
24
58
  Show shared library dependencies of a wheel or a shared library file.
25
59
  """
26
60
  try:
27
- dependencies = show(wheel_or_so_file)
28
- pprint(dependencies)
61
+ libraries = show(wheel_or_so_file)
62
+ for lib, (deps, runtime_paths) in libraries.items():
63
+ print_dylib(
64
+ lib, deps, runtime_paths, list(libraries.keys()), show_runtime_paths
65
+ )
29
66
  except Exception as e:
30
67
  raise e
31
68
 
@@ -41,6 +78,12 @@ def _repair(
41
78
  None,
42
79
  help="Directory to output repaired wheel or shared library. (default: overwrite the input file)",
43
80
  ),
81
+ show_runtime_paths: bool = typer.Option(
82
+ False,
83
+ "-r",
84
+ "--with-runtime-paths",
85
+ help="Show runtime paths.",
86
+ ),
44
87
  ):
45
88
  """
46
89
  Repair a wheel file: copy shared libraries to the wheel directory.
@@ -52,8 +95,11 @@ def _repair(
52
95
  output_dir,
53
96
  modify_rpath=True,
54
97
  )
55
- dependencies = show(repaired_wheel)
56
- pprint(dependencies)
98
+ libraries = show(repaired_wheel)
99
+ for lib, (deps, runtime_paths) in libraries.items():
100
+ print_dylib(
101
+ lib, deps, runtime_paths, list(libraries.keys()), show_runtime_paths
102
+ )
57
103
  except RuntimeError as e:
58
104
  raise e
59
105
 
@@ -21,7 +21,7 @@ def resolve_sharedlib(wheel_file: str | Path, libdir: str | Path) -> dict[str, P
21
21
 
22
22
  dependencies_resolved: dict[str, Path] = {}
23
23
  while dep_queue:
24
- lib, deps = dep_queue.popleft()
24
+ lib, (deps, _) = dep_queue.popleft()
25
25
  for dep in deps:
26
26
  if dep in dependencies_resolved:
27
27
  continue
@@ -1,5 +1,6 @@
1
1
  import tempfile
2
2
  from pathlib import Path
3
+ import os.path
3
4
 
4
5
  from .lib_utils import get_all_shared_libs_in_dir, sharedlib_regex
5
6
  from .module import parse_dylink_section
@@ -7,26 +8,31 @@ from .wheel_utils import is_emscripten_wheel, unpack
7
8
  from .wasm_utils import is_wasm_module
8
9
 
9
10
 
10
- def show_dylib(dylib_file: Path) -> list[str]:
11
+ def show_dylib(dylib_file: Path) -> tuple[list[str], list[str]]:
11
12
  if not is_wasm_module(dylib_file):
12
13
  raise RuntimeError(f"{dylib_file} is not a WASM file")
13
14
 
14
15
  dylink = parse_dylink_section(dylib_file)
15
- return dylink.needed
16
+ return dylink.needed, dylink.runtime_paths
16
17
 
17
18
 
18
- def show_wheel_unpacked(wheel_extract_dir: str | Path) -> dict[str, list[str]]:
19
+ def show_wheel_unpacked(
20
+ wheel_extract_dir: str | Path,
21
+ ) -> dict[str, tuple[list[str], list[str]]]:
19
22
  dependencies = {}
20
23
 
21
24
  shared_libs = get_all_shared_libs_in_dir(wheel_extract_dir)
22
25
  for shared_lib in shared_libs:
23
- deps = show_dylib(shared_lib)
24
- dependencies[shared_lib.relative_to(wheel_extract_dir).as_posix()] = deps
26
+ deps, runtime_paths = show_dylib(shared_lib)
27
+ dependencies[shared_lib.relative_to(wheel_extract_dir).as_posix()] = (
28
+ deps,
29
+ runtime_paths,
30
+ )
25
31
 
26
32
  return dependencies
27
33
 
28
34
 
29
- def show_wheel(wheel_file: Path) -> dict[str, list[str]]:
35
+ def show_wheel(wheel_file: Path) -> dict[str, tuple[list[str], list[str]]]:
30
36
  if not is_emscripten_wheel(wheel_file.name):
31
37
  raise RuntimeError(f"{wheel_file} is not an emscripten wheel")
32
38
 
@@ -37,7 +43,7 @@ def show_wheel(wheel_file: Path) -> dict[str, list[str]]:
37
43
  return show_wheel_unpacked(extract_dir)
38
44
 
39
45
 
40
- def show(wheel_or_so_file: str | Path) -> dict[str, list[str]]:
46
+ def show(wheel_or_so_file: str | Path) -> dict[str, tuple[list[str], list[str]]]:
41
47
  file = Path(wheel_or_so_file)
42
48
  if not file.exists():
43
49
  raise RuntimeError(f"no such file: {file}")
@@ -53,3 +59,21 @@ def show(wheel_or_so_file: str | Path) -> dict[str, list[str]]:
53
59
  }
54
60
  else:
55
61
  raise RuntimeError(f"unknown file type: {file}")
62
+
63
+
64
+ def locate_dependency(
65
+ base: str, dep: str, libraries: list[str], runtime_paths: list[str]
66
+ ) -> str | None:
67
+ """
68
+ Check if the dependencies exists in the wheel using runtime paths.
69
+ If the dependency exists, return the path to the dependency.
70
+ Otherwise, return None.
71
+ """
72
+ for path in runtime_paths:
73
+ relpath = path.replace("$ORIGIN", "..")
74
+ # Always use unix-style separators
75
+ candidate = os.path.normpath(str(Path(base) / relpath / dep)).replace("\\", "/")
76
+ if candidate in libraries:
77
+ return candidate
78
+
79
+ return None
@@ -25,7 +25,7 @@ test = [
25
25
 
26
26
 
27
27
  [project.urls]
28
- Home = "https://github.com/ryanking13/auditwheel-emscripten"
28
+ Home = "https://github.com/pyodide/auditwheel-emscripten"
29
29
 
30
30
  [project.entry-points."pyodide.cli"]
31
31
  auditwheel = "auditwheel_emscripten.cli.main:app"
@@ -71,7 +71,7 @@ def test_repair(tmp_path, wheel_file, expected):
71
71
  repaired_wheel = repair(wheel_file, TEST_DATA, tmp_path, modify_rpath=True)
72
72
 
73
73
  libs = show(repaired_wheel)
74
- libs_dependencies = list(chain(*libs.values()))
74
+ libs_dependencies = list(chain(*[dep for (dep, _) in libs.values()]))
75
75
  for expected_lib in expected:
76
76
  assert (
77
77
  expected_lib in libs_dependencies
@@ -3,7 +3,7 @@ from itertools import chain
3
3
  import pytest
4
4
  from paths import GALPY_WHEEL, NUMPY_WHEEL, SHAPELY_WHEEL
5
5
 
6
- from auditwheel_emscripten.show import show
6
+ from auditwheel_emscripten.show import show, locate_dependency
7
7
 
8
8
 
9
9
  @pytest.mark.parametrize(
@@ -59,8 +59,46 @@ def test_show(wheel_file, expected):
59
59
  def test_show_dependencies(wheel_file, expected):
60
60
  libs = show(wheel_file)
61
61
 
62
- libs_dependencies = list(chain(*libs.values()))
62
+ libs_dependencies = list(chain(*[dep for (dep, _) in libs.values()]))
63
63
  for expected_lib in expected:
64
64
  assert (
65
65
  expected_lib in libs_dependencies
66
66
  ), f"expected lib {expected_lib} not found in dependencies"
67
+
68
+
69
+ def test_locate_dependency():
70
+ # Test case 1: Dependency found in runtime path
71
+ base = "dir/lib.so"
72
+ dep = "libdep.so"
73
+ libraries = ["dir/subdir/libdep.so", "other/lib.so"]
74
+ runtime_paths = ["$ORIGIN/subdir"]
75
+
76
+ result = locate_dependency(base, dep, libraries, runtime_paths)
77
+ assert result == "dir/subdir/libdep.so"
78
+
79
+ # Test case 2: Dependency not found
80
+ base = "dir/lib.so"
81
+ dep = "libmissing.so"
82
+ libraries = ["dir/subdir/libdep.so", "other/lib.so"]
83
+ runtime_paths = ["$ORIGIN/subdir"]
84
+
85
+ result = locate_dependency(base, dep, libraries, runtime_paths)
86
+ assert result is None
87
+
88
+ # Test case 3: Multiple runtime paths, dependency in second path
89
+ base = "dir/lib.so"
90
+ dep = "libdep.so"
91
+ libraries = ["dir/path2/libdep.so", "other/lib.so"]
92
+ runtime_paths = ["$ORIGIN/path1", "$ORIGIN/path2"]
93
+
94
+ result = locate_dependency(base, dep, libraries, runtime_paths)
95
+ assert result == "dir/path2/libdep.so"
96
+
97
+ # Test case 4: rpath contains ".."
98
+ base = "dir/subdir/lib.so"
99
+ dep = "libdep.so"
100
+ libraries = ["dir/libdep.so", "other/lib.so"]
101
+ runtime_paths = ["$ORIGIN/.."]
102
+
103
+ result = locate_dependency(base, dep, libraries, runtime_paths)
104
+ assert result == "dir/libdep.so"