|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # -*- coding: utf-8 -*- |
| 3 | +import codecs |
| 4 | +import os |
| 5 | +import re |
3 | 6 |
|
4 | 7 | try: |
5 | 8 | from setuptools import setup |
6 | 9 | except ImportError: |
7 | 10 | from distutils.core import setup |
8 | 11 |
|
9 | | -import os |
10 | | - |
11 | | -os.chdir(os.path.abspath(os.path.dirname(__file__))) |
12 | | - |
13 | | -# Read package version without importing it |
14 | | -for line in open(os.path.join("tarantool", "__init__.py")): |
15 | | - if line.startswith("__version__"): |
16 | | - exec line |
17 | | - break |
18 | | - |
19 | 12 | # Extra commands for documentation management |
20 | 13 | cmdclass = {} |
21 | 14 | command_options = {} |
|
37 | 30 | from sphinx_pypi_upload import UploadDoc |
38 | 31 | cmdclass["upload_sphinx"] = UploadDoc |
39 | 32 | command_options["upload_sphinx"] = { |
40 | | - 'upload_dir': ('setup.py', os.path.join("build", "sphinx", "html")) |
| 33 | + 'upload_dir': ('setup.py', os.path.join("build", "sphinx", "html")) |
41 | 34 | } |
42 | 35 | except ImportError: |
43 | 36 | pass |
|
51 | 44 | except ImportError: |
52 | 45 | pass |
53 | 46 |
|
| 47 | + |
| 48 | +def read(*parts): |
| 49 | + filename = os.path.join(os.path.dirname(__file__), *parts) |
| 50 | + with codecs.open(filename, encoding='utf-8') as fp: |
| 51 | + return fp.read() |
| 52 | + |
| 53 | + |
| 54 | +def find_version(*file_paths): |
| 55 | + version_file = read(*file_paths) |
| 56 | + version_match = re.search(r"""^__version__\s*=\s*(['"])(.+)\1""", |
| 57 | + version_file, re.M) |
| 58 | + if version_match: |
| 59 | + return version_match.group(2) |
| 60 | + raise RuntimeError("Unable to find version string.") |
| 61 | + |
| 62 | + |
54 | 63 | setup( |
55 | | - name = "tarantool", |
56 | | - packages = ["tarantool"], |
57 | | - package_dir = {"tarantool": os.path.join("tarantool")}, |
58 | | - version = __version__, |
59 | | - platforms = ["all"], |
60 | | - author = "Konstantin Cherkasoff", |
61 | | - author_email = "k.cherkasoff@gmail.com", |
62 | | - url = "https://github.com/coxx/tarantool-python", |
63 | | - license = "BSD", |
64 | | - description = "Python client library for Tarantool Database", |
65 | | - long_description = open("README.rst").read(), |
66 | | - classifiers = [ |
| 64 | + name="tarantool", |
| 65 | + packages=["tarantool"], |
| 66 | + package_dir={"tarantool": os.path.join("tarantool")}, |
| 67 | + version=find_version('tarantool', '__init__.py'), |
| 68 | + platforms=["all"], |
| 69 | + author="Konstantin Cherkasoff", |
| 70 | + author_email="k.cherkasoff@gmail.com", |
| 71 | + url="https://github.com/tarantool/tarantool-python", |
| 72 | + license="BSD", |
| 73 | + description="Python client library for Tarantool Database", |
| 74 | + long_description=read('README.rst'), |
| 75 | + classifiers=[ |
67 | 76 | "Intended Audience :: Developers", |
68 | 77 | "License :: OSI Approved :: BSD License", |
69 | 78 | "Operating System :: OS Independent", |
70 | 79 | "Programming Language :: Python", |
71 | 80 | "Topic :: Database :: Front-Ends" |
72 | 81 | ], |
73 | | - cmdclass = cmdclass, |
74 | | - command_options = command_options, |
75 | | - install_requires = [ |
| 82 | + cmdclass=cmdclass, |
| 83 | + command_options=command_options, |
| 84 | + install_requires=[ |
76 | 85 | 'msgpack-python>=0.4', |
77 | 86 | ] |
78 | 87 | ) |
0 commit comments