[packages/python-astroid] Add support for loading modules with no sources

jajcus jajcus at pld-linux.org
Thu Jun 11 14:15:37 CEST 2015


commit 60fa4681ca6aaa3f053f66bbf11f0515b4e5b180
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date:   Thu Jun 11 14:14:57 2015 +0200

    Add support for loading modules with no sources
    
    workaround for the stupid 'no python sources' policy in PLD

 modules_without_sources.patch | 35 +++++++++++++++++++++++++++++++++++
 python-astroid.spec           |  5 ++++-
 2 files changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/python-astroid.spec b/python-astroid.spec
index 06083ad..3c3280a 100644
--- a/python-astroid.spec
+++ b/python-astroid.spec
@@ -8,11 +8,12 @@ Summary:	Rebuild a new abstract syntax tree from Python's AST
 Summary(pl.UTF-8):	Tworzenie nowego abstrakcyjnego drzewa składniowego z pythonowego AST
 Name:		python-%{module}
 Version:	1.3.6
-Release:	1
+Release:	2
 License:	LGPL v2.1+
 Group:		Development/Languages/Python
 Source0:	https://pypi.python.org/packages/source/a/astroid/astroid-%{version}.tar.gz
 # Source0-md5:	0d387f5b2e878f424b95af3bfe44e106
+Patch0:		modules_without_sources.patch
 URL:		http://www.astroid.org/
 %if %{with python2}
 BuildRequires:	python-devel >= 1:2.7
@@ -70,6 +71,8 @@ potrzebami pylinta. Dawniej nazywała się logilab-astng.
 
 %prep
 %setup -q -n %{module}-%{version}
+
+%patch0 -p1
 # drop python 2.5 egg deps
 %{__rm} */*/*/*/*/*py2.5.egg
 
diff --git a/modules_without_sources.patch b/modules_without_sources.patch
new file mode 100644
index 0000000..c381556
--- /dev/null
+++ b/modules_without_sources.patch
@@ -0,0 +1,35 @@
+diff -dur astroid-1.3.6.orig/astroid/manager.py astroid-1.3.6/astroid/manager.py
+--- astroid-1.3.6.orig/astroid/manager.py	2015-03-14 15:04:09.000000000 +0100
++++ astroid-1.3.6/astroid/manager.py	2015-06-11 13:57:16.000000000 +0200
+@@ -144,7 +144,7 @@
+                 module = self.zip_import_data(filepath)
+                 if module is not None:
+                     return module
+-            elif mp_type in (imp.C_BUILTIN, imp.C_EXTENSION):
++            elif mp_type in (imp.C_BUILTIN, imp.C_EXTENSION, imp.PY_COMPILED):
+                 if mp_type == imp.C_EXTENSION and not self._can_load_extension(modname):
+                     return self._build_stub_module(modname)
+                 try:
+@@ -153,8 +153,6 @@
+                     msg = 'Unable to load module %s (%s)' % (modname, ex)
+                     raise AstroidBuildingException(msg)
+                 return self.ast_from_module(module, modname)
+-            elif mp_type == imp.PY_COMPILED:
+-                raise AstroidBuildingException("Unable to load compiled module %s" % (modname,))
+             if filepath is None:
+                 raise AstroidBuildingException("Unable to load module %s" % (modname,))
+             return self.ast_from_file(filepath, modname, fallback=False)
+diff -dur astroid-1.3.6.orig/astroid/modutils.py astroid-1.3.6/astroid/modutils.py
+--- astroid-1.3.6.orig/astroid/modutils.py	2015-03-09 23:00:27.000000000 +0100
++++ astroid-1.3.6/astroid/modutils.py	2015-06-11 13:57:49.000000000 +0200
+@@ -534,6 +534,10 @@
+         return None, imp.C_BUILTIN
+     elif mtype == imp.PKG_DIRECTORY:
+         mp_filename = _has_init(mp_filename)
++        try:
++            return get_source_file(mp_filename), imp.PY_SOURCE
++        except NoSourceFile:
++            return mp_filename, imp.PY_COMPILED
+         mtype = imp.PY_SOURCE
+     return mp_filename, mtype
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-astroid.git/commitdiff/60fa4681ca6aaa3f053f66bbf11f0515b4e5b180



More information about the pld-cvs-commit mailing list