Skip to content

Commit de2e035

Browse files
committed
refactor setup.py
1 parent a19b9f8 commit de2e035

File tree

3 files changed

+24
-144
lines changed

3 files changed

+24
-144
lines changed

.local.jenkins.lin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ install:
1515
- $PYINT -m pip freeze
1616

1717
script:
18-
- { CMD: "$PYINT -u setup.py unittests", NAME: "UT" }
18+
- { CMD: "$PYINT -u setup.py unittests --covtoken=14c7930a-a5c0-405d-a22f-3f9c6feaf0bc", NAME: "UT" }
1919

2020
after_script:
2121
- $PYINT -u setup.py bdist_wheel
2222
- if [ ${NAME} == "UT" ] then cp dist/*.whl {{root_path}}/../local_pypi/local_pypi_server fi
2323

2424
documentation:
25-
- if [ ${NAME} == "UT" ] then $PYINT -u setup.py build_sphinx fi
25+
- if [ ${NAME} == "UT" ] then $PYINT -u setup.py build_sphinx --layout=html,pdf fi
2626
- if [ ${NAME} == "UT" ] then cp -R -f _doc/sphinxdoc/build/html dist/html fi

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Pillow
1010
pycodestyle
1111
pylint
1212
pyquickhelper>=1.10
13+
pyquicksetup
1314
scikit-learn
1415
scipy
1516
sphinx

setup.py

Lines changed: 21 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from __future__ import print_function
33
import sys
44
import os
5-
from setuptools import setup, Extension
6-
from setuptools import find_packages
5+
from setuptools import setup, Extension, find_packages
6+
from pyquicksetup import read_version, read_readme, default_cmdclass
77

88
#########
99
# settings
@@ -36,144 +36,23 @@
3636
package_dir = {k: os.path.join(here, k.replace(".", "/")) for k in packages}
3737
package_data = {}
3838

39-
############
40-
# functions
41-
############
4239

43-
44-
def ask_help():
45-
return "--help" in sys.argv or "--help-commands" in sys.argv
46-
47-
48-
def is_local():
49-
file = os.path.abspath(__file__).replace("\\", "/").lower()
50-
if "/temp/" in file and "pip-" in file:
51-
return False
52-
from pyquickhelper.pycode.setup_helper import available_commands_list
53-
return available_commands_list(sys.argv)
54-
55-
56-
def verbose():
57-
print("---------------------------------")
58-
print("package_dir =", package_dir)
59-
print("packages =", packages)
60-
print("package_data=", package_data)
61-
print("current =", os.path.abspath(os.getcwd()))
62-
print("---------------------------------")
63-
64-
##########
65-
# version
66-
##########
67-
68-
69-
if is_local() and not ask_help():
70-
def write_version():
71-
from pyquickhelper.pycode import write_version_for_setup
72-
return write_version_for_setup(__file__)
73-
74-
write_version()
75-
76-
versiontxt = os.path.join(os.path.dirname(__file__), "version.txt")
77-
if os.path.exists(versiontxt):
78-
with open(versiontxt, "r") as f:
79-
lines = f.readlines()
80-
subversion = "." + lines[0].strip("\r\n ")
81-
if subversion == ".0":
82-
raise Exception("Git version is wrong: '{0}'.".format(subversion))
83-
else:
84-
raise FileNotFoundError(versiontxt)
85-
else:
86-
# when the module is installed, no commit number is displayed
87-
subversion = ""
88-
89-
if "upload" in sys.argv and not subversion and not ask_help():
90-
# avoid uploading with a wrong subversion number
91-
raise Exception(
92-
"Git version is empty, cannot upload, is_local()={0}".format(is_local()))
93-
94-
##############
95-
# common part
96-
##############
97-
98-
if os.path.exists(readme):
99-
with open(readme, "r", encoding='utf-8-sig') as f:
100-
long_description = f.read()
101-
else:
102-
long_description = ""
103-
if os.path.exists(history):
104-
with open(history, "r", encoding='utf-8-sig') as f:
105-
long_description += f.read()
106-
107-
if "--verbose" in sys.argv:
108-
verbose()
109-
110-
if is_local():
111-
import pyquickhelper
112-
logging_function = pyquickhelper.get_fLOG()
113-
logging_function(OutputPrint=True)
114-
must_build, run_build_ext = pyquickhelper.get_insetup_functions()
115-
116-
if must_build():
117-
out = run_build_ext(__file__)
118-
print(out)
119-
120-
if "build_sphinx" in sys.argv and not sys.platform.startswith("win"):
121-
# There is an issue with matplotlib and notebook gallery on linux
122-
# _tkinter.TclError: no display name and no $DISPLAY environment variable
123-
import matplotlib
124-
matplotlib.use('agg')
125-
126-
from pyquickhelper.pycode import process_standard_options_for_setup
127-
r = process_standard_options_for_setup(
128-
sys.argv, __file__, project_var_name,
129-
unittest_modules=["pyquickhelper"],
130-
additional_notebook_path=["pyquickhelper", "jyquickhelper"],
131-
additional_local_path=["pyquickhelper", "jyquickhelper"],
132-
requirements=["pyquickhelper", "jyquickhelper"],
133-
layout=["html"], github_owner='sdpython',
134-
add_htmlhelp=sys.platform.startswith("win"),
135-
coverage_options=dict(omit=["*exclude*.py"]),
136-
fLOG=logging_function, covtoken=("14c7930a-a5c0-405d-a22f-3f9c6feaf0bc", "'_UT_39_std' in outfile"))
137-
if not r and not ({"bdist_msi", "sdist",
138-
"bdist_wheel", "publish", "publish_doc", "register",
139-
"upload_docs", "bdist_wininst", "build_ext"} & set(sys.argv)):
140-
raise Exception("unable to interpret command line: " + str(sys.argv))
141-
else:
142-
r = False
143-
144-
if ask_help():
145-
from pyquickhelper.pycode import process_standard_options_for_setup_help
146-
process_standard_options_for_setup_help(sys.argv)
147-
148-
if not r:
149-
if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
150-
from pyquickhelper.pycode import process_standard_options_for_setup_help
151-
process_standard_options_for_setup_help(sys.argv)
152-
root = os.path.abspath(os.path.dirname(__file__))
153-
if sys.platform.startswith("win"):
154-
extra_compile_args = None
155-
else:
156-
extra_compile_args = ['-std=c++11']
157-
158-
from pyquickhelper.pycode import clean_readme
159-
from pandas_streaming import __version__ as sversion
160-
long_description = clean_readme(long_description)
161-
162-
setup(
163-
name=project_var_name,
164-
version=sversion,
165-
author='Xavier Dupré',
166-
author_email='xavier.dupre@gmail.com',
167-
license="MIT",
168-
url="http://www.xavierdupre.fr/app/pandas_streaming/helpsphinx/index.html",
169-
download_url="https://github.com/sdpython/pandas_streaming/",
170-
description=DESCRIPTION,
171-
long_description=long_description,
172-
keywords=KEYWORDS,
173-
classifiers=CLASSIFIERS,
174-
packages=packages,
175-
package_dir=package_dir,
176-
package_data=package_data,
177-
setup_requires=["pyquickhelper>=1.10"],
178-
install_requires=['numpy', 'pandas', 'ijson'],
179-
)
40+
setup(
41+
name=project_var_name,
42+
version=read_version(__file__, project_var_name),
43+
author='Xavier Dupré',
44+
author_email='xavier.dupre@gmail.com',
45+
license="MIT",
46+
url="http://www.xavierdupre.fr/app/pandas_streaming/helpsphinx/index.html",
47+
download_url="https://github.com/sdpython/pandas_streaming/",
48+
description=DESCRIPTION,
49+
long_description=read_readme(__file__),
50+
cmdclass=default_cmdclass(),
51+
keywords=KEYWORDS,
52+
classifiers=CLASSIFIERS,
53+
packages=packages,
54+
package_dir=package_dir,
55+
package_data=package_data,
56+
setup_requires=["pyquicksetup"],
57+
install_requires=['numpy', 'pandas', 'ijson'],
58+
)

0 commit comments

Comments
 (0)