2018-08-21 19:26:50 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2020-06-08 23:47:48 +02:00
|
|
|
"""
|
|
|
|
Template by pypi-mobans
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2017-10-20 08:55:56 +02:00
|
|
|
import codecs
|
2019-11-08 21:21:41 +01:00
|
|
|
import locale
|
|
|
|
import platform
|
2017-10-20 08:55:56 +02:00
|
|
|
from shutil import rmtree
|
2018-11-10 23:26:43 +01:00
|
|
|
|
2020-06-08 23:47:48 +02:00
|
|
|
from setuptools import Command, setup, find_packages
|
2018-11-10 23:26:43 +01:00
|
|
|
|
2016-08-31 09:36:47 +02:00
|
|
|
PY2 = sys.version_info[0] == 2
|
|
|
|
PY26 = PY2 and sys.version_info[1] < 7
|
2019-11-08 21:21:41 +01:00
|
|
|
PY33 = sys.version_info < (3, 4)
|
|
|
|
|
|
|
|
# Work around mbcs bug in distutils.
|
|
|
|
# http://bugs.python.org/issue10945
|
|
|
|
# This work around is only if a project supports Python < 3.4
|
|
|
|
|
|
|
|
# Work around for locale not being set
|
|
|
|
try:
|
|
|
|
lc = locale.getlocale()
|
|
|
|
pf = platform.system()
|
|
|
|
if pf != "Windows" and lc == (None, None):
|
|
|
|
locale.setlocale(locale.LC_ALL, "C.UTF-8")
|
|
|
|
except (ValueError, UnicodeError, locale.Error):
|
|
|
|
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
|
|
|
|
|
|
|
|
NAME = "pyexcel-xls"
|
2020-10-21 10:35:59 +02:00
|
|
|
AUTHOR = "C.W."
|
2021-10-07 00:16:47 +02:00
|
|
|
VERSION = "0.7.0"
|
2019-11-08 21:21:41 +01:00
|
|
|
EMAIL = "info@pyexcel.org"
|
|
|
|
LICENSE = "New BSD"
|
2016-06-09 00:03:04 +02:00
|
|
|
DESCRIPTION = (
|
2019-11-08 21:21:41 +01:00
|
|
|
"A wrapper library to read, manipulate and write data in xls format. It" +
|
|
|
|
"reads xlsx and xlsm format"
|
2016-06-09 00:03:04 +02:00
|
|
|
)
|
2019-11-08 21:21:41 +01:00
|
|
|
URL = "https://github.com/pyexcel/pyexcel-xls"
|
2021-10-07 00:16:47 +02:00
|
|
|
DOWNLOAD_URL = "%s/archive/0.7.0.tar.gz" % URL
|
2020-08-29 22:39:29 +02:00
|
|
|
FILES = ["README.rst","CONTRIBUTORS.rst", "CHANGELOG.rst"]
|
2016-04-28 23:19:34 +02:00
|
|
|
KEYWORDS = [
|
2019-11-08 21:21:41 +01:00
|
|
|
"python",
|
2016-06-09 00:05:01 +02:00
|
|
|
'xls',
|
|
|
|
'xlsx',
|
2018-11-10 23:26:43 +01:00
|
|
|
'xlsm'
|
2016-04-28 23:19:34 +02:00
|
|
|
]
|
2016-04-26 00:05:13 +02:00
|
|
|
|
2016-04-28 23:19:34 +02:00
|
|
|
CLASSIFIERS = [
|
2019-11-08 21:21:41 +01:00
|
|
|
"Topic :: Software Development :: Libraries",
|
|
|
|
"Programming Language :: Python",
|
|
|
|
"Intended Audience :: Developers",
|
2020-10-21 10:35:59 +02:00
|
|
|
|
|
|
|
"Programming Language :: Python :: 3 :: Only",
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-08 21:21:41 +01:00
|
|
|
"Programming Language :: Python :: 3.6",
|
|
|
|
"Programming Language :: Python :: 3.7",
|
|
|
|
"Programming Language :: Python :: 3.8",
|
|
|
|
|
2016-06-09 00:05:01 +02:00
|
|
|
'Programming Language :: Python :: Implementation :: PyPy'
|
2016-04-28 23:19:34 +02:00
|
|
|
]
|
|
|
|
|
2020-10-21 10:35:59 +02:00
|
|
|
PYTHON_REQUIRES = ">=3.6"
|
2020-06-08 23:47:48 +02:00
|
|
|
|
2016-09-20 19:38:22 +02:00
|
|
|
INSTALL_REQUIRES = [
|
2020-10-08 20:01:20 +02:00
|
|
|
"pyexcel-io>=0.6.2",
|
2021-10-06 23:01:26 +02:00
|
|
|
"xlrd",
|
2019-11-08 21:21:41 +01:00
|
|
|
"xlwt",
|
2016-09-20 19:38:22 +02:00
|
|
|
]
|
2018-08-21 19:26:50 +02:00
|
|
|
SETUP_COMMANDS = {}
|
2016-09-20 19:38:22 +02:00
|
|
|
|
2020-06-08 23:47:48 +02:00
|
|
|
PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests", "tests.*"])
|
2016-09-20 19:38:22 +02:00
|
|
|
EXTRAS_REQUIRE = {
|
|
|
|
}
|
2018-08-21 19:26:50 +02:00
|
|
|
# You do not need to read beyond this line
|
2019-11-08 21:21:41 +01:00
|
|
|
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
|
2020-10-21 10:35:59 +02:00
|
|
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
2021-10-07 00:16:47 +02:00
|
|
|
GS_COMMAND = ("gease pyexcel-xls v0.7.0 " +
|
|
|
|
"Find 0.7.0 in changelog for more details")
|
2019-11-08 21:21:41 +01:00
|
|
|
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
|
|
|
|
"Please install gease to enable it.")
|
2018-08-21 19:26:50 +02:00
|
|
|
UPLOAD_FAILED_MSG = (
|
|
|
|
'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND)
|
2017-10-20 08:55:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PublishCommand(Command):
|
|
|
|
"""Support setup.py upload."""
|
|
|
|
|
2019-11-08 21:21:41 +01:00
|
|
|
description = "Build and publish the package on github and pypi"
|
2017-10-20 08:55:56 +02:00
|
|
|
user_options = []
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def status(s):
|
|
|
|
"""Prints things in bold."""
|
2019-11-08 21:21:41 +01:00
|
|
|
print("\033[1m{0}\033[0m".format(s))
|
2017-10-20 08:55:56 +02:00
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
try:
|
2019-11-08 21:21:41 +01:00
|
|
|
self.status("Removing previous builds...")
|
|
|
|
rmtree(os.path.join(HERE, "dist"))
|
|
|
|
rmtree(os.path.join(HERE, "build"))
|
|
|
|
rmtree(os.path.join(HERE, "pyexcel_xls.egg-info"))
|
2017-10-20 08:55:56 +02:00
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
2019-11-08 21:21:41 +01:00
|
|
|
self.status("Building Source and Wheel (universal) distribution...")
|
2018-08-21 19:26:50 +02:00
|
|
|
run_status = True
|
|
|
|
if has_gease():
|
|
|
|
run_status = os.system(GS_COMMAND) == 0
|
|
|
|
else:
|
|
|
|
self.status(NO_GS_MESSAGE)
|
|
|
|
if run_status:
|
|
|
|
if os.system(PUBLISH_COMMAND) != 0:
|
2019-11-08 21:21:41 +01:00
|
|
|
self.status(UPLOAD_FAILED_MSG)
|
2017-10-20 08:55:56 +02:00
|
|
|
|
|
|
|
sys.exit()
|
2016-09-20 19:38:22 +02:00
|
|
|
|
2016-04-28 23:19:34 +02:00
|
|
|
|
2018-08-21 19:26:50 +02:00
|
|
|
SETUP_COMMANDS.update({
|
2019-11-08 21:21:41 +01:00
|
|
|
"publish": PublishCommand
|
2018-08-21 19:26:50 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
def has_gease():
|
|
|
|
"""
|
|
|
|
test if github release command is installed
|
|
|
|
|
|
|
|
visit http://github.com/moremoban/gease for more info
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
import gease # noqa
|
|
|
|
return True
|
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2016-04-28 23:19:34 +02:00
|
|
|
def read_files(*files):
|
|
|
|
"""Read files into setup"""
|
|
|
|
text = ""
|
|
|
|
for single_file in files:
|
2016-09-20 19:38:22 +02:00
|
|
|
content = read(single_file)
|
|
|
|
text = text + content + "\n"
|
2016-04-28 23:19:34 +02:00
|
|
|
return text
|
|
|
|
|
|
|
|
|
|
|
|
def read(afile):
|
|
|
|
"""Read a file into setup"""
|
2018-08-21 19:26:50 +02:00
|
|
|
the_relative_file = os.path.join(HERE, afile)
|
2019-11-08 21:21:41 +01:00
|
|
|
with codecs.open(the_relative_file, "r", "utf-8") as opened_file:
|
2016-09-20 19:38:22 +02:00
|
|
|
content = filter_out_test_code(opened_file)
|
|
|
|
content = "".join(list(content))
|
|
|
|
return content
|
|
|
|
|
|
|
|
|
|
|
|
def filter_out_test_code(file_handle):
|
|
|
|
found_test_code = False
|
|
|
|
for line in file_handle.readlines():
|
2019-11-08 21:21:41 +01:00
|
|
|
if line.startswith(".. testcode:"):
|
2016-09-20 19:38:22 +02:00
|
|
|
found_test_code = True
|
|
|
|
continue
|
|
|
|
if found_test_code is True:
|
2019-11-08 21:21:41 +01:00
|
|
|
if line.startswith(" "):
|
2016-09-20 19:38:22 +02:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
empty_line = line.strip()
|
|
|
|
if len(empty_line) == 0:
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
found_test_code = False
|
|
|
|
yield line
|
|
|
|
else:
|
2019-11-08 21:21:41 +01:00
|
|
|
for keyword in ["|version|", "|today|"]:
|
2017-08-20 02:07:43 +02:00
|
|
|
if keyword in line:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
yield line
|
2016-04-28 23:19:34 +02:00
|
|
|
|
|
|
|
|
2019-11-08 21:21:41 +01:00
|
|
|
if __name__ == "__main__":
|
2016-04-28 23:19:34 +02:00
|
|
|
setup(
|
2019-11-08 21:21:41 +01:00
|
|
|
test_suite="tests",
|
2016-04-28 23:19:34 +02:00
|
|
|
name=NAME,
|
|
|
|
author=AUTHOR,
|
|
|
|
version=VERSION,
|
|
|
|
author_email=EMAIL,
|
|
|
|
description=DESCRIPTION,
|
2017-08-20 02:07:43 +02:00
|
|
|
url=URL,
|
|
|
|
download_url=DOWNLOAD_URL,
|
|
|
|
long_description=read_files(*FILES),
|
2016-09-20 19:38:22 +02:00
|
|
|
license=LICENSE,
|
2016-04-28 23:19:34 +02:00
|
|
|
keywords=KEYWORDS,
|
2020-10-21 10:35:59 +02:00
|
|
|
python_requires=PYTHON_REQUIRES,
|
2016-04-28 23:19:34 +02:00
|
|
|
extras_require=EXTRAS_REQUIRE,
|
2019-11-08 21:21:41 +01:00
|
|
|
tests_require=["nose"],
|
2016-09-20 19:38:22 +02:00
|
|
|
install_requires=INSTALL_REQUIRES,
|
2016-04-28 23:19:34 +02:00
|
|
|
packages=PACKAGES,
|
|
|
|
include_package_data=True,
|
|
|
|
zip_safe=False,
|
2017-10-20 08:55:56 +02:00
|
|
|
classifiers=CLASSIFIERS,
|
2018-08-21 19:26:50 +02:00
|
|
|
cmdclass=SETUP_COMMANDS
|
2016-05-10 10:09:31 +02:00
|
|
|
)
|