From 185a36c9886db85b0a5e18b8ca60fa67d3f6a2be 2012-06-30 20:41:30 From: MinRK Date: 2012-06-30 20:41:30 Subject: [PATCH] enable uploading wininst to PyPI with tools/release_windows.py adds upload_wininst command to setup.py --- diff --git a/setup.py b/setup.py index 4e656ae..d009aaf 100755 --- a/setup.py +++ b/setup.py @@ -52,6 +52,7 @@ from glob import glob if os.path.exists('MANIFEST'): os.remove('MANIFEST') from distutils.core import setup +from distutils.command.upload import upload # On Python 3, we need distribute (new setuptools) to do the 2to3 conversion if PY3: @@ -171,6 +172,31 @@ setup_args['package_data'] = package_data setup_args['data_files'] = data_files #--------------------------------------------------------------------------- +# custom upload_wininst command +#--------------------------------------------------------------------------- + +class UploadWindowsInstallers(upload): + + description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" + user_options = upload.user_options + [ + ('files=', 'f', 'exe file (or glob) to upload') + ] + def initialize_options(self): + upload.initialize_options(self) + meta = self.distribution.metadata + base = '{name}-{version}'.format( + name=meta.get_name(), + version=meta.get_version() + ) + self.files = os.path.join('dist', '%s.*.exe' % base) + + def run(self): + for dist_file in glob(self.files): + self.upload_file('bdist_wininst', 'any', dist_file) + +setup_args['cmdclass']['upload_wininst'] = UploadWindowsInstallers + +#--------------------------------------------------------------------------- # Handle scripts, dependencies, and setuptools specific things #--------------------------------------------------------------------------- diff --git a/tools/release_windows.py b/tools/release_windows.py index e1fe605..2a50e22 100644 --- a/tools/release_windows.py +++ b/tools/release_windows.py @@ -25,9 +25,8 @@ github = '--github' in sys.argv cmd_t = "{py} setup.py bdist_wininst --plat-name={plat}" -if '--pypi' in sys.argv: - raise NotImplementedError("pypi upload doesn't work yet") - cmd_t += ' upload' +pypi = '--pypi' in sys.argv +pypi_cmd_t = "python setup.py upload_wininst -f {fname}" for py in ['python', 'python3']: # deliberately mangle the name, @@ -45,6 +44,8 @@ for py in ['python', 'python3']: '.py{v}-{plat}.exe'.format(**locals()) ) os.rename(orig, mangled) + if pypi: + sh(pypi_cmd_t.format(fname=mangled)) if github and gh_api: print ("Uploading %s to GitHub" % mangled) desc = "IPython Installer for Python {v}.x on {plat}".format(**locals())