You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

171 lines
5.6 KiB

  1. #!/usr/bin/env python
  2. import codecs
  3. import logging
  4. import os
  5. import re
  6. import subprocess
  7. import sys
  8. import warnings
  9. from setuptools import setup, find_packages, Command
  10. from setuptools.command.test import test as TestCommand
  11. NAME = "wstools-py3"
  12. url = "https://github.com/Synerty/wstools-py3"
  13. # Get the version - do not use normal import because it does break coverage
  14. base_path = os.path.dirname(__file__)
  15. fp = open(os.path.join(base_path, 'wstools', 'version.py'))
  16. __version__ = re.compile(r".*__version__\s*=\s*['\"](.*?)['\"]",
  17. re.S).match(fp.read()).group(1)
  18. fp.close()
  19. # this should help getting annoying warnings from inside distutils
  20. warnings.simplefilter('ignore', UserWarning)
  21. class PyTest(TestCommand):
  22. user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
  23. def initialize_options(self):
  24. TestCommand.initialize_options(self)
  25. self.pytest_args = []
  26. FORMAT = '%(levelname)-10s %(message)s'
  27. logging.basicConfig(format=FORMAT)
  28. logging.getLogger().setLevel(logging.INFO)
  29. # if we have pytest-cache module we enable the test failures first mode
  30. try:
  31. import pytest_cache # noqa
  32. self.pytest_args.append("--ff")
  33. except ImportError:
  34. pass
  35. self.pytest_args.append("-s")
  36. if sys.stdout.isatty():
  37. # when run manually we enable fail fast
  38. self.pytest_args.append("--maxfail=1")
  39. def finalize_options(self):
  40. TestCommand.finalize_options(self)
  41. self.test_args = []
  42. self.test_suite = True
  43. def run_tests(self):
  44. # before running tests we need to run autopep8
  45. try:
  46. subprocess.check_call(
  47. "python -m autopep8 -r --in-place wstools/ tests/",
  48. shell=True)
  49. except subprocess.CalledProcessError:
  50. logging.getLogger().warn('autopep8 is not installed so '
  51. 'it will not be run')
  52. # import here, cause outside the eggs aren't loaded
  53. import pytest # noqa
  54. errno = pytest.main(self.pytest_args)
  55. sys.exit(errno)
  56. class Release(Command):
  57. user_options = []
  58. def initialize_options(self):
  59. # Command.initialize_options(self)
  60. pass
  61. def finalize_options(self):
  62. # Command.finalize_options(self)
  63. pass
  64. def run(self):
  65. import json
  66. try:
  67. from urllib.request import urlopen
  68. except ImportError:
  69. from urllib.request import urlopen
  70. response = urlopen(
  71. "http://pypi.python.org/pypi/%s/json" % NAME)
  72. data = json.load(codecs.getreader("utf-8")(response))
  73. released_version = data['info']['version']
  74. if released_version == __version__:
  75. raise RuntimeError(
  76. "This version was already released, remove it from PyPi if you want to release it"
  77. " again or increase the version number. http://pypi.python.org/pypi/%s/" % NAME)
  78. elif released_version > __version__:
  79. raise RuntimeError(
  80. "Cannot release a version (%s) smaller than the PyPI current release (%s)." % (
  81. __version__, released_version))
  82. class PreRelease(Command):
  83. user_options = []
  84. def initialize_options(self):
  85. # Command.initialize_options(self)
  86. pass
  87. def finalize_options(self):
  88. # Command.finalize_options(self)
  89. pass
  90. def run(self):
  91. import json
  92. try:
  93. from urllib.request import urlopen
  94. except ImportError:
  95. from urllib.request import urlopen
  96. response = urlopen(
  97. "http://pypi.python.org/pypi/%s/json" % NAME)
  98. data = json.load(codecs.getreader("utf-8")(response))
  99. released_version = data['info']['version']
  100. if released_version >= __version__:
  101. raise RuntimeError(
  102. "Current version of the package is equal or lower than the already published ones (PyPi). Increse version to be able to pass prerelease stage.")
  103. install_requires = [ 'six' ]
  104. # The order of packages is significant, because pip processes them in the order
  105. # of appearance. Changing the order has an impact on the overall integration
  106. # process, which may cause wedges in the gate later.
  107. tests_require = [ 'py >= 1.4', 'hacking', 'pytest', 'pytest-cov' ]
  108. setup(
  109. name=NAME,
  110. version=__version__,
  111. cmdclass={'test': PyTest, 'release': Release, 'prerelease': PreRelease},
  112. packages=find_packages(exclude=['tests']),
  113. include_package_data=True,
  114. tests_require=tests_require,
  115. setup_requires=['setuptools'],
  116. install_requires=install_requires,
  117. extras_require={
  118. 'testing': tests_require
  119. },
  120. license='BSD',
  121. description="WSDL parsing services package for Web Services for Python. see" + url,
  122. long_description=open("README.rst").read(),
  123. maintainer="Synerty",
  124. maintainer_email="contact@synerty.com",
  125. author='Makina Corpus',
  126. author_email='python@makina-corpus.com',
  127. provides=['wstools'],
  128. url=url,
  129. bugtrack_url='%s/issues' % url,
  130. home_page=url,
  131. keywords='api wstools wdsl web',
  132. classifiers=[
  133. 'Programming Language :: Python',
  134. 'Programming Language :: Python :: 3',
  135. 'Development Status :: 5 - Production/Stable',
  136. 'Environment :: Other Environment',
  137. 'Intended Audience :: Developers',
  138. 'License :: OSI Approved :: BSD License',
  139. 'Operating System :: OS Independent',
  140. 'Topic :: Software Development :: Libraries :: Python Modules',
  141. 'Programming Language :: Python :: 3.4',
  142. 'Programming Language :: Python :: 3.5',
  143. 'Topic :: Internet :: WWW/HTTP',
  144. ],
  145. )