Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
refactor setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Apr 12, 2021
1 parent 4e5f468 commit fed0667
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 147 deletions.
7 changes: 5 additions & 2 deletions .local.jenkins.lin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ install:
- $PYINT --version
- $PYINT -m pip freeze

before_script:
- $PYINT -u setup.py write_version

script:
- { CMD: "$PYINT -u setup.py unittests", NAME: "UT", TIMEOUT: 3600 }
- { CMD: "$PYINT -u setup.py unittests --covtoken=7e43a842-880e-44b6-aaf5-66173a5061fa", NAME: "UT", TIMEOUT: 3600 }

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

documentation:
- if [ ${NAME} == "UT" ] then $PYINT -u setup.py build_sphinx fi
- if [ ${NAME} == "UT" ] then $PYINT -u setup.py build_sphinx --layout=html fi
- if [ ${NAME} == "UT" ] then cp -R -f _doc/sphinxdoc/build/html dist/html fi
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pyensae
pylint>=2.4.2
pymyinstall
pyquickhelper>=1.10.3519
pyquicksetup
pyspark
qgrid
sphinxcontrib.imagesvg
Expand Down
167 changes: 22 additions & 145 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import sys
import os
from setuptools import setup, Extension
from setuptools import find_packages
from setuptools import setup, Extension, find_packages
from pyquicksetup import read_version, read_readme, default_cmdclass


#########
# settings
Expand Down Expand Up @@ -34,146 +35,22 @@
package_dir = {k: "src/" + k.replace(".", "/") for k in packages}
package_data = {}

############
# functions
############


def ask_help():
return "--help" in sys.argv or "--help-commands" in sys.argv


def is_local():
file = os.path.abspath(__file__).replace("\\", "/").lower()
if "/temp/" in file and "pip-" in file:
return False
from pyquickhelper.pycode.setup_helper import available_commands_list
return available_commands_list(sys.argv)


def verbose():
print("---------------------------------")
print("package_dir =", package_dir)
print("packages =", packages)
print("package_data=", package_data)
print("current =", os.path.abspath(os.getcwd()))
print("---------------------------------")

##########
# version
##########


if is_local() and not ask_help():
def write_version():
from pyquickhelper.pycode import write_version_for_setup
return write_version_for_setup(__file__)

write_version()

versiontxt = os.path.join(os.path.dirname(__file__), "version.txt")
if os.path.exists(versiontxt):
with open(versiontxt, "r") as f:
lines = f.readlines()
subversion = "." + lines[0].strip("\r\n ")
if subversion == ".0":
raise Exception("Git version is wrong: '{0}'.".format(subversion))
else:
raise FileNotFoundError(
"Unable to find '{0}' argv={1}".format(versiontxt, sys.argv))
else:
# when the module is installed, no commit number is displayed
subversion = ""

if "upload" in sys.argv and not subversion and not ask_help():
# avoid uploading with a wrong subversion number
raise Exception(
"Git version is empty, cannot upload, is_local()={0}".format(is_local()))

##############
# common part
##############

if os.path.exists(readme):
with open(readme, "r", encoding='utf-8-sig') as f:
long_description = f.read()
else:
long_description = ""
if os.path.exists(history):
with open(history, "r", encoding='utf-8-sig') as f:
long_description += f.read()

if "--verbose" in sys.argv:
verbose()

if is_local():
import pyquickhelper
logging_function = pyquickhelper.get_fLOG()
logging_function(OutputPrint=True)
must_build, run_build_ext = pyquickhelper.get_insetup_functions()

if must_build():
out = run_build_ext(__file__)
print(out)

if "build_sphinx" in sys.argv and not sys.platform.startswith("win"):
# There is an issue with matplotlib and notebook gallery on linux
# _tkinter.TclError: no display name and no $DISPLAY environment variable
import matplotlib
matplotlib.use('agg')

from pyquickhelper.pycode import process_standard_options_for_setup
r = process_standard_options_for_setup(
sys.argv, __file__, project_var_name,
unittest_modules=["pyquickhelper", "pyensae", "pyenbc"],
additional_notebook_path=[
"pyquickhelper", "jyquickhelper", "pyensae", "pyenbc", 'pymyinstall'],
additional_local_path=[
"pyquickhelper", "jyquickhelper", "pyensae", "pyenbc", 'pymyinstall'],
requirements=["pyquickhelper", "jyquickhelper",
"pyensae", "pyenbc", 'pymyinstall'],
layout=["html"], github_owner="sdpython",
add_htmlhelp=sys.platform.startswith("win"),
coverage_options=dict(omit=["*exclude*.py"]),
fLOG=logging_function, covtoken=("7e43a842-880e-44b6-aaf5-66173a5061fa", "'_UT_39_std' in outfile"))
if not r and not ({"bdist_msi", "sdist",
"bdist_wheel", "publish", "publish_doc", "register",
"upload_docs", "bdist_wininst", "build_ext"} & set(sys.argv)):
raise Exception("unable to interpret command line: " + str(sys.argv))
else:
r = False

if ask_help():
from pyquickhelper.pycode import process_standard_options_for_setup_help
process_standard_options_for_setup_help(sys.argv)

if not r:
if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
from pyquickhelper.pycode import process_standard_options_for_setup_help
process_standard_options_for_setup_help(sys.argv)
from pyquickhelper.pycode import clean_readme
from sparkouille import __version__ as sversion
long_description = clean_readme(long_description)
root = os.path.abspath(os.path.dirname(__file__))
if sys.platform.startswith("win"):
extra_compile_args = None
else:
extra_compile_args = ['-std=c++11']
setup(
name=project_var_name,
version=sversion,
author='Xavier Dupré',
author_email='xavier.dupre@gmail.com',
license="MIT",
url="http://www.xavierdupre.fr/app/%s/helpsphinx/index.html" % project_var_name,
download_url="https://github.com/sdpython/%s/" % project_var_name,
description=DESCRIPTION,
long_description=long_description,
keywords=KEYWORDS,
classifiers=CLASSIFIERS,
packages=packages,
package_dir=package_dir,
package_data=package_data,
setup_requires=["pyquickhelper"],
install_requires=['pyspark'],
)
setup(
name=project_var_name,
version=read_version(__file__, project_var_name, subfolder='src'),
author='Xavier Dupré',
author_email='xavier.dupre@gmail.com',
license="MIT",
url="http://www.xavierdupre.fr/app/%s/helpsphinx/index.html" % project_var_name,
download_url="https://github.com/sdpython/%s/" % project_var_name,
description=DESCRIPTION,
long_description=read_readme(__file__),
cmdclass=default_cmdclass(),
keywords=KEYWORDS,
classifiers=CLASSIFIERS,
packages=packages,
package_dir=package_dir,
package_data=package_data,
setup_requires=["pyquicksetup"],
install_requires=['pyspark'],
)

0 comments on commit fed0667

Please sign in to comment.