Skip to content

Commit c930fc8

Browse files
committed
[GR-13591] Test pip install in venv and pip list in gate
PullRequest: graalpython/430
2 parents ce9df96 + 3861a51 commit c930fc8

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_venv.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,31 @@
3737
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
# SOFTWARE.
3939

40-
import tempfile
41-
import sys
42-
import shutil
4340
import os
41+
import re
42+
import shutil
4443
import subprocess
44+
import sys
45+
import tempfile
4546

4647

4748
class VenvTest():
4849
def setUp(self):
4950
self.env_dir = os.path.realpath(tempfile.mkdtemp())
51+
self.env_dir2 = os.path.realpath(tempfile.mkdtemp())
5052

5153
def tearDown(self):
5254
shutil.rmtree(self.env_dir)
55+
shutil.rmtree(self.env_dir2)
5356

5457
def test_create_and_use_basic_venv(self):
5558
subprocess.check_output([sys.executable, "-m", "venv", self.env_dir, "--without-pip"])
5659
run = subprocess.getoutput(". %s/bin/activate; python -m site" % self.env_dir)
5760
assert "ENABLE_USER_SITE: False" in run, run
5861
assert self.env_dir in run, run
62+
63+
def test_create_and_use_venv_with_pip(self):
64+
subprocess.check_output([sys.executable, "-m", "venv", self.env_dir2])
65+
run = subprocess.getoutput("%s/bin/python -m pip list" % self.env_dir2)
66+
assert "pip" in run, run
67+
assert "setuptools" in run, run

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,23 @@ public PReferenceType refType(LazyPythonClass cls, Object object, @SuppressWarni
137137

138138
@Specialization(guards = "!isNativeObject(object)")
139139
public PReferenceType refType(LazyPythonClass cls, Object object, Object callback) {
140-
return factory().createReferenceType(cls, object, callback, getWeakReferenceQueue());
140+
if (callback instanceof PNone) {
141+
return factory().createReferenceType(cls, object, null, getWeakReferenceQueue());
142+
} else {
143+
return factory().createReferenceType(cls, object, callback, getWeakReferenceQueue());
144+
}
141145
}
142146

143147
@Specialization
144148
public PReferenceType refType(LazyPythonClass cls, PythonAbstractNativeObject pythonObject, Object callback,
145149
@Cached("create()") GetLazyClassNode getClassNode,
146150
@Cached("create()") IsBuiltinClassProfile profile) {
151+
Object actualCallback = callback instanceof PNone ? null : callback;
147152
LazyPythonClass clazz = getClassNode.execute(pythonObject);
148153

149154
// if the object is a type, a weak ref is allowed
150155
if (profile.profileClass(clazz, PythonBuiltinClassType.PythonClass)) {
151-
return factory().createReferenceType(cls, pythonObject, callback, getWeakReferenceQueue());
156+
return factory().createReferenceType(cls, pythonObject, actualCallback, getWeakReferenceQueue());
152157
}
153158

154159
// if the object's type is a native type, we need to consider 'tp_weaklistoffset'
@@ -159,10 +164,10 @@ public PReferenceType refType(LazyPythonClass cls, PythonAbstractNativeObject py
159164
}
160165
Object tpWeaklistoffset = getTpWeaklistoffsetNode.execute(clazz);
161166
if (tpWeaklistoffset != PNone.NO_VALUE) {
162-
return factory().createReferenceType(cls, pythonObject, callback, getWeakReferenceQueue());
167+
return factory().createReferenceType(cls, pythonObject, actualCallback, getWeakReferenceQueue());
163168
}
164169
}
165-
return refType(cls, pythonObject, callback);
170+
return refType(cls, pythonObject, actualCallback);
166171
}
167172

168173
@Fallback

mx.graalpython/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "graalpython",
1010
"versionConflictResolution": "latest",
1111

12-
"version": "1.0.0-rc14",
12+
"version": "1.0.0-rc15",
1313
"release": False,
1414
"groupId": "org.graalvm.graalpython",
1515
"url": "http://www.graalvm.org/",

0 commit comments

Comments
 (0)