Permalink
Browse files

met à jour setup.py

  • Loading branch information...
sdpython committed Apr 21, 2015
1 parent d757a51 commit aa6f99a8ed4c386d50546ecf4913bea6c4857ff1
Showing with 107 additions and 131 deletions.
  1. +9 −0 publish_doc_on_pipy.bat
  2. +5 −2 publish_on_pipy.bat
  3. +93 −129 setup.py
View
@@ -0,0 +1,9 @@
if "%1"=="" goto default_value:
set pythonexe=%1\python
goto custom_python:
:default_value:
set pythonexe=c:\Python34_x64\python
:custom_python:
%pythonexe% setup.py upload_docs --upload-dir=dist/html
View
@@ -3,7 +3,10 @@ set pythonexe=%1\python
goto custom_python:
:default_value:
set pythonexe=c:\Python34\python
set pythonexe=c:\Python34_x64\python
:custom_python:
%pythonexe% setup.py sdist register upload
%pythonexe% setup.py rotate --match=.zip --keep=1
%pythonexe% setup.py rotate --match=.tar.gz --keep=3
rem %pythonexe% setup.py sdist register
%pythonexe% setup.py sdist --formats=gztar upload
View
222 setup.py
@@ -42,46 +42,9 @@
from distutils.core import setup
from setuptools import find_packages
def import_pyquickhelper():
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 ({0})".format(
sys.executable)) from e
return pyquickhelper
def write_version():
pyquickhelper = import_pyquickhelper()
from pyquickhelper.loghelper.pyrepo_helper import SourceRepository
src = SourceRepository(commandline=True)
fold = os.path.abspath(os.path.dirname(__file__))
version = src.version(fold)
if version is not None:
with open(os.path.join(fold, "version.txt"), "w") as f:
f.write(str(version) + "\n")
if not os.path.exists("version.txt"):
write_version()
if os.path.exists("version.txt"):
with open("version.txt", "r") as f:
lines = f.readlines()
subversion = lines[0].strip("\r\n ")
else:
raise FileNotFoundError("version.txt")
#########
# settings
#########
project_var_name = "code_beatrix"
sversion = "0.5"
@@ -90,32 +53,20 @@ def write_version():
readme = 'README.rst'
KEYWORDS = \
project_var_name + ', coding goûter'
DESCRIPTION = \
"""Exercices pour apprendre la programmation, les algorithmes, et faire des coding goûters."""
CLASSIFIERS = \
[
'Programming Language :: Python :: 3',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering',
'Topic :: Education',
'License :: OSI Approved :: BSD License',
'Development Status :: 5 - Production/Stable'
]
KEYWORDS = project_var_name + ', coding goûter'
DESCRIPTION = """Exercices pour apprendre la programmation, les algorithmes, et faire des coding goûters."""
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 = []
#######
# data
#######
packages = find_packages('src', exclude='src')
package_dir = {k: "src/" + k.replace(".", "/") for k in packages}
@@ -126,91 +77,107 @@ def write_version():
project_var_name + ".jsscripts.snap": ["*.*"],
}
if os.path.exists(readme):
############
# functions
############
def is_local():
if "clean_space" in sys.argv or \
"write_version" in sys.argv or \
"clean_pyd" in sys.argv or \
"build_sphinx" in sys.argv or \
"unittests" in sys.argv or \
"copy27" in sys.argv or \
"build" in sys.argv or \
"sdist" in sys.argv or \
"register" in sys.argv or \
"bdist_wininst" in sys.argv or \
"bdist_msi" in sys.argv or \
"bdist_wheel" in sys.argv or \
"upload_docs" in sys.argv:
return True
else:
return False
def import_pyquickhelper():
try:
with open(readme, "r", encoding='utf-8') as f:
long_description = f.read()
long_description = long_description.replace("\ufeff", "")
except:
import pyquickhelper
except ImportError:
sys.path.append(
os.path.normpath(
os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"..",
"pyquickhelper",
"src"))))
try:
with open(readme, "r") as f:
long_description = f.read()
except:
long_description = ""
else:
long_description = ""
import pyquickhelper
except ImportError as e:
message = "module pyquickhelper is needed to build the documentation ({0}), not found in path {1}".format(
sys.executable,
sys.path[
-1])
raise ImportError(message) from e
return pyquickhelper
if "--verbose" in 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("---------------------------------")
if "clean_space" in sys.argv:
pyquickhelper = import_pyquickhelper()
##########
# version
##########
fold = os.path.dirname(__file__)
fold = os.path.abspath(fold)
rem = pyquickhelper.remove_extra_spaces_folder(
fold,
extensions=[
".py",
"rst",
".bat",
".sh"])
print("number of impacted files", len(rem))
elif "write_version" in sys.argv:
write_version()
elif "clean_pyd" in sys.argv:
pyquickhelper = import_pyquickhelper()
pyquickhelper.clean_exts()
if is_local():
def write_version():
pyquickhelper = import_pyquickhelper()
from pyquickhelper import write_version_for_setup
return write_version_for_setup(__file__)
elif "build_sphinx" in sys.argv:
pyquickhelper = import_pyquickhelper()
write_version()
if "--help" in sys.argv:
print(pyquickhelper.get_help_usage())
if os.path.exists("version.txt"):
with open("version.txt", "r") as f:
lines = f.readlines()
subversion = "." + lines[0].strip("\r\n ")
else:
raise FileNotFoundError("version.txt")
else:
# when the module is installed, no commit number is displayed
subversion = ""
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
from pyquickhelper.helpgen import sphinx_add_scripts
sphinx_add_scripts(os.path.join("src", project_var_name, "jsscripts", "snap"),
os.path.join("_doc", "sphinxdoc", "source", "phdoc_static", "snap"))
fLOG(OutputPrint=True)
project_name = os.path.split(
os.path.split(os.path.abspath(__file__))[0])[-1]
generate_help_sphinx(project_name, module_name=project_var_name,
layout=["pdf", "html"])
elif "unittests" in sys.argv:
##############
# common part
##############
if not os.path.exists("_unittests"):
raise FileNotFoundError(
"you must get the source from GitHub to run the unittests")
if os.path.exists(readme):
with open(readme, "r", encoding='utf-8-sig') as f:
long_description = f.read()
else:
long_description = ""
run_unit = os.path.join("_unittests", "run_unittests.py")
if not os.path.exists(run_unit):
raise FileNotFoundError("the folder should contain run_unittests.py")
if "--verbose" in sys.argv:
verbose()
if is_local():
pyquickhelper = import_pyquickhelper()
pyquickhelper.main_wrapper_tests(run_unit, add_coverage=True)
r = pyquickhelper.process_standard_options_for_setup(
sys.argv, __file__, project_var_name)
else:
r = False
if not r:
setup(
name=project_var_name,
version='%s.%s' % (sversion, subversion),
version='%s%s' % (sversion, subversion),
author='Xavier Dupré',
author_email='',
url="http://lesenfantscodaient.fr/",
@@ -222,8 +189,5 @@ def write_version():
packages=packages,
package_dir=package_dir,
package_data=package_data,
#data_files = data_files,
install_requires=[],
ext_modules=EXT_MODULES,
#include_package_data = True,
)

0 comments on commit aa6f99a

Please sign in to comment.