#305 Add a check for unversionned Python dependency
Merged 5 years ago by churchyard. Opened 5 years ago by eclipseo.
Unknown source check_python_requires  into  devel

file modified
+29
@@ -1,6 +1,7 @@

  # -*- coding: utf-8 -*-

  ''' Python package tests '''

  

+ import re

  

  from FedoraReview import CheckBase, RegistryBase

  
@@ -39,3 +40,31 @@

          br = self.spec.build_requires

          passed = 'python2-devel' in br or 'python3-devel' in br

          self.set_passed(self.PASS if passed else self.FAIL)

+ 

+ 

+ class CheckPythonRequires(PythonCheckBase):

+     """ Check that there is no unversioned Python dependencies """

+     def __init__(self, base):

+         PythonCheckBase.__init__(self, base)

+         self.url = 'https://fedoraproject.org/wiki/Packaging:Python' \

+                    '#Dependencies'

+         self.text = 'Packages MUST NOT have dependencies (either build-time ' \

+             'or runtime) on packages named with the unversioned python- ' \

+             'prefix unless no properly versioned package exists. ' \

+             'Dependencies on Python packages instead MUST use names ' \

+             'beginning with python2- or python3- as appropriate.'

+         self.automatic = True

+         self.type = 'MUST'

+ 

+     def run_on_applicable(self):

+         """ Run the check """

+         regex = re.compile('(^python-)|(-python$)|(-python-)', re.M)

+         br = self.spec.build_requires

+         rr = self.spec.get_requires()

+         

+         if regex.search('\n'.join(br)) or regex.search('\n'.join(rr)):

+             self.set_passed(self.FAIL, 'Unversionned Python dependency ' \

+                                        'found.')

+             return

+         self.set_passed(self.PASS)

+ 

Packages MUST NOT have dependencies (either build-time or runtime) on packages named with the unversioned python- prefix unless no properly versioned package exists. Dependencies on Python packages instead MUST use names beginning with python2- or python3- as appropriate.

https://fedoraproject.org/wiki/Packaging:Python#Dependencies

rebased onto 52da017

5 years ago

Pull-Request has been merged by churchyard

5 years ago
Metadata