forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipex additional fixes for PEX-INFO interpreter constraints
add an integration test!!
- Loading branch information
1 parent
1776dea
commit c031e05
Showing
5 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/python/pants/python/pex_build_util_test_integration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import json | ||
import os | ||
import subprocess | ||
|
||
from pex.interpreter import PythonInterpreter | ||
|
||
from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest | ||
from pants.util.collections import assert_single_element | ||
from pants.util.contextutil import open_zip, temporary_dir | ||
|
||
|
||
class PexBuildUtilIntegrationTest(PantsRunIntegrationTest): | ||
|
||
binary_target_address = "testprojects/src/python/python_targets:test" | ||
|
||
def test_multiplatform_python_binary(self): | ||
cur_interpreter_id = PythonInterpreter.get().identity | ||
interpreter_name = cur_interpreter_id.requirement.name | ||
major, minor, patch = cur_interpreter_id.version | ||
cur_interpreter_constraint = f"{interpreter_name}=={major}.{minor}.{patch}" | ||
|
||
imprecise_constraint = f"{interpreter_name}=={major}.{minor}.*" | ||
|
||
with temporary_dir() as tmp_dir: | ||
self.do_command( | ||
"--binary-py-generate-ipex", | ||
"binary", | ||
self.binary_target_address, | ||
config={ | ||
"GLOBAL": {"pants_distdir": tmp_dir}, | ||
"python-setup": {"interpreter_constraints": [cur_interpreter_constraint],}, | ||
}, | ||
) | ||
|
||
pex_path = os.path.join(tmp_dir, "test.ipex") | ||
assert os.path.isfile(pex_path) | ||
pex_execution_result = subprocess.run([pex_path], stdout=subprocess.PIPE, check=True) | ||
assert pex_execution_result.stdout.decode() == "test!\n" | ||
|
||
with open_zip(pex_path) as zf: | ||
info = json.loads(zf.read("PEX-INFO")) | ||
constraint = assert_single_element(info["interpreter_constraints"]) | ||
assert constraint == imprecise_constraint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters