1# Copyright 2019 The RE2 Authors.  All Rights Reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file.
4
5import setuptools
6
7long_description = """\
8A drop-in replacement for the re module.
9
10It uses RE2 under the hood, of course, so various PCRE features
11(e.g. backreferences, look-around assertions) are not supported.
12
13Known differences between this API and the re module's API:
14
15  * The error class does not provide any error information as attributes.
16  * The Options class replaces the re module's flags with RE2's options as
17    gettable/settable properties. Please see re2.h for their documentation.
18  * The pattern string and the input string do not have to be the same type.
19    Any str will be encoded to UTF-8.
20  * The pattern string cannot be str if the options specify Latin-1 encoding.
21
22Known issues with regard to building the C++ extension:
23
24  * Building requires RE2 to be installed on your system.
25    On Debian, for example, install the libre2-dev package.
26  * Building requires pybind11 to be installed on your system OR venv.
27    On Debian, for example, install the pybind11-dev package.
28    For a venv, install the pybind11 package from PyPI.
29  * Building on macOS has not been tested yet and will possibly fail.
30  * Building on Windows has not been tested yet and will probably fail.
31"""
32
33def include_dirs():
34  try:
35    import pybind11
36    yield pybind11.get_include()
37  except ModuleNotFoundError:
38    pass
39
40ext_module = setuptools.Extension(
41    name='_re2',
42    sources=['_re2.cc'],
43    include_dirs=list(include_dirs()),
44    libraries=['re2'],
45    extra_compile_args=['-fvisibility=hidden'],
46)
47
48setuptools.setup(
49    name='google-re2',
50    version='0.2.20210901',
51    description='RE2 Python bindings',
52    long_description=long_description,
53    long_description_content_type='text/plain',
54    url='https://github.com/google/re2',
55    author='The RE2 Authors',
56    author_email='re2-dev@googlegroups.com',
57    classifiers=[
58        'Development Status :: 5 - Production/Stable',
59        'Intended Audience :: Developers',
60        'License :: OSI Approved :: BSD License',
61        'Programming Language :: C++',
62        'Programming Language :: Python :: 3.6',
63    ],
64    ext_modules=[ext_module],
65    py_modules=['re2'],
66    python_requires='~=3.6',
67)
68