From a69759bcadae336733a4db24a8b073f32d95e7e8 Mon Sep 17 00:00:00 2001 From: Kareem Zidane Date: Thu, 15 Jun 2017 01:40:36 +0200 Subject: [PATCH] installed certs in dev mode too --- setup.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 1b1910e..46ae8aa 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,37 @@ from os.path import isfile from setuptools import setup +from setuptools.command.develop import develop from setuptools.command.install import install from subprocess import call from sys import platform, version_info -class Certs(install): +def install_certs(cmd): + """Decorator for classes subclassing one of setuptools commands. + + Installs certificates before installing the package when running + Python>=3.6 on Mac OS. + """ + orig_run = cmd.run; + def run(self): - install.run(self) if platform == "darwin" and version_info >= (3, 6): INSTALL_CERTS = "/Applications/Python 3.6/Install Certificates.command" if not isfile(INSTALL_CERTS) or call(INSTALL_CERTS) != 0: raise Error("Error installing certificates.") + orig_run(self) + + cmd.run = run + return cmd + +@install_certs +class CustomDevelop(develop): + pass + +@install_certs +class CustomInstall(install): + pass + setup( author="CS50", author_email="sysadmins@cs50.harvard.edu", @@ -26,7 +46,10 @@ def run(self): keywords=["submit", "submit50"], name="submit50", py_modules=["submit50"], - cmdclass={"install": Certs}, + cmdclass={ + "develop": CustomDevelop, + "install": CustomInstall + }, entry_points={ "console_scripts": ["submit50=submit50:main"] },