File: setup.py

package info (click to toggle)
fastchunking 0.0.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 300 kB
  • sloc: cpp: 490; python: 384; makefile: 197
file content (105 lines) | stat: -rw-r--r-- 3,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import codecs
import os
import re
import sys

from setuptools import setup, Extension
from setuptools.command.test import test as TestCommand

# Some general-purpose code stolen from
# https://github.com/jeffknupp/sandman/blob/5c4b7074e8ba5a60b00659760e222c57ad24ef91/setup.py

here = os.path.abspath(os.path.dirname(__file__))


class Tox(TestCommand):

    def finalize_options(self):
        TestCommand.finalize_options(self)
        self.test_args = []
        self.test_suite = True

    def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import tox
        errcode = tox.cmdline(self.test_args)
        sys.exit(errcode)


def read(*parts):
    # intentionally *not* adding an encoding option to open
    return codecs.open(os.path.join(here, *parts), 'r').read()


def find_version(*file_paths):
    version_file = read(*file_paths)
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
                              version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError("Unable to find version string.")

# Make sure build path exists.
build_path = os.path.join(here, 'build')
if not os.path.exists(build_path):
    os.mkdir(build_path)

# Generate Python bindings for bundled C++ library.
module_fname = os.path.join(build_path, "rabinkarprh.cpp")

try:
    import pybindgen #@UnusedImport
except ImportError:
    print("WARNING: Failed to import pybindgen. If you called setup.py egg_info,"
          "this is probably acceptable; otherwise, build will fail."
          "You can resolve this problem by installing pybindgen beforehand.")
else:
    with open(module_fname, "wt") as file_:
        print("Generating file {}".format(module_fname))
        from lib.rabinkarp_gen import generate
        generate(file_)

setup(
    name='fastchunking',
    version=find_version('fastchunking', '__init__.py'),

    description='Fast chunking library.',
    long_description=read('README.rst'),

    url='https://github.com/netleibi/fastchunking',

    author='Dominik Leibenger',
    author_email='python-fastchunking@mails.dominik-leibenger.de',

    license='Apache Software License',

    classifiers=[
            'Development Status :: 2 - Pre-Alpha',

            'Intended Audience :: Developers',
            'Topic :: Software Development :: Libraries :: Python Modules',

            'License :: OSI Approved :: Apache Software License',

            'Operating System :: OS Independent',

            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.5'
    ],

    keywords=['text chunking', 'SC', 'static chunking', 'CDC', 'content-defined chunking', 'ML-*', 'multi-level chunking', 'ML-SC', 'ML-CDC', 'Rabin Karp', 'rolling hash'],

    packages=['fastchunking', 'lib'],

    setup_requires=['pybindgen'],
    install_requires=['pybindgen'],

    ext_modules=[
        Extension('fastchunking._rabinkarprh',
                  sources=[module_fname, 'lib/rabinkarp.cpp'],
                  include_dirs=['lib']
                  )
    ],

    test_suite='fastchunking.test'
)