@@ -46,11 +46,6 @@ def __init__(self, system_site_packages=False, clear=False,
46
46
self .symlinks = symlinks
47
47
self .upgrade = upgrade
48
48
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
54
49
self .prompt = prompt
55
50
56
51
def create (self , env_dir ):
@@ -119,9 +114,22 @@ def create_if_needed(d):
119
114
context .python_dir = dirname
120
115
context .python_exe = exename
121
116
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
+
122
128
# Truffle change: our executable may not just be a file (e.g. we're
123
129
# running through java), we always provide a script for launching in
124
130
# venv
131
+ exename = context .python_exe = "graalpython"
132
+
125
133
import atexit , tempfile
126
134
tempdir = tempfile .mkdtemp ()
127
135
script = os .path .join (tempdir , "graalpython" )
@@ -132,6 +140,13 @@ def create_if_needed(d):
132
140
if sys .platform != "win32" :
133
141
f .write ("#!/bin/sh\n " )
134
142
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
+ ))
135
150
if sys .platform == "win32" :
136
151
f .write (" %*" )
137
152
else :
@@ -143,24 +158,13 @@ def create_if_needed(d):
143
158
atexit .register (lambda : shutil .rmtree (tempdir , ignore_errors = True ))
144
159
145
160
dirname = context .python_dir = sys .graal_python_home
146
- exename = context .python_exe = "graalpython"
147
161
context .executable = script
148
162
149
163
if self .symlinks :
150
164
logger .warning ("We're not using symlinks in a Graal Python venv" )
151
165
self .symlinks = False
152
166
# End of Truffle change
153
167
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' )
164
168
context .inc_path = path = os .path .join (env_dir , incpath )
165
169
create_if_needed (path )
166
170
create_if_needed (libpath )
@@ -278,7 +282,10 @@ def _setup_pip(self, context):
278
282
# We run ensurepip in isolated mode to avoid side effects from
279
283
# environment vars, the current directory and anything else
280
284
# 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' ,
282
289
'--default-pip' ]
283
290
subprocess .check_output (cmd , stderr = subprocess .STDOUT )
284
291
@@ -323,7 +330,7 @@ def replace_variables(self, text, context):
323
330
text = text .replace ('__VENV_PROMPT__' , context .prompt )
324
331
text = text .replace ('__VENV_BIN_NAME__' , context .bin_name )
325
332
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
327
334
text = text .replace (
328
335
'__VENV_GRAAL_PYTHON_OPTIONS__' ,
329
336
"--python.CoreHome='%s' --python.StdLibHome='%s' --python.SysPrefix='%s' --python.SysBasePrefix='%s' --python.Executable='%s'" % (
0 commit comments