1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import os
1516import subprocess
17+ import sys
1618import zipfile
1719import shutil
1820from pathlib import Path
2123
2224ROOT_DIR = Path (__file__ ).resolve ().parents [1 ]
2325
26+ # Read version and requires-python from pyproject.toml
27+ if sys .version_info >= (3 , 11 ):
28+ import tomllib
29+ else :
30+ try :
31+ import tomllib
32+ except ImportError :
33+ import tomli as tomllib # noqa: F401
34+
35+ with open (ROOT_DIR / "pyproject.toml" , "rb" ) as f :
36+ _pyproject = tomllib .load (f )
37+
38+ PROJECT_NAME = _pyproject ["project" ]["name" ]
39+ PROJECT_VERSION = _pyproject ["project" ]["version" ]
40+ REQUIRES_PYTHON = _pyproject ["project" ]["requires-python" ]
41+ CURRENT_PYTHON = f"{ sys .version_info .major } .{ sys .version_info .minor } "
42+
43+
44+ def _python_bin (venv_dir : Path ) -> Path :
45+ """Return the platform-appropriate Python binary path inside a venv."""
46+ if os .name == "nt" :
47+ return venv_dir / "Scripts" / "python.exe"
48+ return venv_dir / "bin" / "python"
49+
2450
2551def _uv_available () -> bool :
2652 return shutil .which ("uv" ) is not None
@@ -63,9 +89,9 @@ def test_wheel_metadata(self, tmp_path):
6389 assert len (metadata_files ) == 1 , f"Expected 1 METADATA file, found: { metadata_files } "
6490 metadata = zf .read (metadata_files [0 ]).decode ("utf-8" )
6591
66- assert "Name: GQLAlchemy " in metadata
67- assert "Version: 1.8.0 " in metadata
68- assert "Requires-Python: >=3.10 " in metadata
92+ assert f "Name: { PROJECT_NAME } " in metadata
93+ assert f "Version: { PROJECT_VERSION } " in metadata
94+ assert f "Requires-Python: { REQUIRES_PYTHON } " in metadata
6995
7096 def test_wheel_contains_package (self , tmp_path ):
7197 """The wheel should include the gqlalchemy package directory."""
@@ -86,6 +112,7 @@ def test_wheel_contains_package(self, tmp_path):
86112 assert len (gqlalchemy_files ) > 0 , "Wheel does not contain gqlalchemy/ package"
87113 assert any (n == "gqlalchemy/__init__.py" for n in gqlalchemy_files ), "Missing gqlalchemy/__init__.py"
88114
115+ @pytest .mark .slow
89116 def test_wheel_install_in_isolated_venv (self , tmp_path ):
90117 """The wheel should install successfully into a fresh venv."""
91118 wheel_dir = tmp_path / "dist"
@@ -103,16 +130,16 @@ def test_wheel_install_in_isolated_venv(self, tmp_path):
103130
104131 wheel_file = next (wheel_dir .glob ("*.whl" ))
105132
106- # Create isolated venv + install
133+ # Create isolated venv using the current Python version
107134 subprocess .run (
108- ["uv" , "venv" , "--python" , "3.12" , str (venv_dir )],
135+ ["uv" , "venv" , "--python" , CURRENT_PYTHON , str (venv_dir )],
109136 capture_output = True ,
110137 text = True ,
111138 timeout = 60 ,
112139 check = True ,
113140 )
114141
115- python = venv_dir / "bin" / "python"
142+ python = _python_bin ( venv_dir )
116143 result = subprocess .run (
117144 ["uv" , "pip" , "install" , "--python" , str (python ), str (wheel_file )],
118145 capture_output = True ,
@@ -149,14 +176,14 @@ def _make_venv_and_install_extra(tmp_path, extra, import_check):
149176 wheel_file = next (wheel_dir .glob ("*.whl" ))
150177
151178 subprocess .run (
152- ["uv" , "venv" , "--python" , "3.12" , str (venv_dir )],
179+ ["uv" , "venv" , "--python" , CURRENT_PYTHON , str (venv_dir )],
153180 capture_output = True ,
154181 text = True ,
155182 timeout = 60 ,
156183 check = True ,
157184 )
158185
159- python = str (venv_dir / "bin" / "python" )
186+ python = str (_python_bin ( venv_dir ) )
160187
161188 # Install wheel with the extra
162189 result = subprocess .run (
0 commit comments