22
33import contextlib
44import os
5- import re
65import subprocess
76import sys
87import tarfile
98import zipfile
109from pathlib import Path
1110from typing import Generator
12- from pprint import pprint
1311
1412# These tests must be run explicitly
1513
1614DIR = Path (__file__ ).parent .resolve ()
1715MAIN_DIR = DIR .parent .parent
1816
19- MARKER_PATTERN = re .compile (
20- r"# not-in-global-start.*?# not-in-global-end\n?" , re .DOTALL
21- )
17+
18+ # Newer pytest has global path setting, but keeping old pytest for now
19+ sys .path .append (str (MAIN_DIR / "tools" ))
20+
21+ from make_global import get_global # noqa: E402
2222
2323PKGCONFIG = """\
2424 prefix=${{pcfiledir}}/../../
@@ -151,12 +151,8 @@ def build_global() -> Generator[None, None, None]:
151151 """
152152
153153 pyproject = MAIN_DIR / "pyproject.toml"
154- with preserve_file (pyproject ) as txt :
155- new_txt = txt .replace ('name = "pybind11"' , 'name = "pybind11-global"' )
156- assert txt != new_txt
157- newer_txt = MARKER_PATTERN .sub ("" , new_txt )
158- assert new_txt != newer_txt
159-
154+ with preserve_file (pyproject ):
155+ newer_txt = get_global ()
160156 pyproject .write_text (newer_txt , encoding = "utf-8" )
161157 yield
162158
@@ -183,16 +179,13 @@ def test_build_sdist(monkeypatch, tmpdir):
183179 (sdist ,) = tmpdir .visit ("*.tar.gz" )
184180
185181 with tarfile .open (str (sdist ), "r:gz" ) as tar :
186- start = tar .getnames ()[0 ] + "/"
187- version = start [9 :- 1 ]
188182 simpler = {n .split ("/" , 1 )[- 1 ] for n in tar .getnames ()[1 :]}
189183
190184 pyproject_toml = read_tz_file (tar , "pyproject.toml" )
191185
192186 files = headers | sdist_files
193187 assert files <= simpler
194188
195- simple_version = "." .join (version .split ("." )[:3 ])
196189 assert b'name = "pybind11"' in pyproject_toml
197190
198191
@@ -207,8 +200,6 @@ def test_build_global_dist(monkeypatch, tmpdir):
207200 (sdist ,) = tmpdir .visit ("*.tar.gz" )
208201
209202 with tarfile .open (str (sdist ), "r:gz" ) as tar :
210- start = tar .getnames ()[0 ] + "/"
211- version = start [16 :- 1 ]
212203 simpler = {n .split ("/" , 1 )[- 1 ] for n in tar .getnames ()[1 :]}
213204
214205 pyproject_toml = read_tz_file (tar , "pyproject.toml" )
@@ -249,11 +240,8 @@ def tests_build_global_wheel(monkeypatch, tmpdir):
249240 monkeypatch .chdir (MAIN_DIR )
250241 with build_global ():
251242 subprocess .run (
252- [sys .executable , "-m" , "pip" , "wheel" , "." ,
253- "-Cskbuild.wheel.install-dir=/data" ,
254- "-Cskbuild.experimental=true" ,
255- "-w" ,
256- str (tmpdir )], check = True
243+ [sys .executable , "-m" , "pip" , "wheel" , "." , "-w" , str (tmpdir )],
244+ check = True ,
257245 )
258246
259247 (wheel ,) = tmpdir .visit ("*.whl" )
@@ -272,7 +260,6 @@ def tests_build_global_wheel(monkeypatch, tmpdir):
272260 names = z .namelist ()
273261
274262 beginning = names [0 ].split ("/" , 1 )[0 ].rsplit ("." , 1 )[0 ]
275- pprint (names )
276263 trimmed = {n [len (beginning ) + 1 :] for n in names }
277264
278265 assert files == trimmed
0 commit comments