Skip to content

Commit bcfa1e6

Browse files
committed
Work with setuptools>=72.2.0
- No longer include "-static-libstdc++" in CFLAGS - Add libstdc++ to relenv bundles - When RELENV_BUILDENV environment is set, update environment with buildenv rather than only updating sysconfig. - Clean up linux populate_environment method syntax - Stop duplicating rpath durring python build step
1 parent 04193db commit bcfa1e6

6 files changed

Lines changed: 76 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
0.18.2
1+
0.19.0
22
======
33

44
* Update python 3.10 to 3.10.17:
55
https://www.python.org/downloads/release/python-31017/
66
* Update python 3.13 to 3.13.3
77
* Update libxcrypt to 4.4.38
8+
* Update libffi to 3.4.8
89
* Update gdbm to 1.25
10+
* Include libstdc++ in relenv lib
11+
* Update environment with buildenv when RELENV_BUILDENV environment is set.
912

1013

1114
0.18.1

relenv/build/common.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,13 @@ def install_runtime(sitepackages):
14071407
relenv = sitepackages / "relenv"
14081408
os.makedirs(relenv, exist_ok=True)
14091409

1410-
for name in ["runtime.py", "relocate.py", "common.py", "__init__.py"]:
1410+
for name in [
1411+
"runtime.py",
1412+
"relocate.py",
1413+
"common.py",
1414+
"buildenv.py",
1415+
"__init__.py",
1416+
]:
14111417
src = MODULE_DIR / name
14121418
dest = relenv / name
14131419
with io.open(src, "r") as rfp:
@@ -1433,6 +1439,15 @@ def finalize(env, dirs, logfp):
14331439
# Install relenv-sysconfigdata module
14341440
libdir = pathlib.Path(dirs.prefix) / "lib"
14351441

1442+
shutil.copy(
1443+
pathlib.Path(dirs.toolchain)
1444+
/ env["RELENV_HOST"]
1445+
/ "sysroot"
1446+
/ "lib"
1447+
/ "libstdc++.so.6",
1448+
libdir,
1449+
)
1450+
14361451
def find_pythonlib(libdir):
14371452
for root, dirs, files in os.walk(libdir):
14381453
for _ in dirs:

relenv/build/linux.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,35 @@ def populate_env(env, dirs):
3535
:type dirs: ``relenv.build.common.Dirs``
3636
"""
3737
# CC and CXX need to be to have the full path to the executable
38-
env["CC"] = "{}/bin/{}-gcc -no-pie".format(dirs.toolchain, env["RELENV_HOST"])
39-
env["CXX"] = "{}/bin/{}-g++ -no-pie".format(dirs.toolchain, env["RELENV_HOST"])
38+
env["CC"] = f"{dirs.toolchain}/bin/{env['RELENV_HOST']}-gcc -no-pie"
39+
env["CXX"] = f"{dirs.toolchain}/bin/{env['RELENV_HOST']}-g++ -no-pie"
4040
# Add our toolchain binaries to the path. We also add the bin directory of
4141
# our prefix so that libtirpc can find krb5-config
42-
env["PATH"] = "{}/bin/:{}/bin/:{PATH}".format(dirs.toolchain, dirs.prefix, **env)
42+
env["PATH"] = f"{dirs.toolchain}/bin/:{dirs.prefix}/bin/:{env['PATH']}"
4343
ldflags = [
4444
"-Wl,--build-id=sha1",
45-
"-Wl,--rpath={prefix}/lib",
46-
"-L{prefix}/lib",
47-
"-L{}/{RELENV_HOST}/sysroot/lib".format(dirs.toolchain, **env),
48-
"-static-libstdc++",
45+
f"-Wl,--rpath={dirs.prefix}/lib",
46+
f"-L{dirs.prefix}/lib",
47+
f"-L{dirs.toolchain}/{env['RELENV_HOST']}/sysroot/lib",
4948
]
50-
env["LDFLAGS"] = " ".join(ldflags).format(prefix=dirs.prefix)
49+
env["LDFLAGS"] = " ".join(ldflags)
5150
cflags = [
5251
"-g",
53-
"-I{prefix}/include",
54-
"-I{prefix}/include/readline",
55-
"-I{prefix}/include/ncursesw",
56-
"-I{}/{RELENV_HOST}/sysroot/usr/include".format(dirs.toolchain, **env),
52+
f"-I{dirs.prefix}/include",
53+
f"-I{dirs.prefix}/include/readline",
54+
f"-I{dirs.prefix}/include/ncursesw",
55+
f"-I{dirs.toolchain}/{env['RELENV_HOST']}/sysroot/usr/include",
5756
]
58-
env["CFLAGS"] = " ".join(cflags).format(prefix=dirs.prefix)
57+
env["CFLAGS"] = " ".join(cflags)
5958
# CPPFLAGS are needed for Python's setup.py to find the 'nessicery bits'
6059
# for things like zlib and sqlite.
6160
cpplags = [
62-
"-I{prefix}/include",
63-
"-I{prefix}/include/readline",
64-
"-I{prefix}/include/ncursesw",
65-
"-I{}/{RELENV_HOST}/sysroot/usr/include".format(dirs.toolchain, **env),
61+
f"-I{dirs.prefix}/include",
62+
f"-I{dirs.prefix}/include/readline",
63+
f"-I{dirs.prefix}/include/ncursesw",
64+
f"-I{dirs.toolchain}/{env['RELENV_HOST']}/sysroot/usr/include",
6665
]
67-
env["CPPFLAGS"] = " ".join(cpplags).format(prefix=dirs.prefix)
68-
env["CXXFLAGS"] = " ".join(cpplags).format(prefix=dirs.prefix)
69-
env["LD_LIBRARY_PATH"] = "{prefix}/lib"
66+
env["CPPFLAGS"] = " ".join(cpplags)
7067
env["PKG_CONFIG_PATH"] = f"{dirs.prefix}/lib/pkgconfig"
7168

7269

@@ -354,9 +351,9 @@ def build_python(env, dirs, logfp):
354351
:param logfp: A handle for the log file
355352
:type logfp: file
356353
"""
357-
env["LDFLAGS"] = "-Wl,--rpath={prefix}/lib {ldflags}".format(
358-
prefix=dirs.prefix, ldflags=env["LDFLAGS"]
359-
)
354+
ldflagopt = f"-Wl,--rpath={dirs.prefix}/lib"
355+
if ldflagopt not in env["LDFLAGS"]:
356+
env["LDFLAGS"] = f"{ldflagopt} {env['LDFLAGS']}"
360357

361358
# Needed when using a toolchain even if build and host match.
362359
runcmd(
@@ -433,6 +430,8 @@ def build_python(env, dirs, logfp):
433430
with io.open("Modules/Setup", "a+") as fp:
434431
fp.seek(0, io.SEEK_END)
435432
fp.write("*disabled*\n" "_tkinter\n" "nsl\n" "nis\n")
433+
for _ in ["LDFLAGS", "CFLAGS", "CPPFLAGS", "CXX", "CC"]:
434+
env.pop(_)
436435
runcmd(["make", "-j8"], env=env, stderr=logfp, stdout=logfp)
437436
runcmd(["make", "install"], env=env, stderr=logfp, stdout=logfp)
438437

@@ -555,8 +554,8 @@ def build_python(env, dirs, logfp):
555554
download={
556555
"url": "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz",
557556
# "fallback_url": "https://woz.io/relenv/dependencies/libffi-{version}.tar.gz",
558-
"version": "3.4.7",
559-
"checksum": "b07136211f47fa30c0512ebd7484fde724978d99",
557+
"version": "3.4.8",
558+
"checksum": "6930b77aebe2465a8e1a8617c4c9a8fa3199b256",
560559
"checkfunc": github_version,
561560
"checkurl": "https://github.com/libffi/libffi/releases/",
562561
},

relenv/buildenv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def buildenv(relenv_path=None):
5858
f"-I{relenv_path}/include "
5959
f"-I{toolchain}/sysroot/usr/include"
6060
),
61+
"CXXFLAGS": (
62+
f"-I{relenv_path}/include -I{toolchain}/{triplet}/sysroot/usr/include "
63+
f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "
64+
f"-Wl,-rpath,{relenv_path}/lib"
65+
),
6166
"CPPFLAGS": (
6267
# f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "
6368
f"-I{relenv_path}/include -I{toolchain}/{triplet}/sysroot/usr/include"

relenv/runtime.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ def relocate():
7070
return relocate.relocate
7171

7272

73+
def buildenv():
74+
"""
75+
Late import relenv buildenv.
76+
"""
77+
if not hasattr(buildenv, "builenv"):
78+
buildenv.buildenv = path_import(
79+
"relenv.buildenv", str(pathlib.Path(__file__).parent / "buildenv.py")
80+
)
81+
return buildenv.buildenv
82+
83+
7384
def get_major_version():
7485
"""
7586
Current python major version.
@@ -1024,3 +1035,5 @@ def bootstrap():
10241035
setup_crossroot()
10251036
install_cargo_config()
10261037
sys.meta_path = [importer] + sys.meta_path
1038+
if "RELENV_BUILDENV" in os.environ:
1039+
os.environ.update(buildenv().buildenv())

tests/test_verify_build.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,31 +339,35 @@ def test_pip_install_salt_w_package_requirements(
339339
"23.2.0",
340340
"25.1.2",
341341
"26.2.0",
342+
"26.4.0",
342343
],
343344
)
344345
def test_pip_install_pyzmq(pipexec, pyzmq_version, build_version, arch):
345346

346347
if pyzmq_version == "23.2.0" and "3.12" in build_version:
347348
pytest.xfail(f"{pyzmq_version} does not install on 3.12")
348349

350+
if pyzmq_version == "23.2.0" and "3.13" in build_version:
351+
pytest.xfail(f"{pyzmq_version} does not install on 3.13")
352+
349353
if pyzmq_version == "23.2.0" and sys.platform == "darwin":
350354
pytest.xfail("pyzmq 23.2.0 fails on macos arm64")
351355

352-
if sys.platform == "win32" and pyzmq_version == "25.1.2":
353-
pytest.xfail("pyzmq 25.1.2 fails on windows")
354-
355-
if sys.platform == "win32" and pyzmq_version == "23.2.0":
356-
pytest.xfail("vcredist not found as of 9/9/24")
357-
358-
if sys.platform == "win32" and pyzmq_version == "26.2.0":
356+
if pyzmq_version == "23.2.0" and sys.platform == "win32":
359357
pytest.xfail("vcredist not found as of 9/9/24")
360358

361-
if pyzmq_version == "23.2.0" and "3.13" in build_version:
362-
pytest.xfail(f"{pyzmq_version} does not install on 3.13")
363-
364359
if pyzmq_version == "25.1.2" and "3.13" in build_version:
365360
pytest.xfail(f"{pyzmq_version} does not install on 3.13")
366361

362+
if pyzmq_version == "25.1.2" and sys.platform == "win32":
363+
pytest.xfail("pyzmq 25.1.2 fails on windows")
364+
365+
if pyzmq_version == "26.2.0" and sys.platform == "win32":
366+
pytest.xfail("vcredist not found as of 9/9/24")
367+
368+
if pyzmq_version == "26.4.0" and sys.platform == "win32":
369+
pytest.xfail("Needs troubleshooting 4/12/25")
370+
367371
env = os.environ.copy()
368372

369373
p = subprocess.run(

0 commit comments

Comments
 (0)