Skip to content

Commit

Permalink
installed certs in dev mode too
Browse files Browse the repository at this point in the history
  • Loading branch information
Kareem Zidane committed Jun 14, 2017
1 parent 898c7dc commit a69759b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
Expand All @@ -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"]
},
Expand Down

0 comments on commit a69759b

Please sign in to comment.