[csw-devel] SF.net SVN: gar:[21575] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Jul 29 23:35:14 CEST 2013


Revision: 21575
          http://gar.svn.sourceforge.net/gar/?rev=21575&view=rev
Author:   wahwah
Date:     2013-07-29 21:35:14 +0000 (Mon, 29 Jul 2013)
Log Message:
-----------
checkpkg: protecting us from breaking Python 2.6

If we build a CSWpy- package, it must contain files that are reachable by our
Python 2.6 interpreter.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2013-07-29 21:34:58 UTC (rev 21574)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2013-07-29 21:35:14 UTC (rev 21575)
@@ -814,9 +814,9 @@
             '%s %s' % (file_path, " ".join(pkgnames)))
 
 
-def CheckPythonPackageName(pkg_data, error_mgr, logger, messenger):
-  """Checks for CSWpy-* and py_* package names."""
-  pyfile_re = re.compile(r"/opt/csw/lib/python.*/.*")
+def CheckPython2PackageName(pkg_data, error_mgr, logger, messenger):
+  """Packages providing Python modules are named CSWpy-* and py_*."""
+  pyfile_re = re.compile(r"/opt/csw/lib/python(2\.6|2\.7)?/.*")
   pkgname = pkg_data["basic_stats"]["pkgname"]
   has_py_files = False
   example_py_file = ""
@@ -829,11 +829,13 @@
       break
   if has_py_files and not pkgname.startswith("CSWpy-"):
     error_mgr.ReportError("pkgname-does-not-start-with-CSWpy-")
-    messenger.Message("The package "
-                      "installs files into /opt/csw/lib/python. For example, %s. "
-                      "However, the pkgname doesn't start with 'CSWpy-'."
-                      % repr(example_py_file))
-  if has_py_files and not pkg_data["basic_stats"]["catalogname"].startswith("py_"):
+    messenger.Message(
+        "The package "
+        "installs files into /opt/csw/lib/python. For example, %s. "
+        "However, the pkgname doesn't start with 'CSWpy-'."
+        % repr(example_py_file))
+  catalogname = pkg_data["basic_stats"]["catalogname"]
+  if has_py_files and not catalogname.startswith("py_"):
     error_mgr.ReportError("catalogname-does-not-start-with-py_")
     messenger.Message("The package installs files into /opt/csw/lib/python. "
         "For example, %s. "
@@ -841,6 +843,30 @@
         % repr(example_py_file))
 
 
+def CheckPackageDoesNotBreakPython26(pkg_data, error_mgr, logger, messenger):
+  """Packages named CSWpy- must provide files for Python 2.6."""
+  py26_file_re = re.compile(r"/opt/csw/lib/python(2\.6)?/.*")
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  has_py_prefix = pkgname.startswith("CSWpy-")
+  if not has_py_prefix:
+    # It's not a Python 2.x module. Nothing to see here.
+    return
+  spotted_a_py26_file = False
+  example_py_file = ""
+  for pkgmap_entry in pkg_data["pkgmap"]:
+    if not pkgmap_entry["path"]:
+      continue
+    if py26_file_re.match(pkgmap_entry["path"]):
+      spotted_a_py26_file = True
+      example_py_file = pkgmap_entry["path"]
+      break
+  if not spotted_a_py26_file:
+    error_mgr.ReportError("python-package-missing-py26-files")
+    messenger.Message(
+        "The package has the CSWpy- prefix but "
+        "does not contain any files for Python 2.6. ")
+
+
 def CheckArchitecture(pkg_data, error_mgr, logger, messenger):
   pkgname = pkg_data["basic_stats"]["pkgname"]
   for metadata in pkg_data["files_metadata"]:

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2013-07-29 21:34:58 UTC (rev 21574)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2013-07-29 21:35:14 UTC (rev 21575)
@@ -861,30 +861,25 @@
     self.pkg_data["pkginfo"]["VENDOR"] = "https://www.example.com/"
 
 
-class TestCheckPythonPackageName(CheckTestHelper, unittest.TestCase):
-  FUNCTION_NAME = "CheckPythonPackageName"
+class TestCheckPackageDoesNotBreakPython26(CheckTestHelper, unittest.TestCase):
+  FUNCTION_NAME = "CheckPackageDoesNotBreakPython26"
   def testBad(self):
     self.pkg_data["pkgmap"].append({
-      "class": "none",
-      "group": "bin",
-      "line": "",
-      "mode": '0755',
-      "path": "/opt/csw/lib/python/site-packages/hachoir_parser/video/mov.py",
-      "type": "f",
-      "user": "root"
+      "class": "none", "group": "bin", "line": "", "mode": '0755',
+      "type": "f", "user": "root",
+      "path": "/opt/csw/lib/python2.7/site-packages/"
+              "hachoir_parser/video/mov.py",
+      # No file in /opt/csw/lib/python/site-packages
     })
-    self.error_mgr_mock.ReportError('pkgname-does-not-start-with-CSWpy-')
-    self.error_mgr_mock.ReportError('catalogname-does-not-start-with-py_')
+    self.pkg_data["basic_stats"]["catalogname"] = "py_foo"
+    self.pkg_data["basic_stats"]["pkgname"] = "CSWpy-foo"
+    self.error_mgr_mock.ReportError('python-package-missing-py26-files')
 
   def testGood(self):
     self.pkg_data["pkgmap"].append({
-      "class": "none",
-      "group": "bin",
-      "line": "",
-      "mode": '0755',
+      "class": "none", "group": "bin", "line": "", "mode": '0755',
+      "type": "f", "user": "root",
       "path": "/opt/csw/lib/python/site-packages/hachoir_parser/video/mov.py",
-      "type": "f",
-      "user": "root"
     })
     self.pkg_data["basic_stats"]["catalogname"] = "py_foo"
     self.pkg_data["basic_stats"]["pkgname"] = "CSWpy-foo"

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list