@@ -15,91 +15,84 @@ def make_paths(root, paths):
1515 os .makedirs (pjoin (root , p .lstrip ("/" )))
1616
1717
18- def test_path_discovery (monkeypatch ):
18+ def test_path_discovery ():
1919 version = sys .version_info
2020 X , Y = version .major , version .minor
2121
22- # With multiple site-packages, choose the one that
23- # matches the current Python version
22+ # With multiple site-packages, choose the one that matches the
23+ # current Python version
2424 with tempfile .TemporaryDirectory () as d :
25- with monkeypatch .context () as m :
26- install_dir = pjoin (d , "build-install" )
27- m .setattr (meson , "install_dir" , install_dir )
28-
29- make_paths (
30- install_dir ,
31- [
32- f"/usr/lib64/python{ X } .{ Y } /site-packages" ,
33- f"/usr/lib64/python{ X } .{ Y + 1 } /site-packages" ,
34- f"/usr/lib64/python{ X } .{ Y + 2 } /site-packages" ,
35- ],
36- )
37- assert (
38- normpath (f"/usr/lib64/python{ X } .{ Y } /site-packages" )
39- in meson ._get_site_packages ()
40- )
25+ build_dir = pjoin (d , "./build" )
26+ install_dir = pjoin (d , "./build-install" )
27+
28+ make_paths (
29+ install_dir ,
30+ [
31+ f"/usr/lib64/python{ X } .{ Y } /site-packages" ,
32+ f"/usr/lib64/python{ X } .{ Y + 1 } /site-packages" ,
33+ f"/usr/lib64/python{ X } .{ Y + 2 } /site-packages" ,
34+ ],
35+ )
36+ assert normpath (
37+ f"/usr/lib64/python{ X } .{ Y } /site-packages"
38+ ) in meson ._get_site_packages (build_dir )
4139
4240 # Debian uses dist-packages
4341 with tempfile .TemporaryDirectory () as d :
44- with monkeypatch .context () as m :
45- install_dir = pjoin (d , "build-install" )
46- m .setattr (meson , "install_dir" , install_dir )
47-
48- make_paths (
49- install_dir ,
50- [
51- f"/usr/lib64/python{ X } .{ Y } /dist-packages" ,
52- ],
53- )
54- assert (
55- normpath (f"/usr/lib64/python{ X } .{ Y } /dist-packages" )
56- in meson ._get_site_packages ()
57- )
42+ build_dir = pjoin (d , "./build" )
43+ install_dir = pjoin (d , "./build-install" )
44+
45+ make_paths (
46+ install_dir ,
47+ [
48+ f"/usr/lib64/python{ X } .{ Y } /dist-packages" ,
49+ ],
50+ )
51+ assert normpath (
52+ f"/usr/lib64/python{ X } .{ Y } /dist-packages"
53+ ) in meson ._get_site_packages (build_dir )
5854
5955 # If there is no version information in site-packages,
6056 # use whatever site-packages can be found
6157 with tempfile .TemporaryDirectory () as d :
62- with monkeypatch .context () as m :
63- install_dir = pjoin (d , "build-install" )
64- m .setattr (meson , "install_dir" , install_dir )
58+ build_dir = pjoin (d , "./build" )
59+ install_dir = pjoin (d , "./build-install" )
6560
66- make_paths (install_dir , ["/Python3/site-packages" ])
67- assert normpath ("/Python3/site-packages" ) in meson ._get_site_packages ()
61+ make_paths (install_dir , ["/Python3/site-packages" ])
62+ assert normpath ("/Python3/site-packages" ) in meson ._get_site_packages (build_dir )
6863
6964 # Raise if no site-package directory present
7065 with tempfile .TemporaryDirectory () as d :
71- with monkeypatch .context () as m :
72- install_dir = pjoin (d , "build-install" )
73- m .setattr (meson , "install_dir" , install_dir )
66+ install_dir = pjoin (d , "-install" )
7467
75- with pytest .raises (FileNotFoundError ):
76- meson ._get_site_packages ()
68+ with pytest .raises (FileNotFoundError ):
69+ meson ._get_site_packages (build_dir )
7770
7871 # If there are multiple site-package paths, but without version information,
7972 # refuse the temptation to guess
8073 with tempfile .TemporaryDirectory () as d :
81- install_dir = pjoin (d , "build-install" )
74+ build_dir = pjoin (d , "./build" )
75+ install_dir = pjoin (d , "./build-install" )
8276 make_paths (
8377 install_dir , ["/Python3/x/site-packages" , "/Python3/y/site-packages" ]
8478 )
8579 with pytest .raises (FileNotFoundError ):
86- meson ._get_site_packages ()
80+ meson ._get_site_packages (build_dir )
8781
8882 # Multiple site-package paths found, but none that matches our Python
8983 with tempfile .TemporaryDirectory () as d :
90- with monkeypatch .context () as m :
91- install_dir = pjoin (d , "build-install" )
92- m .setattr (meson , "install_dir" , install_dir )
93-
94- make_paths (
95- install_dir ,
96- [
97- f"/usr/lib64/python{ X } .{ Y + 1 } /site-packages" ,
98- f"/usr/lib64/python{ X } .{ Y + 2 } /site-packages" ,
99- ],
100- )
101- with pytest .raises (FileNotFoundError ):
102- meson ._get_site_packages ()
84+ build_dir = pjoin (d , "./build" )
85+ install_dir = pjoin (d , "./build-install" )
86+
87+ make_paths (
88+ install_dir ,
89+ [
90+ f"/usr/lib64/python{ X } .{ Y + 1 } /site-packages" ,
91+ f"/usr/lib64/python{ X } .{ Y + 2 } /site-packages" ,
92+ ],
93+ )
94+ with pytest .raises (FileNotFoundError ):
95+ meson ._get_site_packages (build_dir )
10396
10497
10598def test_meson_cli_discovery (monkeypatch ):
0 commit comments