forked from sdpython/ensae_teaching_cs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
201 lines (172 loc) · 7.78 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#-*- coding: utf-8 -*-
# Copyright (C) 2014 ---------------
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. All advertising materials mentioning features or use of this
# software must display the following acknowledgment:
# "This product includes software developed by
# Xavier Dupré <xavier.dupre AT gmail.com>"
#
# 4. Redistributions of any form whatsoever must retain the following
# acknowledgment:
# "This product includes software developed by
# Xavier Dupré <xavier.dupre AT gmail.com>."
#
# THIS SOFTWARE IS PROVIDED BY Xavier Dupré ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Roman V. Kiseliov OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
import sys,os
from distutils.core import setup
from setuptools import find_packages
if os.path.exists("version.txt") :
with open("version.txt", "r") as f : lines = f.readlines()
subversion = lines[0].strip("\r\n ")
else :
subversion = 1
project_var_name = "ensae_teaching_cs"
sversion = "0.5"
versionPython = "%s.%s" % (sys.version_info.major, sys.version_info.minor)
path = "Lib/site-packages/" + project_var_name
readme = 'README.rst'
KEYWORDS = \
project_var_name + ', ENSAE, sqllite, database, teachings'
DESCRIPTION = \
"""Module which contains materials for teaching puroposes, also includes pythonnet."""
CLASSIFIERS = \
[
'Programming Language :: Python :: 3',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering',
'Topic :: Education',
'License :: OSI Approved :: BSD License',
'Development Status :: 5 - Production/Stable'
]
if "bdist_wininst" not in sys.argv :
EXT_MODULES = [
#Extension(project_var_name + '.subproject.sample_module',
# ['src/' + project_var_name + '/subproject/sample_module.cpp'],
# include_dirs = ['src/' + project_var_name + '/subproject']),
]
else :
EXT_MODULES = [ ]
packages = find_packages('src', exclude='src')
package_dir = { k: "src/" + k.replace(".","/") for k in packages }
package_data = { project_var_name + ".pythonnet.py33" : ["*.pyd","*.txt","*.dll"],
project_var_name + ".pythonnet.py33x64": ["*.pyd","*.txt","*.dll"],
project_var_name + ".pythonnet.py34" : ["*.pyd","*.txt","*.dll"],
project_var_name + ".pythonnet.py34x64": ["*.pyd","*.txt","*.dll"],
project_var_name + ".pythonnet.csdll": ["*.dll"],
}
with open(readme) as f : long_description = f.read()
if "--verbose" in sys.argv :
print ("---------------------------------")
print ("package_dir =",package_dir)
print ("packages =",packages)
print ("package_data=",package_data)
print ("current =", os.path.abspath(os.getcwd()))
print ("---------------------------------")
if "build_sphinx" in sys.argv:
# we take a shortcut
try:
import pyquickhelper
except ImportError:
sys.path.append ( os.path.normpath (os.path.abspath(os.path.join("..", "pyquickhelper", "src" ))))
try:
import pyquickhelper
except ImportError as e :
raise ImportError("module pyquickhelper is needed to build the documentation") from e
if "--help" in sys.argv:
print(pyquickhelper.get_help_usage())
else :
if not os.path.exists("_doc/sphinxdoc/source"):
raise FileNotFoundError("you must get the source from GitHub to build the documentation")
from pyquickhelper import fLOG, generate_help_sphinx
fLOG (OutputPrint = True)
project_name = os.path.split(os.path.split(os.path.abspath(__file__))[0])[-1]
generate_help_sphinx(project_name,
nbformats=['ipynb', 'html', 'python', 'rst', 'docx','pdf'],
layout = [ "pdf",
"html",
("html", "build2", {"html_theme":"basicstrap"}, "source/conf2"),
("html", "build3", {"html_theme":"solar_theme"}, "source/conf3"),
] )
elif "build_pres" in sys.argv:
# we generate the documentation for the presentation
def get_executables_path() :
"""
returns the paths to Python, Python Scripts
@return a list of paths
"""
res = [ os.path.split(sys.executable)[0] ]
res += [ os.path.join(res[-1], "Scripts") ]
if sys.platform.startswith("win") :
ver = "c:\\Python%d%d" % (sys.version_info.major, sys.version_info.minor)
res += [ver ]
res += [ os.path.join(res[-1], "Scripts") ]
return res
# run the documentation generation
if sys.platform.startswith("win"):
temp = os.environ ["PATH"]
pyts = get_executables_path()
script = ";".join(pyts)
temp = script + ";" + temp
os.environ["PATH"] = temp
pa = os.getcwd ()
thispath = os.path.normpath(os.path.split(__file__)[0])
docpath = os.path.normpath(os.path.join(thispath, "_doc","presentation"))
os.chdir (docpath)
lay = "html"
build = "build"
over = ""
sconf = ""
cmd = "sphinx-build -b {1} -d {0}/doctrees{2}{3} source {0}/{1}".format(build, lay, over, sconf)
os.system(cmd)
if sys.platform.startswith("win"):
os.chdir (pa)
elif "unittests" in sys.argv:
if not os.path.exists("_unittests"):
raise FileNotFoundError("you must get the source from GitHub to run the unittests")
sys.path.append("_unittests")
from run_unittests import main
main()
else :
setup(
name = project_var_name,
version = '%s.%s' %(sversion, subversion) if "register" in sys.argv or "bdist_msi" in sys.argv else 'py%s-v%s.%s' % (versionPython, sversion, subversion),
author = 'Xavier Dupré',
author_email = 'xavier.dupre AT gmail.com',
url = "http://www.xavierdupre.fr/app/ensae_teaching_cs/helpsphinx/index.html",
download_url = "https://github.com/sdpython/ensae_teaching_cs/",
description = DESCRIPTION,
long_description = long_description,
keywords = KEYWORDS,
classifiers = CLASSIFIERS,
packages = packages,
package_dir = package_dir,
package_data = package_data,
#data_files = data_files,
install_requires = [ "pyensae" ],
ext_modules = EXT_MODULES,
#include_package_data = True,
)