Skip to content

Commit cbffda2

Browse files
committed
Detect armv7l hard-float ABI for manylinux2014
PEP 599 defines manylinux2014 armv7l to be compatible with centos7 altarch armv7 i.e. armhf using the gnueabihf ABI
1 parent 91c6dec commit cbffda2

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/pip/_internal/pep425tags.py

+36-4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,32 @@ def get_platform():
164164
return result
165165

166166

167+
def is_linux_armhf():
168+
# type: () -> bool
169+
if get_platform() != "linux_armv7l":
170+
return False
171+
# hard-float ABI can be detected from the ELF header of the running
172+
# process
173+
try:
174+
with open(sys.executable, 'rb') as f:
175+
elf_header_raw = f.read(40) # read 40 first bytes of ELF header
176+
except (IOError, OSError, TypeError):
177+
return False
178+
if elf_header_raw is None or len(elf_header_raw) < 40:
179+
return False
180+
if isinstance(elf_header_raw, str):
181+
elf_header = [ord(c) for c in elf_header_raw]
182+
else:
183+
elf_header = [b for b in elf_header_raw]
184+
result = elf_header[0:4] == [0x7f, 0x45, 0x4c, 0x46] # ELF magic number
185+
result &= elf_header[4:5] == [1] # 32-bit ELF
186+
result &= elf_header[5:6] == [1] # little-endian
187+
result &= elf_header[18:20] == [0x28, 0] # ARM machine
188+
result &= elf_header[39:40] == [5] # ARM EABIv5
189+
result &= (elf_header[37:38][0] & 4) == 4 # EF_ARM_ABI_FLOAT_HARD
190+
return result
191+
192+
167193
def is_manylinux1_compatible():
168194
# type: () -> bool
169195
# Only Linux, and only x86-64 / i686
@@ -202,10 +228,16 @@ def is_manylinux2010_compatible():
202228

203229
def is_manylinux2014_compatible():
204230
# type: () -> bool
205-
# Only Linux and only x86-64, i686, aarch64, armv7l, ppc64, ppc64le, s390x
206-
if get_platform() not in {"linux_x86_64", "linux_i686", "linux_aarch64",
207-
"linux_armv7l", "linux_ppc64", "linux_ppc64le",
208-
"linux_s390x"}:
231+
# Only Linux, and only supported architectures
232+
platform = get_platform()
233+
if platform not in {"linux_x86_64", "linux_i686", "linux_aarch64",
234+
"linux_armv7l", "linux_ppc64", "linux_ppc64le",
235+
"linux_s390x"}:
236+
return False
237+
238+
# check for hard-float ABI in case we're running linux_armv7l not to
239+
# install hard-float ABI wheel in a soft-float ABI environment
240+
if platform == "linux_armv7l" and not is_linux_armhf():
209241
return False
210242

211243
# Check for presence of _manylinux module

0 commit comments

Comments
 (0)