Noted by @richardlau in #29897
Problem
In various places in GYP files and Python scripts, we use string or number comparisons to check if the version of compiling tools satisfies some minimum value. These are not safe and could give wrong results:
"10.1" >= "2.4" returns False
2.24 > 2.3 returns False
Some examples in our code base
|
openssl110_asm_supported = \ |
|
('gas_version' in variables and float(variables['gas_version']) >= 2.23) or \ |
|
('xcode_version' in variables and float(variables['xcode_version']) >= 5.0) or \ |
|
('llvm_version' in variables and float(variables['llvm_version']) >= 3.3) or \ |
|
('nasm_version' in variables and float(variables['nasm_version']) >= 2.10) |
|
'llvm_version>="3.3" or xcode_version>="5.0" or gas_version>="2.23"', { |
|
}, 'gas_version >= "2.26" or nasm_version >= "2.11.8"', { |
Solution?
I haven't found a solution yet, because we need something that works in GYP conditions, meaning simple Python expressions that cannot import external libraries (correct me if I'm wrong).
We could use the builtin from distutils.version import StrictVersion and StrictVersion("2.24") >= StrictVersion("2.3") but I don't know if it's possible to make StrictVersion available to GYP conditionals.
/cc @nodejs/gyp @nodejs/python
Noted by @richardlau in #29897
Problem
In various places in GYP files and Python scripts, we use string or number comparisons to check if the version of compiling tools satisfies some minimum value. These are not safe and could give wrong results:
"10.1" >= "2.4"returnsFalse2.24 > 2.3returnsFalseSome examples in our code base
node/configure.py
Lines 1233 to 1237 in 81bc7b3
node/deps/openssl/openssl.gypi
Line 1039 in 81bc7b3
node/deps/openssl/openssl.gyp
Line 24 in 81bc7b3
Solution?
I haven't found a solution yet, because we need something that works in GYP conditions, meaning simple Python expressions that cannot import external libraries (correct me if I'm wrong).
We could use the builtin
from distutils.version import StrictVersionandStrictVersion("2.24") >= StrictVersion("2.3")but I don't know if it's possible to makeStrictVersionavailable to GYP conditionals./cc @nodejs/gyp @nodejs/python