@@ -46,11 +46,6 @@ def __init__(self, system_site_packages=False, clear=False,
4646 self .symlinks = symlinks
4747 self .upgrade = upgrade
4848 self .with_pip = with_pip
49- # Truffle change
50- if with_pip :
51- logger .warning ("We cannot install pip on Graal Python, yet" )
52- self .with_pip = False
53- # End Truffle change
5449 self .prompt = prompt
5550
5651 def create (self , env_dir ):
@@ -119,9 +114,22 @@ def create_if_needed(d):
119114 context .python_dir = dirname
120115 context .python_exe = exename
121116
117+ if sys .platform == 'win32' :
118+ binname = 'Scripts'
119+ incpath = 'Include'
120+ libpath = os .path .join (env_dir , 'Lib' , 'site-packages' )
121+ else :
122+ binname = 'bin'
123+ incpath = 'include'
124+ libpath = os .path .join (env_dir , 'lib' ,
125+ 'python%d.%d' % sys .version_info [:2 ],
126+ 'site-packages' )
127+
122128 # Truffle change: our executable may not just be a file (e.g. we're
123129 # running through java), we always provide a script for launching in
124130 # venv
131+ exename = context .python_exe = "graalpython"
132+
125133 import atexit , tempfile
126134 tempdir = tempfile .mkdtemp ()
127135 script = os .path .join (tempdir , "graalpython" )
@@ -132,6 +140,13 @@ def create_if_needed(d):
132140 if sys .platform != "win32" :
133141 f .write ("#!/bin/sh\n " )
134142 f .write (sys .executable )
143+ f .write (" --python.CoreHome='%s' --python.StdLibHome='%s' --python.SysPrefix='%s' --python.SysBasePrefix='%s' --python.Executable='%s'" % (
144+ sys .graal_python_core_home ,
145+ sys .graal_python_stdlib_home ,
146+ context .env_dir ,
147+ sys .base_prefix ,
148+ os .path .join (context .env_dir , binname , exename ),
149+ ))
135150 if sys .platform == "win32" :
136151 f .write (" %*" )
137152 else :
@@ -143,24 +158,13 @@ def create_if_needed(d):
143158 atexit .register (lambda : shutil .rmtree (tempdir , ignore_errors = True ))
144159
145160 dirname = context .python_dir = sys .graal_python_home
146- exename = context .python_exe = "graalpython"
147161 context .executable = script
148162
149163 if self .symlinks :
150164 logger .warning ("We're not using symlinks in a Graal Python venv" )
151165 self .symlinks = False
152166 # End of Truffle change
153167
154- if sys .platform == 'win32' :
155- binname = 'Scripts'
156- incpath = 'Include'
157- libpath = os .path .join (env_dir , 'Lib' , 'site-packages' )
158- else :
159- binname = 'bin'
160- incpath = 'include'
161- libpath = os .path .join (env_dir , 'lib' ,
162- 'python%d.%d' % sys .version_info [:2 ],
163- 'site-packages' )
164168 context .inc_path = path = os .path .join (env_dir , incpath )
165169 create_if_needed (path )
166170 create_if_needed (libpath )
@@ -278,7 +282,10 @@ def _setup_pip(self, context):
278282 # We run ensurepip in isolated mode to avoid side effects from
279283 # environment vars, the current directory and anything else
280284 # intended for the global Python environment
281- cmd = [context .env_exe , '-Im' , 'ensurepip' , '--upgrade' ,
285+ # Truffle change: the graal python interpreter cannot yet parse grouped flags
286+ # cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade',
287+ # End Truffle change
288+ cmd = [context .env_exe , '-I' , '-m' , 'ensurepip' , '--upgrade' ,
282289 '--default-pip' ]
283290 subprocess .check_output (cmd , stderr = subprocess .STDOUT )
284291
@@ -323,7 +330,7 @@ def replace_variables(self, text, context):
323330 text = text .replace ('__VENV_PROMPT__' , context .prompt )
324331 text = text .replace ('__VENV_BIN_NAME__' , context .bin_name )
325332 text = text .replace ('__VENV_PYTHON__' , context .env_exe )
326- # Truffle change: we need to set some extra options for the launcher to work
333+ # Truffle change: # Truffle change: we need to set some extra options for the launcher to work
327334 text = text .replace (
328335 '__VENV_GRAAL_PYTHON_OPTIONS__' ,
329336 "--python.CoreHome='%s' --python.StdLibHome='%s' --python.SysPrefix='%s' --python.SysBasePrefix='%s' --python.Executable='%s'" % (
0 commit comments