forked from cs50/submit50
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
83 lines (70 loc) · 2.34 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from glob import glob
from os import walk
from os.path import isfile, join, splitext
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
def create_mo_files():
"""Compiles .po files in local/LANG to .mo files and returns them as array of data_files"""
mo_files=[]
for prefix in glob("locale/*"):
for _,_,files in walk(prefix):
for file in files:
if file.endswith(".po"):
po_file = join(prefix, file)
mo_file = splitext(po_file)[0] + ".mo"
call(["msgfmt", "-o", mo_file, po_file])
mo_files.append((join("submit50", prefix, "LC_MESSAGES"), [mo_file]))
return mo_files
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):
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 RuntimeError("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]",
classifiers=[
"Intended Audience :: Education",
"Programming Language :: Python :: 3",
"Topic :: Education",
"Topic :: Utilities"
],
description="This is submit50, with which you can submit solutions to \
problems for CS50.",
install_requires=[
"backports.shutil_get_terminal_size", "backports.shutil_which",
"pexpect>=4.0", "requests", "six", "termcolor"
],
keywords=["submit", "submit50"],
name="submit50",
py_modules=["submit50"],
cmdclass={
"develop": CustomDevelop,
"install": CustomInstall
},
entry_points={
"console_scripts": ["submit50=submit50:main"]
},
data_files=create_mo_files(),
url="https://github.com/cs50/submit50",
version="2.4.5"
)