-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kareem Zidane
committed
Jun 14, 2017
1 parent
898c7dc
commit a69759b
Showing
1 changed file
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]", | ||
|
@@ -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"] | ||
}, | ||
|