Skip to content

Commit 2e1ae2b

Browse files
committed
[GR-68574] Pin build deps of HPy, test_standalone: pin build deps, add more logging.
PullRequest: graalpython/3947
2 parents 8cec77e + 80cf190 commit 2e1ae2b

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# constraints for the pkgs installed in test_standalone.txt
2+
setuptools==80.9.0
3+
setuptools-scm==8.3.1
4+
wheel==0.45.1

graalpython/com.oracle.graal.python.test/src/tests/standalone/test_standalone.py

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -44,41 +44,50 @@
4444
from tests.standalone import util
4545

4646
is_enabled = 'ENABLE_STANDALONE_UNITTESTS' in os.environ and os.environ['ENABLE_STANDALONE_UNITTESTS'] == "true"
47+
constraints_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'constraints.txt')
48+
49+
def create_test_env():
50+
env = os.environ.copy()
51+
env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version()
52+
env["PIP_CONSTRAINT"] = constraints_file
53+
return env
4754

4855
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
4956
def test_native_executable_one_file():
5057
graalpy = util.get_gp()
5158
if graalpy is None:
5259
return
53-
env = os.environ.copy()
54-
env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version()
5560

61+
env = create_test_env()
5662
with tempfile.TemporaryDirectory() as tmpdir:
5763

5864
source_file = os.path.join(tmpdir, "hello.py")
5965
with open(source_file, 'w') as f:
6066
f.write("import sys\n")
6167
f.write("print('hello world, argv[1:]:', sys.argv[1:])")
6268

69+
log = util.Logger()
70+
6371
target_file = os.path.join(tmpdir, "hello")
6472
cmd = [graalpy, "-m", "standalone", "--verbose", "native", "-ce", "-m", source_file, "-o", target_file]
6573

66-
out, return_code = util.run_cmd(cmd, env, print_out=True)
67-
util.check_ouput("Bundling Python resources into", out)
68-
util.check_ouput("Finished generating 'hello' in", out)
74+
out, return_code = util.run_cmd(cmd, env, print_out=True, logger=log)
75+
assert return_code == 0, log
76+
util.check_ouput("Bundling Python resources into", out, logger=log)
77+
util.check_ouput("Finished generating 'hello' in", out, logger=log)
6978

7079
cmd = [target_file, "arg1", "arg2"]
71-
out, return_code = util.run_cmd(cmd, env)
72-
util.check_ouput("hello world, argv[1:]: " + str(cmd[1:]), out)
80+
out, return_code = util.run_cmd(cmd, env, logger=log)
81+
assert return_code == 0, log
82+
util.check_ouput("hello world, argv[1:]: " + str(cmd[1:]), out, logger=log)
7383

7484
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
7585
def test_native_executable_venv_and_one_file():
7686
graalpy = util.get_gp()
7787
if graalpy is None:
7888
return
79-
env = os.environ.copy()
80-
env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version()
8189

90+
env = create_test_env()
8291
with tempfile.TemporaryDirectory() as target_dir:
8392
source_file = os.path.join(target_dir, "hello.py")
8493
with open(source_file, 'w') as f:
@@ -89,33 +98,38 @@ def test_native_executable_venv_and_one_file():
8998
f.write('d = ujson.loads("""{"key": "value"}""")\n')
9099
f.write("print('key=' + d['key'])\n")
91100

101+
log = util.Logger()
102+
92103
venv_dir = os.path.join(target_dir, "venv")
93104
cmd = [graalpy, "-m", "venv", venv_dir]
94-
out, return_code = util.run_cmd(cmd, env)
105+
out, return_code = util.run_cmd(cmd, env, logger=log)
106+
assert return_code == 0, log
95107

96108
venv_python = os.path.join(venv_dir, "Scripts", "python.exe") if os.name == "nt" else os.path.join(venv_dir, "bin", "python")
97109
cmd = [venv_python, "-m", "pip", "install", "termcolor", "ujson"]
98-
out, return_code = util.run_cmd(cmd, env)
110+
_, return_code = util.run_cmd(cmd, env, logger=log)
111+
assert return_code == 0, log
99112

100113
target_file = os.path.join(target_dir, "hello")
101114
cmd = [graalpy, "-m", "standalone", "--verbose", "native", "-ce", "-Os", "-m", source_file, "--venv", venv_dir, "-o", target_file]
102-
out, return_code = util.run_cmd(cmd, env)
103-
util.check_ouput("Bundling Python resources into", out)
104-
util.check_ouput("Finished generating 'hello' in", out)
115+
out, return_code = util.run_cmd(cmd, env, logger=log)
116+
assert return_code == 0, log
117+
util.check_ouput("Bundling Python resources into", out, logger=log)
118+
util.check_ouput("Finished generating 'hello' in", out, logger=log)
105119

106120
cmd = [target_file]
107-
out, return_code = util.run_cmd(cmd, env)
108-
util.check_ouput("hello standalone world", out)
109-
util.check_ouput("key=value", out)
121+
out, return_code = util.run_cmd(cmd, env, logger=log)
122+
assert return_code == 0, log
123+
util.check_ouput("hello standalone world", out, logger=log)
124+
util.check_ouput("key=value", out, logger=log)
110125

111126
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
112127
def test_native_executable_module():
113128
graalpy = util.get_gp()
114129
if graalpy is None:
115130
return
116-
env = os.environ.copy()
117-
env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version()
118131

132+
env = create_test_env()
119133
with tempfile.TemporaryDirectory() as tmp_dir:
120134

121135
module_dir = os.path.join(tmp_dir, "hello_app")
@@ -131,12 +145,16 @@ def test_native_executable_module():
131145
f.write("import hello\n")
132146
f.write("hello.print_hello()\n")
133147

148+
log = util.Logger()
149+
134150
target_file = os.path.join(tmp_dir, "hello")
135151
cmd = [graalpy, "-m", "standalone", "--verbose", "native", "-ce", "-Os", "-m", module_dir, "-o", target_file]
136-
out, return_code = util.run_cmd(cmd, env)
137-
util.check_ouput("Bundling Python resources into", out)
138-
util.check_ouput("Finished generating 'hello' in", out)
152+
out, return_code = util.run_cmd(cmd, env, logger=log)
153+
assert return_code == 0, log
154+
util.check_ouput("Bundling Python resources into", out, logger=log)
155+
util.check_ouput("Finished generating 'hello' in", out, logger=log)
139156

140157
cmd = [target_file]
141-
out, return_code = util.run_cmd(cmd, env)
142-
util.check_ouput("hello standalone world", out)
158+
out, return_code = util.run_cmd(cmd, env, logger=log)
159+
assert return_code == 0, log
160+
util.check_ouput("hello standalone world", out, logger=log)

graalpython/hpy/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = [ "setuptools>=64.0", "setuptools-scm[toml]>=6.0", "wheel>=0.34.2",]
2+
requires = [ "setuptools==80.9.0", "setuptools-scm[toml]==8.3.1", "wheel==0.45.1",]
33
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)