4646import unittest
4747from pathlib import Path
4848
49+ from tests .testlib_helper import build_testlib
50+
4951
5052class TestWheelBuildAndRun (unittest .TestCase ):
5153 def test_build_install_and_run (self ):
5254 # Build a C library and a wheel that depends on it. Then run it through repair_wheel to vendor the library in and verify that it can be imported
53- orig_root = ( Path (__file__ ).parent / "example_wheel" ) .resolve ()
54- orig_testwheel = orig_root / "testwheel"
55- orig_answerlib = orig_root / "answerlib "
55+ orig_root = Path (__file__ ).parent .resolve ()
56+ orig_test_wheel = orig_root / "testwheel"
57+ orig_testlib = orig_root / "testlib "
5658
5759 with tempfile .TemporaryDirectory (prefix = "testwheel_tmp_" ) as tmpdir :
5860 tmpdir = Path (tmpdir )
59- tmp_testwheel = tmpdir / "testwheel"
60- tmp_answerlib = tmpdir / "answerlib"
61+ tmp_test_wheel = tmpdir / "testwheel"
6162 venv_dir = tmpdir / "venv"
6263 repair_venv_dir = tmpdir / "repair_venv"
6364 wheel_dir = tmpdir / "wheels"
6465 repaired_dir = tmpdir / "repaired"
6566
66- shutil .copytree (orig_testwheel , tmp_testwheel )
67- shutil .copytree (orig_answerlib , tmp_answerlib )
68-
69- answerlib_build = tmp_answerlib / "build"
70- if answerlib_build .exists ():
71- shutil .rmtree (answerlib_build )
72- answerlib_build .mkdir (parents = True , exist_ok = True )
73-
74- cmd = ["cmake" , "-DCMAKE_BUILD_TYPE=Release" , ".." ]
75- print ("Running:" , shlex .join (cmd ))
76- subprocess .check_call (cmd , cwd = str (answerlib_build ))
77- cmd = ["cmake" , "--build" , "." , "--config" , "Release" ]
78- print ("Running:" , shlex .join (cmd ))
79- subprocess .check_call (cmd , cwd = str (answerlib_build ))
67+ shutil .copytree (orig_test_wheel , tmp_test_wheel )
68+ testlib_build = build_testlib (tmpdir , orig_testlib )
8069
8170 cmd = [sys .executable , "-m" , "venv" , str (venv_dir )]
8271 print ("Running:" , shlex .join (cmd ))
@@ -96,7 +85,7 @@ def test_build_install_and_run(self):
9685 wheel_dir .mkdir (parents = True , exist_ok = True )
9786 cmd = [str (python ), "-m" , "build" , "--wheel" , "--outdir" , str (wheel_dir )]
9887 print ("Running:" , shlex .join (cmd ))
99- subprocess .check_call (cmd , cwd = str (tmp_testwheel ))
88+ subprocess .check_call (cmd , cwd = str (tmp_test_wheel ))
10089
10190 built_wheels = list (wheel_dir .glob ("testwheel-*.whl" ))
10291 self .assertTrue (built_wheels , "Wheel was not built!" )
@@ -117,11 +106,11 @@ def test_build_install_and_run(self):
117106
118107 repair_env = os .environ .copy ()
119108 if sys .platform .startswith ("linux" ):
120- repair_env ["LD_LIBRARY_PATH" ] = str (answerlib_build )
109+ repair_env ["LD_LIBRARY_PATH" ] = str (testlib_build )
121110 elif sys .platform == "darwin" :
122- repair_env ["DYLD_LIBRARY_PATH" ] = str (answerlib_build )
111+ repair_env ["DYLD_LIBRARY_PATH" ] = str (testlib_build )
123112 elif sys .platform == "win32" :
124- repair_env ["PATH" ] = str (answerlib_build ) + os .pathsep + repair_env .get ("PATH" , "" )
113+ repair_env ["PATH" ] = str (testlib_build ) + os .pathsep + repair_env .get ("PATH" , "" )
125114 cmd = [
126115 str (python_repair ),
127116 str ((Path (
0 commit comments