Skip to content

Commit d2ea025

Browse files
committed
Make ppbt optional
1 parent bcba7e6 commit d2ea025

File tree

6 files changed

+157
-7
lines changed

6 files changed

+157
-7
lines changed

relenv/build/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def get_triplet(machine=None, plat=None):
125125
if ppbt:
126126
env = ppbt.environ(auto_extract=True)
127127
toolchain = pathlib.Path(env["TOOLCHAIN_PATH"])
128-
else:
129-
log.warning("ppbt package not installed")
128+
#else:
129+
# log.warning("ppbt package not installed")
130130
else:
131131
toolchain = DATA_DIR / "toolchain" / get_triplet()
132132
@@ -1482,6 +1482,9 @@ def find_pythonlib(libdir):
14821482
env["RELENV_CROSS"] = dirs.prefix
14831483
python = env["RELENV_NATIVE_PY"]
14841484
logfp.write("\nRUN ENSURE PIP\n")
1485+
1486+
env.pop("RELENV_BUILDENV")
1487+
14851488
runcmd(
14861489
[str(python), "-m", "ensurepip"],
14871490
env=env,

relenv/buildenv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ def buildenv(relenv_path=None):
5555
if sys.platform != "linux":
5656
raise RelenvException("buildenv is only supported on Linux")
5757

58-
triplet = get_triplet()
5958
toolchain = get_toolchain()
59+
if not toolchain:
60+
raise RelenvException("buildenv is only supported on Linux")
61+
62+
triplet = get_triplet()
6063
env = {
6164
"RELENV_BUILDENV": "1",
6265
"TOOLCHAIN_PATH": f"{toolchain}",

relenv/runtime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ def wrapper(*args, **kwargs):
602602
env = ppbt.environ(auto_extract=True)
603603
toolchain = pathlib.Path(env["TOOLCHAIN_PATH"])
604604
else:
605-
debug("ppbt package not installed")
605+
if os.environ.get("RELENV_BUILDENV", 0):
606+
raise RuntimeError("No toolchain installed")
606607
return func(*args, **kwargs)
607608

608609
if not toolchain.exists():

relenv/toolchain.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def main(*args, **kwargs):
2020
"""
2121
Notify users of toolchain command deprecation.
2222
"""
23-
print("The relenv toolchain command has been deprecated. Please pip install ppbt.")
23+
print(
24+
"The relenv toolchain command has been deprecated. Please pip install relenv[toolchain]."
25+
)
2426

2527

2628
if __name__ == "__main__":

setup.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ packages = find:
1717
package_dir =
1818
relenv = relenv
1919
include_package_data = True
20-
install_requires =
21-
ppbt; sys_platform == "linux"
2220

2321
[options.entry_points]
2422
console_scripts =

tests/test_verify_build.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ def test_pip_install_salt_git(pipexec, build, build_dir, pyexec, build_version):
108108
if sys.platform == "darwin" and "3.13" in build_version:
109109
pytest.xfail("Salt does not work with 3.13 on macos yet")
110110

111+
p = subprocess.run(
112+
[
113+
str(pipexec),
114+
"install",
115+
"ppbt",
116+
]
117+
)
118+
assert p.returncode == 0, "Failed to install ppbt"
119+
111120
env = os.environ.copy()
112121
env["RELENV_BUILDENV"] = "yes"
113122
if sys.platform == "linux" and shutil.which("git"):
@@ -147,6 +156,15 @@ def test_pip_install_salt_git(pipexec, build, build_dir, pyexec, build_version):
147156
reason="3.11.7 and greater will not work with 3005.x",
148157
)
149158
def test_pip_install_salt(pipexec, build, tmp_path, pyexec):
159+
p = subprocess.run(
160+
[
161+
str(pipexec),
162+
"install",
163+
"ppbt",
164+
]
165+
)
166+
assert p.returncode == 0, "Failed to install ppbt"
167+
150168
packages = [
151169
"salt==3005",
152170
]
@@ -172,6 +190,15 @@ def test_pip_install_salt(pipexec, build, tmp_path, pyexec):
172190

173191
@pytest.mark.skip_on_windows
174192
def test_symlinked_scripts(pipexec, tmp_path, build):
193+
p = subprocess.run(
194+
[
195+
str(pipexec),
196+
"install",
197+
"ppbt",
198+
]
199+
)
200+
assert p.returncode == 0, "Failed to install ppbt"
201+
175202
name = "chardet==5.1.0"
176203
env = os.environ.copy()
177204
env["RELENV_DEBUG"] = "yes"
@@ -211,6 +238,15 @@ def test_pip_install_salt_w_static_requirements(
211238
if salt_branch == "3006.x" and sys.platform == "win32":
212239
pytest.xfail("Known failure")
213240

241+
p = subprocess.run(
242+
[
243+
str(pipexec),
244+
"install",
245+
"ppbt",
246+
]
247+
)
248+
assert p.returncode == 0, "Failed to install ppbt"
249+
214250
env = os.environ.copy()
215251
env["RELENV_BUILDENV"] = "yes"
216252
env["USE_STATIC_REQUIREMENTS"] = "1"
@@ -270,6 +306,15 @@ def test_pip_install_salt_w_package_requirements(
270306
if sys.platform == "darwin" and salt_branch == "3006.x":
271307
pytest.xfail("Known failure")
272308

309+
p = subprocess.run(
310+
[
311+
str(pipexec),
312+
"install",
313+
"ppbt",
314+
]
315+
)
316+
assert p.returncode == 0, "Failed to install ppbt"
317+
273318
env = os.environ.copy()
274319
env["RELENV_BUILDENV"] = "yes"
275320
env["USE_STATIC_REQUIREMENTS"] = "1"
@@ -365,6 +410,15 @@ def test_pip_install_pyzmq(pipexec, pyzmq_version, build_version, arch):
365410
if pyzmq_version == "25.1.2" and "3.13" in build_version:
366411
pytest.xfail(f"{pyzmq_version} does not install on 3.13")
367412

413+
p = subprocess.run(
414+
[
415+
str(pipexec),
416+
"install",
417+
"ppbt",
418+
]
419+
)
420+
assert p.returncode == 0, "Failed to install ppbt"
421+
368422
env = os.environ.copy()
369423

370424
p = subprocess.run(
@@ -410,6 +464,14 @@ def test_pip_install_cryptography(pipexec):
410464
packages = [
411465
"cryptography",
412466
]
467+
p = subprocess.run(
468+
[
469+
str(pipexec),
470+
"install",
471+
"ppbt",
472+
]
473+
)
474+
assert p.returncode == 0, "Failed to install ppbt"
413475
env = os.environ.copy()
414476
env["RELENV_BUILDENV"] = "yes"
415477
for name in packages:
@@ -421,6 +483,14 @@ def test_pip_install_idem(pipexec):
421483
packages = [
422484
"idem",
423485
]
486+
p = subprocess.run(
487+
[
488+
str(pipexec),
489+
"install",
490+
"ppbt",
491+
]
492+
)
493+
assert p.returncode == 0, "Failed to install ppbt"
424494
env = os.environ.copy()
425495
env["RELENV_BUILDENV"] = "yes"
426496
for name in packages:
@@ -430,6 +500,14 @@ def test_pip_install_idem(pipexec):
430500

431501
def test_pip_install_and_import_libcloud(pipexec, pyexec):
432502
name = "apache-libcloud"
503+
p = subprocess.run(
504+
[
505+
str(pipexec),
506+
"install",
507+
"ppbt",
508+
]
509+
)
510+
assert p.returncode == 0, "Failed to install ppbt"
433511
env = os.environ.copy()
434512
env["RELENV_BUILDENV"] = "yes"
435513
p = subprocess.run([str(pipexec), "install", name, "--no-cache-dir"], env=env)
@@ -455,6 +533,14 @@ def test_pip_install_salt_pip_dir(pipexec, build, build_version, arch):
455533
if sys.platform == "darwin" and "3.13" in build_version:
456534
pytest.xfail("Salt does not work with 3.13 on macos yet")
457535

536+
p = subprocess.run(
537+
[
538+
str(pipexec),
539+
"install",
540+
"ppbt",
541+
]
542+
)
543+
assert p.returncode == 0, "Failed to install ppbt"
458544
env = os.environ.copy()
459545
env["RELENV_BUILDENV"] = "yes"
460546
env["RELENV_DEBUG"] = "yes"
@@ -472,6 +558,14 @@ def test_pip_install_salt_pip_dir(pipexec, build, build_version, arch):
472558

473559

474560
def test_nox_virtualenvs(pipexec, build, tmp_path):
561+
p = subprocess.run(
562+
[
563+
str(pipexec),
564+
"install",
565+
"ppbt",
566+
]
567+
)
568+
assert p.returncode == 0, "Failed to install ppbt"
475569
env = os.environ.copy()
476570
env["RELENV_BUILDENV"] = "yes"
477571
env["RELENV_DEBUG"] = "yes"
@@ -555,6 +649,14 @@ def test_pip_install_m2crypto_system_ssl(pipexec, pyexec):
555649

556650
@pytest.mark.skip_unless_on_linux
557651
def test_pip_install_m2crypto_relenv_ssl(pipexec, pyexec, build):
652+
p = subprocess.run(
653+
[
654+
str(pipexec),
655+
"install",
656+
"ppbt",
657+
]
658+
)
659+
assert p.returncode == 0, "Failed to install ppbt"
558660
p = subprocess.run(
559661
[
560662
pyexec,
@@ -628,6 +730,14 @@ def validate_shebang(path):
628730
# XXX Mac support
629731
@pytest.mark.skip_unless_on_linux
630732
def test_moving_pip_installed_c_extentions(pipexec, build, minor_version):
733+
p = subprocess.run(
734+
[
735+
str(pipexec),
736+
"install",
737+
"ppbt",
738+
]
739+
)
740+
assert p.returncode == 0, "Failed to install ppbt"
631741
env = os.environ.copy()
632742
env["RELENV_DEBUG"] = "yes"
633743
env["RELENV_BUILDENV"] = "yes"
@@ -657,6 +767,15 @@ def test_moving_pip_installed_c_extentions(pipexec, build, minor_version):
657767
@pytest.mark.skip_unless_on_linux
658768
@pytest.mark.parametrize("cryptography_version", ["40.0.1", "39.0.2"])
659769
def test_cryptography_rpath(pipexec, build, minor_version, cryptography_version):
770+
p = subprocess.run(
771+
[
772+
str(pipexec),
773+
"install",
774+
"ppbt",
775+
]
776+
)
777+
assert p.returncode == 0, "Failed to install ppbt"
778+
660779
def find_library(path, search):
661780
for root, dirs, files in os.walk(path):
662781
for fname in files:
@@ -723,6 +842,14 @@ def find_library(path, search):
723842

724843
@pytest.mark.skip_unless_on_linux
725844
def test_install_pycurl(pipexec, build):
845+
p = subprocess.run(
846+
[
847+
str(pipexec),
848+
"install",
849+
"ppbt",
850+
]
851+
)
852+
assert p.returncode == 0, "Failed to install ppbt"
726853
curlver = "8.0.1"
727854

728855
# Build curl and install it into the relenv environment
@@ -819,6 +946,14 @@ def build_dir(tmp_path):
819946
],
820947
)
821948
def test_install_libgit2(pipexec, build, minor_version, build_dir, versions):
949+
p = subprocess.run(
950+
[
951+
str(pipexec),
952+
"install",
953+
"ppbt",
954+
]
955+
)
956+
assert p.returncode == 0, "Failed to install ppbt"
822957

823958
buildscript = textwrap.dedent(
824959
"""\
@@ -895,6 +1030,14 @@ def test_install_libgit2(pipexec, build, minor_version, build_dir, versions):
8951030

8961031
@pytest.mark.skip_unless_on_linux
8971032
def test_install_python_ldap(pipexec, build):
1033+
p = subprocess.run(
1034+
[
1035+
str(pipexec),
1036+
"install",
1037+
"ppbt",
1038+
]
1039+
)
1040+
assert p.returncode == 0, "Failed to install ppbt"
8981041
saslver = "2.1.28"
8991042
ldapver = "2.5.14"
9001043

0 commit comments

Comments
 (0)