conda-forge / conda-forge/python-feedstock
ctypes.util.find_library() doesn't filter non-elf files
- Ngôn ngữ chính
- Shell
- Star
- 47
- Fork
- 112
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 18
Mô tả
### Solution to issue cannot be found in the documentation.
- [x] I checked the documentation.
### Issue
In this example below, conda forge's python is returning a location which is a linker script.
```
# ./dev/bin/python -c "import ctypes.util; print(ctypes.util.find_library('ncursesw'))"
/root/dev/lib/libncursesw.so
# file /root/dev/lib/libncursesw.so
/root/dev/lib/libncursesw.so: ASCII text
# cat /root/dev/lib/libncursesw.so
INPUT(libncursesw.so.6 -ltinfow)
```
How did I land here?
```
# ./dev/bin/python -c 'import pyrepl.curses'
Traceback (most recent call last):
File "", line 1, in
import pyrepl.curses
File "/root/dev/lib/python3.13/site-packages/pyrepl/curses.py", line 22, in
from ._minimal_curses import error, setupterm, tigetstr, tparm
File "/root/dev/lib/python3.13/site-packages/pyrepl/_minimal_curses.py", line 30, in
clib = ctypes.cdll.LoadLibrary(_clibpath)
File "/root/dev/lib/python3.13/ctypes/__init__.py", line 471, in LoadLibrary
return self._dlltype(name)
~~~~~~~~~~~~~^^^^^^
File "/root/dev/lib/python3.13/ctypes/__init__.py", line 390, in __init__
self._handle = _dlopen(self._name, mode)
~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: /root/dev/lib/libncursesw.so: file too short
```
I think we likely need to update Ray's [patch](https://github.com/conda-forge/python-feedstock/blob/7c811d7e4f2b41cfccd2a3befc0a68898508171b/recipe/patches/0003-Fix-find_library-so-that-it-looks-in-sys.prefix-lib-.patch) to filter ELF files using [this](https://github.com/python/cpython/blob/a4ea80d52394bafffb2257abbe815c7ffdb003a3/Lib/ctypes/util.py#L180-L187) function, similar to how it was done in https://github.com/python/cpython/issues/86142
### Installed packages
```shell
# micromamba list -p ./dev/
List of packages in environment: "/root/dev"
Name Version Build Channel
───────────────────────────────────────────────────────────────────
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
bzip2 1.0.8 h4bc722e_7 conda-forge
ca-certificates 2025.1.31 hbd8a1cb_1 conda-forge
ld_impl_linux-64 2.43 h712a8e2_4 conda-forge
libexpat 2.7.0 h5888daf_0 conda-forge
libffi 3.4.6 h2dba641_1 conda-forge
libgcc 14.2.0 h767d61c_2 conda-forge
libgcc-ng 14.2.0 h69a702a_2 conda-forge
libgomp 14.2.0 h767d61c_2 conda-forge
liblzma 5.8.1 hb9d3cd8_0 conda-forge
libmpdec 4.0.0 h4bc722e_0 conda-forge
libsqlite 3.49.1 hee588c1_2 conda-forge
libuuid 2.38.1 h0b41bf4_0 conda-forge
libzlib 1.3.1 hb9d3cd8_2 conda-forge
ncurses 6.5 h2d0b736_3 conda-forge
openssl 3.5.0 h7b32b05_0 conda-forge
pip 25.0.1 pyh145f28c_0 conda-forge
pyrepl 0.11.3.post1 pyhd8ed1ab_1 conda-forge
python 3.13.3 hf636f53_101_cp313 conda-forge
python_abi 3.13 7_cp313 conda-forge
readline 8.2 h8c095d6_2 conda-forge
tk 8.6.13 noxft_h4845f30_101 conda-forge
tzdata 2025b h78e105d_0 conda-forge
```
### Environment info
```shell
# micromamba info
libmamba version : 2.1.0
micromamba version : 2.1.0
curl version : libcurl/8.13.0 OpenSSL/3.5.0 zlib/1.3.1 zstd/1.5.7 libssh2/1.11.1 nghttp2/1.64.0
libarchive version : libarchive 3.7.7 zlib/1.3.1 bz2lib/1.0.8 libzstd/1.5.6
envs directories : /root/micromamba/envs
package cache : /root/micromamba/pkgs
/root/.mamba/pkgs
environment : base
env location : /root/micromamba
user config files : /root/.mambarc
populated config files : /root/.condarc
virtual packages : __unix=0=0
__linux=6.10.14=0
__glibc=2.41=0
__archspec=1=x86_64_v2
channels : https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://conda.anaconda.org/nodefaults/linux-64
https://conda.anaconda.org/nodefaults/noarch
base environment : /root/micromamba
platform : linux-64
```
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.