mirror of
https://github.com/google/re2.git
synced 2025-10-15 12:17:02 +08:00
More setting up to run mypy as per #496.
We need `re2` to be a package, not a module, because it appears that modules can't have `.pyi` files, so munge the module into a package. Change-Id: I1a268875743390c32c0fb9cd58f6d83a670ce928 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63270 Reviewed-by: Paul Wankadia <junyer@google.com> Reviewed-by: Alex Chernyakhovsky <achernya@google.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import re
|
||||
import setuptools
|
||||
import setuptools.command.build_ext
|
||||
import shutil
|
||||
@@ -103,6 +104,16 @@ ext_module = setuptools.Extension(
|
||||
extra_compile_args=['-fvisibility=hidden'],
|
||||
)
|
||||
|
||||
# We need `re2` to be a package, not a module, because it appears that
|
||||
# modules can't have `.pyi` files, so munge the module into a package.
|
||||
os.makedirs('re2')
|
||||
with open('re2.py', 'r') as file:
|
||||
contents = file.read()
|
||||
contents = re.sub(r'^(?=import _)', 'from . ', contents, flags=re.MULTILINE)
|
||||
with open(f're2/__init__.py', 'x') as file:
|
||||
file.write(contents)
|
||||
# TODO(junyer): `.pyi` files as per https://github.com/google/re2/issues/496.
|
||||
|
||||
setuptools.setup(
|
||||
name='google-re2',
|
||||
version='1.1.20240601',
|
||||
@@ -112,7 +123,8 @@ setuptools.setup(
|
||||
author='The RE2 Authors',
|
||||
author_email='re2-dev@googlegroups.com',
|
||||
url='https://github.com/google/re2',
|
||||
py_modules=['re2'],
|
||||
packages=['re2'],
|
||||
ext_package='re2',
|
||||
ext_modules=[ext_module],
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
@@ -125,3 +137,5 @@ setuptools.setup(
|
||||
cmdclass={'build_ext': BuildExt},
|
||||
python_requires='~=3.8',
|
||||
)
|
||||
|
||||
shutil.rmtree('re2')
|
||||
|
Reference in New Issue
Block a user