55from tempfile import TemporaryDirectory
66from pathlib import Path
77import csv
8- from .constants import PYTHON_VERSION
8+ import json
9+ import glob
10+
11+
12+ def _get_python_version (prefix_path ):
13+ path = glob .glob (f"{ prefix_path } /conda-meta/python-3.*.json" )
14+
15+ if not path :
16+ raise RuntimeError ("Python needs to be installed for installing pip dependencies" )
17+
18+ version = json .load (open (path [0 ]))["version" ].split ("." )
19+ return f"{ version [0 ]} .{ version [1 ]} "
920
1021
1122def _install_pip_dependencies (prefix_path , dependencies , log = None ):
@@ -28,6 +39,8 @@ def _install_pip_dependencies(prefix_path, dependencies, log=None):
2839 # So we need to do this whole mess "manually"
2940 pkg_dir = TemporaryDirectory ()
3041
42+ python_version = _get_python_version (prefix_path )
43+
3144 subprocess_run (
3245 [
3346 sys .executable ,
@@ -40,7 +53,7 @@ def _install_pip_dependencies(prefix_path, dependencies, log=None):
4053 pkg_dir .name ,
4154 # Specify the right Python version
4255 "--python-version" ,
43- PYTHON_VERSION ,
56+ python_version ,
4457 # No dependency installed
4558 "--no-deps" ,
4659 "--no-input" ,
@@ -85,7 +98,7 @@ def _install_pip_dependencies(prefix_path, dependencies, log=None):
8598 install_path = (
8699 prefix_path
87100 if not inside_site_packages
88- else prefix_path / "lib" / f"python{ PYTHON_VERSION } " / "site-packages"
101+ else prefix_path / "lib" / f"python{ python_version } " / "site-packages"
89102 )
90103
91104 src_path = Path (pkg_dir .name ) / file_path
0 commit comments