-
Notifications
You must be signed in to change notification settings - Fork 288
/
setup.py
137 lines (116 loc) · 4.23 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
try:
from setuptools import setup
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
except ImportError:
from distutils.core import setup
import errno
import os
import subprocess
import sys
import versioneer
cmdclass = versioneer.get_cmdclass()
version = versioneer.get_version()
if sys.version_info[:2] <= (2, 6):
raise RuntimeError(
"You're using Python <= 2.6, but this package requires either Python "
"2.7, or 3.3 or above, so you can't use it unless you upgrade your "
"Python version."
)
if sys.version_info[:2] <= (3, 5):
dependencies = ["ordered-set<4.0.0"]
else:
dependencies = ["ordered-set"]
extras = {
"docs": ["sphinx", "jinja2<3.0", "MarkupSafe==2.0.1", "alabaster<0.7.12"],
"matrices": ["numpy"],
"matplotlib": ["matplotlib"],
"quantities": ["quantities", "numpy"],
"testing": ["pytest>=4.6", "coverage", "pytest-cov", "black", "isort", "xdoctest"],
"packaging": ["twine"],
}
if sys.version_info[0] == 3:
source_dir = "."
if sys.version_info < (3, 4):
del extras["docs"]
extras["matplotlib"] = ["matplotlib<2.0.0"]
extras["matrices"] = ["numpy<1.12.0"]
extras["quantities"][1] = "numpy<1.12.0"
else:
source_dir = "python2_source"
dependencies.append("future>=0.15.2")
PY2_CONVERTED = False
extras["all"] = list(set([req for reqs in extras.values() for req in reqs]))
# Automatically convert the source from Python 3 to Python 2 if we need to.
class CustomInstall(install):
def run(self):
convert_to_py2()
install.run(self)
class CustomEggInfo(egg_info):
def initialize_options(self):
convert_to_py2()
egg_info.initialize_options(self)
def convert_to_py2():
global PY2_CONVERTED
if source_dir == "python2_source" and not PY2_CONVERTED:
pylatex_exists = os.path.exists(os.path.join(source_dir, "pylatex"))
if "+" not in version and pylatex_exists:
# This is an official release, just use the pre existing existing
# python2_source dir
return
try:
# Check if 3to2 exists
subprocess.check_output(["3to2", "--help"])
subprocess.check_output(["pasteurize", "--help"])
except OSError as e:
if e.errno != errno.ENOENT:
raise
if not pylatex_exists:
raise ImportError(
"3to2 and future need to be installed "
"before installing when PyLaTeX for Python "
"2.7 when it is not installed using one of "
"the pip releases."
)
else:
converter = (
os.path.dirname(os.path.realpath(__file__)) + "/convert_to_py2.sh"
)
subprocess.check_call([converter])
PY2_CONVERTED = True
cmdclass["install"] = CustomInstall
cmdclass["egg_info"] = CustomEggInfo
setup(
name="PyLaTeX",
version=version,
author="Jelte Fennema",
author_email="[email protected]",
description="A Python library for creating LaTeX files and snippets",
long_description=open("README.rst").read(),
package_dir={"": source_dir},
packages=["pylatex", "pylatex.base_classes"],
url="https://github.com/JelteF/PyLaTeX",
license="MIT",
install_requires=dependencies,
extras_require=extras,
cmdclass=cmdclass,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Topic :: Software Development :: Code Generators",
"Topic :: Text Processing :: Markup :: LaTeX",
],
)