Skip to content

Commit

Permalink
update setup and build on circleci
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed May 16, 2018
1 parent ad030e6 commit db81c23
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.4
- image: circleci/python:3.6.5

working_directory: ~/repo

Expand Down
14 changes: 1 addition & 13 deletions _doc/sphinxdoc/source/conf.py
Expand Up @@ -2,24 +2,12 @@
import sys
import os
import sphinx_bootstrap_theme
from pyquickhelper.helpgen.default_conf import set_sphinx_variables, get_default_stylesheet

sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0])))
sys.path.insert(
0,
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"..",
"pyquickhelper",
"src")))

local_template = os.path.join(os.path.abspath(
os.path.dirname(__file__)), "phdoc_templates")

from pyquickhelper.helpgen.default_conf import set_sphinx_variables, get_default_stylesheet
set_sphinx_variables(__file__, "teachpyx", "Xavier Dupré", 2018,
"bootstrap", sphinx_bootstrap_theme.get_html_theme_path(),
locals(), extlinks=dict(
Expand Down
3 changes: 2 additions & 1 deletion build_script.bat
Expand Up @@ -5,7 +5,8 @@ set pythonexe="%1"
goto custom_python:

:default_value_python:
set pythonexe="c:\Python364_x64\python.exe"
set pythonexe="c:\Python365_x64\python.exe"
if not exist %pythonexe% set pythonexe="c:\Python364_x64\python.exe"
if not exist %pythonexe% set pythonexe="c:\Python363_x64\python.exe"
if not exist %pythonexe% set pythonexe="c:\Python36_x64\python.exe"
:custom_python:
Expand Down
48 changes: 4 additions & 44 deletions setup.py
Expand Up @@ -48,35 +48,10 @@ def ask_help():
return "--help" in sys.argv or "--help-commands" in sys.argv


def import_pyquickhelper():
try:
import pyquickhelper
except ImportError:
sys.path.append(
os.path.normpath(
os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"..",
"pyquickhelper" if sys.version_info[
0] >= 3 else "py27_pyquickhelper_27",
"src"))))
try:
import pyquickhelper
except ImportError as e:
message = "Module pyquickhelper is needed to build the documentation ({0}), not found in path {1} - current {2}".format(
sys.executable,
sys.path[-1],
os.getcwd())
raise ImportError(message) from e
return pyquickhelper


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

Expand All @@ -96,20 +71,18 @@ def verbose():

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

if sys.version_info[0] != 2:
write_version()
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("Subversion is wrong: '{0}'.".format(subversion))
raise Exception("Git version is wrong: '{0}'.".format(subversion))
else:
raise FileNotFoundError(versiontxt)
else:
Expand All @@ -118,36 +91,27 @@ def write_version():

if "upload" in sys.argv and not subversion and not ask_help():
# avoid uploading with a wrong subversion number
try:
import pyquickhelper
pyq = True
except ImportError:
pyq = False
raise Exception(
"subversion is empty, cannot upload, is_local()={0}, pyquickhelper={1}".format(is_local(), pyq))
"Git version is empty, cannot upload, is_local()={0}".format(is_local()))

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

if os.path.exists(readme):
if sys.version_info[0] == 2:
from codecs import open
with open(readme, "r", encoding='utf-8-sig') as f:
long_description = f.read()
else:
long_description = ""
if os.path.exists(history):
if sys.version_info[0] == 2:
from codecs import open
with open(history, "r", encoding='utf-8-sig') as f:
long_description += f.read()

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

if is_local():
pyquickhelper = import_pyquickhelper()
import pyquickhelper
logging_function = pyquickhelper.get_fLOG()
logging_function(OutputPrint=True)
from pyquickhelper.pycode import process_standard_options_for_setup
Expand All @@ -171,17 +135,13 @@ def write_version():
r = False

if ask_help():
pyquickhelper = import_pyquickhelper()
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",):
pyquickhelper = import_pyquickhelper()
from pyquickhelper.pycode import process_standard_options_for_setup_help
process_standard_options_for_setup_help(sys.argv)
else:
pyquickhelper = import_pyquickhelper()
from pyquickhelper.pycode import clean_readme
long_description = clean_readme(long_description)

Expand Down

0 comments on commit db81c23

Please sign in to comment.