[narval] make lgp and pypi use the same tarball draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 20 Nov 2014 16:14:11 +0100
changeset 1780 d47dfaf9f065
parent 1779 52df5eea680c
child 1781 37db6358b486
[narval] make lgp and pypi use the same tarball
_narval/checkers/apycot/lgp.py
_narval/checkers/apycot/pypi.py
--- a/_narval/checkers/apycot/lgp.py	Thu Nov 20 23:14:28 2014 +0100
+++ b/_narval/checkers/apycot/lgp.py	Thu Nov 20 16:14:11 2014 +0100
@@ -82,6 +82,9 @@
         'lgp_suffix': {
             'help': ('append vcs revision to the package version'),
         },
+        'lgp_tarball': {
+            'help': ('use given tarball to build debian package; if unset, generate it using setup.py sdist'),
+        },
     }
 
     def display_logs(self, build_folder):
@@ -96,17 +99,20 @@
         dist = self.options.get('lgp_build_distrib') or ['all']
         sign = self.options.get('lgp_sign')
         suffix = self.options.get('lgp_suffix')
+        tarball = self.options.get('lgp_tarball')
         build_folder = os.path.join(test.project_path(), '..')
         cwd = os.getcwd()
         os.chdir(test.project_path())
-        repo = test.apycot_repository()
         try:
             handler = LgpLogHandler(self.writer)
             cmd = LGP.get_command(self.command)
             cmd.logger.addHandler(handler)
             args = ['-v', '-s', sign, '-d', ','.join(dist), '-r', build_folder ]
             if suffix:
+                repo = test.apycot_repository()
                 args += ['--suffix', '~rev%s' % repo.revision()]
+            if tarball:
+                args += ['--orig-tarball', os.path.abspath(tarball)]
             exit_status = cmd.main_run(args, LGP.rcfile)
             self.debian_changes = [f for f in cmd.packages if f.endswith('.changes')]
             if exit_status:
--- a/_narval/checkers/apycot/pypi.py	Thu Nov 20 23:14:28 2014 +0100
+++ b/_narval/checkers/apycot/pypi.py	Thu Nov 20 16:14:11 2014 +0100
@@ -7,14 +7,20 @@
 
 from checkers.apycot import BaseChecker
 
-class PypiUploader(BaseChecker):
-    id = 'pypi.upload'
+class DistutilsBuilder(BaseChecker):
+    id = 'distutils.build'
 
     options_def = {
         'verbose': {
             'type': 'int', 'default': False,
             'help': 'set verbose mode'
             },
+        'pypi_repository': {
+            'help': ('pypi repository to upload to (URL); make sure this '
+                     'repositoy is listed in the .pypirc file; is unset, '
+                     'package will NOT be uploaded'),
+            'default': '',
+            },
         }
 
     def do_check(self, test):
@@ -27,7 +33,14 @@
         if not exists(join(path, 'setup.py')):
             raise apycotlib.SetupException('No file %s' % abspath(join(path, 'setup.py')))
         python = apycotlib.pyversions(test)[0]
-        cmdargs = [python, 'setup.py', 'register', 'sdist', 'upload']
+        if self.options.get('pypi_repository'):
+            repo = str(self.options.get('pypi_repository'))
+            cmdargs = [python, 'setup.py', # wonderful setuptools
+                       'register', '--repository', repo,
+                       'sdist',
+                       'upload', '--repository', repo]
+        else:
+            cmdargs = [python, 'setup.py', 'sdist']
         if not self.options.get('verbose'):
             cmdargs.append('--quiet')
         cmd = apycotlib.Command(self.writer, cmdargs, raises=True, cwd=path)
@@ -36,4 +49,4 @@
             self.writer.info('uploaded tarball to pypi')
         return cmdstatus
 
-apycotlib.register('checker', PypiUploader)
+apycotlib.register('checker', DistutilsBuilder)