Jeff Allen avatar Jeff Allen committed f731a59 Merge

Merge buffer development

Comments (0)

Files changed (3)

 from __future__ import print_function
 
+import sys
 from java.io import Serializable
 from java.util.concurrent import Callable
 
     def call(self):
         # Using print forces use of PySystemState and shows it's initialized
         print("%s barks %s times" % (self.name, self.number))
+        # Verify that site has been imported and therefore
+        # site-packages and distutils/setuptools goodness is available
+        return "site" in sys.modules
 
     def __eq__(self, other):
         return self.name == other.name and self.number == other.number

Lib/test/test_java_integration.py

         tempdir = tempfile.mkdtemp()
         try:
             SerializableProxies.serialized_path = tempdir
-            import bark #importlib.import_module("bark")
+            import bark
             dog = bark.Dog()
             self.assertEqual(dog.whoami(), "Rover")
             self.assertEqual(dog.serialVersionUID, 1)
     public static void main(String[] args) {
         Dog dog = new Dog();
         try {
-            dog.call();
+            Boolean b = (Boolean)(dog.call());
+            if (!b) {
+                throw new RuntimeException("Expected site module to be imported");
+            }
         }
         catch(Exception e) {
             System.err.println(e);
                    "-classpath", classpath, "BarkTheDog"]
             env = dict(os.environ)
             env.update(JYTHONPATH=os.path.normpath(os.path.join(__file__, "..")))
-            self.assertEqual(
-                subprocess.check_output(cmd, env=env, universal_newlines=True),
-                    "Class defined on CLASSPATH <type 'org.python.test.bark.Dog'>\n"
-                    "Rover barks 42 times\n")
+            self.assertRegexpMatches(
+                subprocess.check_output(cmd, env=env, universal_newlines=True,
+                                        stderr=subprocess.STDOUT),
+                r"^\*sys-package-mgr\*: processing new jar, '.+?/proxies.jar'\n"
+                 "Class defined on CLASSPATH <type 'org.python.test.bark.Dog'>\n"
+                 "Rover barks 42 times\n$".format(tempdir))
         finally:
             pass
             # print "Will not remove", tempdir

src/org/python/core/Py.java

             return;
         }
 
+        if (Options.importSite) {
+            // Ensure site-packages are available before attempting to import module.
+            // This step enables supporting modern Python apps when using proxies
+            // directly from Java (eg through clamp).
+            imp.load("site");
+        }
         PyObject mod = imp.importName(module.intern(), false);
         PyType pyc = (PyType)mod.__getattr__(pyclass.intern());
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.