bulky-evening-62934
04/16/2020, 9:19 AM1.27.0.dev3
, it seems that pants will always build the binary for current platform even I set platforms = ['linux-x86_64-cp-37-cp37m']
in BUILD
, is it expected behavior ?
And is it possible to pass platform as an option when running pants binary
instead of using the value in BUILD file ?hundreds-father-404
04/16/2020, 2:25 PMAnd is it possible to pass platform as an optionYes, it should be possible with
--python-setup-platforms
. When you define platforms
in a BUILD file, it will override this global default.
But, I realized we haven’t yet wired this to V2. Our bad. I’ll fix this.
--
is it expected behavior ?No, that is not expected behavior. In 1.27.0.dev3, if you set
platforms
in the python_binary
, we should be passing that down to Pex (and thus Pip). Could you please paste your BUILD file?bulky-evening-62934
04/16/2020, 2:45 PMpython_binary(
name = 'tf_train',
sources = ['*.py', '!*_test.py'],
dependencies = [
'//:tensorflow',
],
platforms = [
'linux-x86_64-cp-37-cp37m'
],
entry_point = "tf_train.main",
)
I build the binary on macOS, but it will still put all macOS wheel into .pex filebulky-evening-62934
04/16/2020, 2:46 PM$unzip -l dist/tf_train.pex | grep wrapt
4 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt-1.12.1.dist-info/INSTALLER
1304 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt-1.12.1.dist-info/LICENSE
6489 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt-1.12.1.dist-info/METADATA
872 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt-1.12.1.dist-info/RECORD
111 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt-1.12.1.dist-info/WHEEL
6 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt-1.12.1.dist-info/top_level.txt
658 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt/__init__.py
57456 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt/_wrappers.cpython-37m-darwin.so
20247 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt/decorators.py
7896 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt/importer.py
33768 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-macosx_10_15_x86_64.whl/wrapt/wrappers.py
4 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt-1.12.1.dist-info/INSTALLER
1304 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt-1.12.1.dist-info/LICENSE
6489 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt-1.12.1.dist-info/METADATA
883 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt-1.12.1.dist-info/RECORD
104 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt-1.12.1.dist-info/WHEEL
6 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt-1.12.1.dist-info/top_level.txt
658 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt/__init__.py
179760 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt/_wrappers.cpython-37m-x86_64-linux-gnu.so
20247 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt/decorators.py
7896 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt/importer.py
33768 01-01-1980 00:00 .deps/wrapt-1.12.1-cp37-cp37m-manylinux2010_x86_64.whl/wrapt/wrappers.py
hundreds-father-404
04/16/2020, 2:46 PMsources
field as discussed in the other thread, which is irrelevant here.hundreds-father-404
04/16/2020, 2:46 PMhundreds-father-404
04/16/2020, 2:47 PMplatforms
field, will the output only include macOS and not Linux?bulky-evening-62934
04/16/2020, 2:50 PMplatform
field, it build .pex only for macOShundreds-father-404
04/16/2020, 2:52 PMplatforms
field is indeed being respected, only not quite how you or I would expect. I’m investigating now.bulky-evening-62934
04/16/2020, 2:53 PM$./pants binary --python-setup-platforms "['linux-x86_64-cp-37-cp37m']" tf_train
Run with the option will get an error
ERROR: Missing value for command line flag --platforms in scope 'python-setup'
hundreds-father-404
04/16/2020, 2:53 PM./pants binary --python-setup-platforms="['linux-x86_64-cp-37-cp37m']" tf_train
. I don’t think there’s a great reason that we don’t allow the lack of =
, probably only oversight.hundreds-father-404
04/16/2020, 2:55 PMbulky-evening-62934
04/16/2020, 2:56 PM=
, but this option doesn’t work, it will build binary only for current platformhundreds-father-404
04/16/2020, 3:03 PMpex --platform=linux-x86_64-cp-37-cp37m cryptography -o test.pex && unzip -l test.pex
and it did the right thing, i.e. only included Linux wheels. I’ll try to reproduce your issue with Pants and figure out why it wouldn’t be working as intended.hundreds-father-404
04/16/2020, 5:58 PMhundreds-father-404
04/16/2020, 6:08 PM--interpreter-constraint
option:
▶ pex --platform=linux-x86_64-cp-37-cp37m --interpreter-constraint 'CPython>=3.6' --output-file test.pex cryptography && unzip -l test.pex | grep 'macosx' | wc -l
151
▶ pex --platform=linux-x86_64-cp-37-cp37m --output-file test.pex cryptography && unzip -l test.pex | grep 'macosx' | wc -l
0
Next step is to see if this is intentional or a bug (more likely)hundreds-father-404
04/16/2020, 6:51 PM--interpreter-constraint
to Pex, but have Pants validate that the interpreter constraints we would have passed are compatible with the platform(s).
2) Current behavior of always including the current
platform no matter what.
I think #1 is more correct for Pants to do.bulky-evening-62934
04/16/2020, 7:09 PMhundreds-father-404
04/16/2020, 7:11 PM--interpreter-constraint
to Pex when --platform
is also set”.
Note that you are already embedding which interpreter you want to use in the platform string with cp-37-cp37m
. You can’t say just linux
anymore; you must specify which interpreter you want. So, you’re overriding whatever Pants would have normally used for the interpreter constraints.hundreds-father-404
04/16/2020, 8:36 PM