ekalinin/nodeenv

Installation broken on alpine 3.14

apatrushev opened this issue · 2 comments

musl detection

return sysconfig.get_config_var('HOST_GNU_TYPE') == 'x86_64-pc-linux-musl'
broken on alpine 3.14 because sysconfig.get_config_var('HOST_GNU_TYPE') returns x86_64-alpine-linux-musl instead of x86_64-pc-linux-musl

Note that sysconfig.get_config_var('HOST_GNU_TYPE') will not always help.

at least not on Python 2.7 and not on void linux with musl.

$ ldd --version
musl libc (x86_64)
Version 1.1.24
Dynamic Program Loader
Usage: ldd [options] [--] pathname

$ ./bin/python
Python 2.7.18 (d2b7dcc, Nov  7 2022, 10:28:51)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_config_var('HOST_GNU_TYPE')
'x86_64-pc-linux-gnu'
>>>

I am detecting musl via

>>> import platform
>>> platform.libc_ver()
('', '')

Maybe something like this will do.

it works for me :)

import platform

def is_x86_64_musl():
    is_x86_64 = platform.processor() == 'x86_64'
    # I don't know how to detect `musl` in another way.
    unknown_libc = platform.libc_ver()[0] == ''
    return is_x86_64 and unknown_libc