| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | from distutils.command.build_ext import build_ext | |
| 7 | 7 | from distutils.command.build_scripts import build_scripts | |
| 8 | 8 | from distutils.command.install_lib import install_lib | |
| 9 | - from distutils.sysconfig import get_config_vars | ||
| 9 | + from distutils.sysconfig import get_config_var | ||
| 10 | 10 | from platform import architecture | |
| 11 | 11 | from subprocess import Popen, CalledProcessError, PIPE, check_call | |
| 12 | 12 | from glob import glob | |
@@ -183,15 +183,22 @@ def _build_monoclr(self, ext): | |||
| 183 | 183 | depends=ext.depends) | |
| 184 | 184 | ||
| 185 | 185 | output_dir = os.path.dirname(self.get_ext_fullpath(ext.name)) | |
| 186 | - py_libs = get_config_vars("BLDLIBRARY")[0] | ||
| 186 | + py_libs = get_config_var("BLDLIBRARY") | ||
| 187 | 187 | libs += " " + py_libs | |
| 188 | 188 | ||
| 189 | + # Include the directories python's shared libs were installed to. This | ||
| 190 | + # is case python was built with --enable-shared as then npython will need | ||
| 191 | + # to be able to find libpythonX.X.so. | ||
| 192 | + runtime_library_dirs = (get_config_var("DESTDIRS") or "").split(" ") | ||
| 193 | + if ext.runtime_library_dirs: | ||
| 194 | + runtime_library_dirs.extend(ext.runtime_library_dirs) | ||
| 195 | + | ||
| 189 | 196 | self.compiler.link_executable(objects, | |
| 190 | 197 | _npython_exe, | |
| 191 | 198 | output_dir=output_dir, | |
| 192 | 199 | libraries=self.get_libraries(ext), | |
| 193 | 200 | library_dirs=ext.library_dirs, | |
| 194 | - runtime_library_dirs=ext.runtime_library_dirs, | ||
| 201 | + runtime_library_dirs=runtime_library_dirs, | ||
| 195 | 202 | extra_postargs=libs.split(" "), | |
| 196 | 203 | debug=self.debug) | |
| 197 | 204 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ internal class AssemblyManager { | |||
| 30 | 30 | static ResolveEventHandler rhandler; | |
| 31 | 31 | static Dictionary<string, int> probed; | |
| 32 | 32 | static List<Assembly> assemblies; | |
| 33 | - static Dictionary<string, Assembly> loadedAssemblies; | ||
| 34 | 33 | internal static List<string> pypath; | |
| 35 | 34 | ||
| 36 | 35 | private AssemblyManager() {} | |
@@ -47,7 +46,6 @@ internal static void Initialize() { | |||
| 47 | 46 | probed = new Dictionary<string, int>(32); | |
| 48 | 47 | //generics = new Dictionary<string, Dictionary<string, string>>(); | |
| 49 | 48 | assemblies = new List<Assembly>(16); | |
| 50 | - loadedAssemblies = new Dictionary<string, Assembly>(); | ||
| 51 | 49 | pypath = new List<string>(16); | |
| 52 | 50 | ||
| 53 | 51 | AppDomain domain = AppDomain.CurrentDomain; | |
@@ -204,24 +202,25 @@ public static Assembly LoadAssemblyPath(string name) { | |||
| 204 | 202 | string path = FindAssembly(name); | |
| 205 | 203 | Assembly assembly = null; | |
| 206 | 204 | if (path != null) { | |
| 207 | - if (loadedAssemblies.ContainsKey(path)) { | ||
| 208 | - return loadedAssemblies[path]; | ||
| 209 | - } | ||
| 210 | - // Avoid using Assembly.LoadFrom as referenced assemblies that exist | ||
| 211 | - // in the same path will be loaded directly from there, rather than | ||
| 212 | - // using other versions already loaded. This is a problem if there | ||
| 213 | - // is a Python.Runtime.dll in the same folder as the assembly being | ||
| 214 | - // loaded, as that will result in two instances being loaded. | ||
| 215 | - try { | ||
| 216 | - byte[] bytes = System.IO.File.ReadAllBytes(path); | ||
| 217 | - assembly = Assembly.Load(bytes); | ||
| 218 | - loadedAssemblies[path] = assembly; | ||
| 219 | - } | ||
| 205 | + try { assembly = Assembly.LoadFrom(path); } | ||
| 220 | 206 | catch {} | |
| 221 | 207 | } | |
| 222 | 208 | return assembly; | |
| 223 | 209 | } | |
| 224 | 210 | ||
| 211 | + //=================================================================== | ||
| 212 | + // Returns an assembly that's already been loaded | ||
| 213 | + //=================================================================== | ||
| 214 | + | ||
| 215 | + public static Assembly FindLoadedAssembly(string name) { | ||
| 216 | + for (int i = 0; i < assemblies.Count; i++) { | ||
| 217 | + Assembly a = (Assembly)assemblies[i]; | ||
| 218 | + if (a.GetName().Name == name) { | ||
| 219 | + return a; | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + return null; | ||
| 223 | + } | ||
| 225 | 224 | ||
| 226 | 225 | //=================================================================== | |
| 227 | 226 | // Given a qualified name of the form A.B.C.D, attempt to load | |
@@ -247,7 +246,10 @@ public static bool LoadImplicit(string name, bool warn=true) { | |||
| 247 | 246 | if (assemblies == null) { | |
| 248 | 247 | assemblies = new HashSet<Assembly>(AppDomain.CurrentDomain.GetAssemblies()); | |
| 249 | 248 | } | |
| 250 | - Assembly a = LoadAssemblyPath(s); | ||
| 249 | + Assembly a = FindLoadedAssembly(s); | ||
| 250 | + if (a == null) { | ||
| 251 | + a = LoadAssemblyPath(s); | ||
| 252 | + } | ||
| 251 | 253 | if (a == null) { | |
| 252 | 254 | a = LoadAssembly(s); | |
| 253 | 255 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -385,7 +385,11 @@ public static Assembly AddReference(string name) | |||
| 385 | 385 | { | |
| 386 | 386 | AssemblyManager.UpdatePath(); | |
| 387 | 387 | Assembly assembly = null; | |
| 388 | - assembly = AssemblyManager.LoadAssemblyPath(name); | ||
| 388 | + assembly = AssemblyManager.FindLoadedAssembly(name); | ||
| 389 | + if (assembly == null) | ||
| 390 | + { | ||
| 391 | + assembly = AssemblyManager.LoadAssemblyPath(name); | ||
| 392 | + } | ||
| 389 | 393 | if (assembly == null) | |
| 390 | 394 | { | |
| 391 | 395 | assembly = AssemblyManager.LoadAssembly(name); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments