Skip to content

Commit e37e6fe

Browse files
committed
Fix m2crypto test and clean up formatting
1 parent bcfa1e6 commit e37e6fe

4 files changed

Lines changed: 80 additions & 48 deletions

File tree

relenv/build/linux.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def populate_env(env, dirs):
6363
f"-I{dirs.prefix}/include/ncursesw",
6464
f"-I{dirs.toolchain}/{env['RELENV_HOST']}/sysroot/usr/include",
6565
]
66+
# env["CXXFLAGS"] = " ".join(cpplags)
6667
env["CPPFLAGS"] = " ".join(cpplags)
6768
env["PKG_CONFIG_PATH"] = f"{dirs.prefix}/lib/pkgconfig"
6869

@@ -82,12 +83,12 @@ def build_bzip2(env, dirs, logfp):
8283
[
8384
"make",
8485
"-j8",
85-
"PREFIX={}".format(dirs.prefix),
86-
"LDFLAGS={}".format(env["LDFLAGS"]),
86+
f"PREFIX={dirs.prefix}",
87+
f"LDFLAGS={env['LDFLAGS']}",
8788
"CFLAGS=-fPIC",
88-
"CC={}".format(env["CC"]),
89-
"BUILD={}".format("x86_64-linux-gnu"),
90-
"HOST={}".format(env["RELENV_HOST"]),
89+
f"CC={env['CC']}",
90+
"BUILD=x86_64-linux-gnu",
91+
f"HOST={env['RELENV_HOST']}",
9192
"install",
9293
],
9394
env=env,
@@ -99,10 +100,10 @@ def build_bzip2(env, dirs, logfp):
99100
"make",
100101
"-f",
101102
"Makefile-libbz2_so",
102-
"CC={}".format(env["CC"]),
103-
"LDFLAGS={}".format(env["LDFLAGS"]),
104-
"BUILD={}".format("x86_64-linux-gnu"),
105-
"HOST={}".format(env["RELENV_HOST"]),
103+
f"CC={env['CC']}",
104+
f"LDFLAGS={env['LDFLAGS']}",
105+
"BUILD=x86_64-linux-gnu",
106+
"HOST={env['RELENV_HOST']}",
106107
],
107108
env=env,
108109
stderr=logfp,
@@ -125,10 +126,10 @@ def build_libxcrypt(env, dirs, logfp):
125126
runcmd(
126127
[
127128
"./configure",
128-
"--prefix={}".format(dirs.prefix),
129+
f"--prefix={dirs.prefix}",
129130
# "--enable-libgdbm-compat",
130-
"--build={}".format(env["RELENV_BUILD"]),
131-
"--host={}".format(env["RELENV_HOST"]),
131+
f"--build={env['RELENV_BUILD']}",
132+
f"--host={env['RELENV_HOST']}",
132133
],
133134
env=env,
134135
stderr=logfp,
@@ -152,10 +153,10 @@ def build_gdbm(env, dirs, logfp):
152153
runcmd(
153154
[
154155
"./configure",
155-
"--prefix={}".format(dirs.prefix),
156+
f"--prefix={dirs.prefix}",
156157
"--enable-libgdbm-compat",
157-
"--build={}".format(env["RELENV_BUILD"]),
158-
"--host={}".format(env["RELENV_HOST"]),
158+
f"--build={env['RELENV_BUILD']}",
159+
f"--host={env['RELENV_HOST']}",
159160
],
160161
env=env,
161162
stderr=logfp,
@@ -202,19 +203,20 @@ def build_ncurses(env, dirs, logfp):
202203
"--disable-stripping",
203204
f"--with-pkg-config={dirs.prefix}/lib/pkgconfig",
204205
"--enable-pc-files",
205-
"--build={}".format(env["RELENV_BUILD"]),
206-
"--host={}".format(env["RELENV_HOST"]),
206+
f"--build={env['RELENV_BUILD']}",
207+
f"--host={env['RELENV_HOST']}",
207208
],
208209
env=env,
209210
stderr=logfp,
210211
stdout=logfp,
211212
)
212213
runcmd(["make", "-j8"], env=env, stderr=logfp, stdout=logfp)
214+
ticdir = str(pathlib.Path(dirs.tmpbuild) / "progs" / "tic")
213215
runcmd(
214216
[
215217
"make",
216-
"DESTDIR={}".format(dirs.prefix),
217-
"TIC_PATH={}".format(str(pathlib.Path(dirs.tmpbuild) / "progs" / "tic")),
218+
f"DESTDIR={dirs.prefix}",
219+
f"TIC_PATH={ticdir}",
218220
"install",
219221
],
220222
env=env,
@@ -237,12 +239,12 @@ def build_readline(env, dirs, logfp):
237239
env["LDFLAGS"] = f"{env['LDFLAGS']} -ltinfow"
238240
cmd = [
239241
"./configure",
240-
"--prefix={}".format(dirs.prefix),
242+
f"--prefix={dirs.prefix}",
241243
]
242244
if env["RELENV_HOST"].find("linux") > -1:
243245
cmd += [
244-
"--build={}".format(env["RELENV_BUILD"]),
245-
"--host={}".format(env["RELENV_HOST"]),
246+
f"--build={env['RELENV_BUILD']}",
247+
f"--host={env['RELENV_HOST']}",
246248
]
247249
runcmd(cmd, env=env, stderr=logfp, stdout=logfp)
248250
runcmd(["make", "-j8"], env=env, stderr=logfp, stdout=logfp)
@@ -263,10 +265,10 @@ def build_libffi(env, dirs, logfp):
263265
runcmd(
264266
[
265267
"./configure",
266-
"--prefix={}".format(dirs.prefix),
268+
f"--prefix={dirs.prefix}",
267269
"--disable-multi-os-directory",
268-
"--build={}".format(env["RELENV_BUILD"]),
269-
"--host={}".format(env["RELENV_HOST"]),
270+
f"--build={env['RELENV_BUILD']}",
271+
"--host={env['RELENV_HOST']}",
270272
],
271273
env=env,
272274
stderr=logfp,
@@ -291,12 +293,12 @@ def build_zlib(env, dirs, logfp):
291293
:param logfp: A handle for the log file
292294
:type logfp: file
293295
"""
294-
env["CFLAGS"] = "-fPIC {}".format(env["CFLAGS"])
296+
env["CFLAGS"] = f"-fPIC {env['CFLAGS']}"
295297
runcmd(
296298
[
297299
"./configure",
298-
"--prefix={}".format(dirs.prefix),
299-
"--libdir={}/lib".format(dirs.prefix),
300+
f"--prefix={dirs.prefix}",
301+
f"--libdir={dirs.prefix}/lib",
300302
"--shared",
301303
],
302304
env=env,
@@ -326,11 +328,11 @@ def build_krb(env, dirs, logfp):
326328
runcmd(
327329
[
328330
"./configure",
329-
"--prefix={}".format(dirs.prefix),
331+
"--prefix={dirs.prefix}",
330332
"--without-system-verto",
331333
"--without-libedit",
332-
"--build={}".format(env["RELENV_BUILD"]),
333-
"--host={}".format(env["RELENV_HOST"]),
334+
"--build={env['RELENV_BUILD']}",
335+
"--host={env['RELENV_HOST']}",
334336
],
335337
env=env,
336338
stderr=logfp,

relenv/buildenv.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,18 @@ def buildenv(relenv_path=None):
5353
"RELENV_PATH": f"{relenv_path}",
5454
"CC": f"{toolchain}/bin/{triplet}-gcc -no-pie",
5555
"CXX": f"{toolchain}/bin/{triplet}-g++ -no-pie",
56-
"CFLAGS": (
57-
# f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "
58-
f"-I{relenv_path}/include "
59-
f"-I{toolchain}/sysroot/usr/include"
60-
),
56+
"CFLAGS": f"-I{relenv_path}/include -I{toolchain}/sysroot/usr/include",
6157
"CXXFLAGS": (
62-
f"-I{relenv_path}/include -I{toolchain}/{triplet}/sysroot/usr/include "
58+
f"-I{relenv_path}/include "
59+
f"-I{toolchain}/{triplet}/sysroot/usr/include "
6360
f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "
6461
f"-Wl,-rpath,{relenv_path}/lib"
6562
),
6663
"CPPFLAGS": (
67-
# f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "
68-
f"-I{relenv_path}/include -I{toolchain}/{triplet}/sysroot/usr/include"
64+
f"-I{relenv_path}/include " f"-I{toolchain}/{triplet}/sysroot/usr/include"
6965
),
7066
"CMAKE_CFLAGS": (
71-
# f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "
72-
f"-I{relenv_path}/include -I{toolchain}/{triplet}/sysroot/usr/include"
67+
f"-I{relenv_path}/include " f"-I{toolchain}/{triplet}/sysroot/usr/include"
7368
),
7469
"LDFLAGS": (
7570
f"-L{relenv_path}/lib -L{toolchain}/{triplet}/sysroot/lib "

relenv/runtime.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,5 +1035,11 @@ def bootstrap():
10351035
setup_crossroot()
10361036
install_cargo_config()
10371037
sys.meta_path = [importer] + sys.meta_path
1038-
if "RELENV_BUILDENV" in os.environ:
1039-
os.environ.update(buildenv().buildenv())
1038+
# XXX This causes our m2crypto test to break
1039+
# if "RELENV_BUILDENV" in os.environ:
1040+
# env = buildenv().buildenv()
1041+
# for key in env:
1042+
# if key in os.environ:
1043+
# os.environ[key] = f"{env[key]} {os.environ[key]}"
1044+
# else:
1045+
# os.environ[key] = env[key]

tests/test_verify_build.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def test_pip_install_salt_w_package_requirements(
342342
"26.4.0",
343343
],
344344
)
345-
def test_pip_install_pyzmq(pipexec, pyzmq_version, build_version, arch):
345+
def test_pip_install_pyzmq(pipexec, pyzmq_version, build_version, arch, build):
346346

347347
if pyzmq_version == "23.2.0" and "3.12" in build_version:
348348
pytest.xfail(f"{pyzmq_version} does not install on 3.12")
@@ -408,6 +408,21 @@ def test_pip_install_pyzmq(pipexec, pyzmq_version, build_version, arch):
408408
)
409409
assert p.returncode == 0, "Failed to pip install package requirements"
410410

411+
if shutil.which("docker"):
412+
subprocess.run(
413+
[
414+
"docker",
415+
"run",
416+
"-v",
417+
f"{build}:/test",
418+
"amazonlinux:2",
419+
"/test/bin/python3",
420+
"-c",
421+
"import zmq",
422+
],
423+
check=True,
424+
)
425+
411426

412427
def test_pip_install_cryptography(pipexec):
413428
packages = [
@@ -557,18 +572,32 @@ def test_pip_install_m2crypto_system_ssl(pipexec, pyexec):
557572

558573

559574
@pytest.mark.skip_unless_on_linux
560-
def test_pip_install_m2crypto_relenv_ssl(pipexec, pyexec, build):
575+
@pytest.mark.parametrize(
576+
"m2crypto_version",
577+
[
578+
"0.38.0",
579+
],
580+
)
581+
def test_pip_install_m2crypto_relenv_ssl(
582+
m2crypto_version, pipexec, pyexec, build, minor_version
583+
):
561584
env = os.environ.copy()
562585
env["RELENV_BUILDENV"] = "yes"
563586
env["RELENV_DEBUG"] = "yes"
564587
env["LDFLAGS"] = f"-L{build}lib"
565-
env["CFLAGS"] = f"-I{build}/include"
566-
env["SWIG_FEATURES"] = f"-I{build}/include"
588+
env["CFLAGS"] = f"-I{build}/include -I{build}/include/python{minor_version}"
589+
env["SWIG_FEATURES"] = f"-I{build}/include -I{build}/include/python{minor_version}"
567590
p = subprocess.run(
568591
["swig", "-version"],
569592
)
570593
p = subprocess.run(
571-
[str(pipexec), "install", "m2crypto", "--no-cache-dir", "-v"],
594+
[
595+
str(pipexec),
596+
"install",
597+
f"m2crypto=={m2crypto_version}",
598+
"--no-cache-dir",
599+
"-v",
600+
],
572601
env=env,
573602
stderr=subprocess.PIPE,
574603
)

0 commit comments

Comments
 (0)