Skip to content

Commit bd1e67c

Browse files
authored
Merge pull request #1 from maxbachmann/init
Improve performance of SequenceMatcher
2 parents 6d57f22 + a3e8cd3 commit bd1e67c

File tree

5 files changed

+52719
-0
lines changed

5 files changed

+52719
-0
lines changed

.github/workflows/pythonbuild.yml

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types:
8+
- published
9+
10+
jobs:
11+
build_legacy:
12+
name: Build wheel for legacy Python versions
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
env:
19+
CIBW_BUILD: cp27-* cp35-* pp27-*
20+
CIBW_BUILD_VERBOSITY: 3
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
with:
25+
submodules: 'true'
26+
27+
- name: Build wheels
28+
uses: pypa/[email protected]
29+
with:
30+
output-dir: wheelhouse
31+
32+
- name: Upload wheels
33+
uses: actions/upload-artifact@v2
34+
with:
35+
path: ./wheelhouse/*.whl
36+
37+
build_windows_27_legacy:
38+
name: Build wheel on windows-latest/auto/2.7
39+
runs-on: windows-latest
40+
41+
steps:
42+
- uses: actions/checkout@v2
43+
with:
44+
submodules: 'true'
45+
46+
- uses: ilammy/msvc-dev-cmd@v1
47+
48+
- name: Build 64-bit wheel
49+
uses: pypa/[email protected]
50+
with:
51+
output-dir: wheelhouse
52+
env:
53+
CIBW_BUILD: cp27-win_amd64
54+
DISTUTILS_USE_SDK: 1
55+
CIBW_BUILD_VERBOSITY: 3
56+
MSSdk: 1
57+
58+
- uses: ilammy/msvc-dev-cmd@v1
59+
with:
60+
arch: x86
61+
62+
- name: Build 32-bit wheel
63+
uses: pypa/[email protected]
64+
with:
65+
output-dir: wheelhouse
66+
env:
67+
CIBW_BUILD: cp27-win32
68+
DISTUTILS_USE_SDK: 1
69+
CIBW_BUILD_VERBOSITY: 3
70+
MSSdk: 1
71+
72+
- name: Upload wheels
73+
uses: actions/upload-artifact@v2
74+
with:
75+
path: ./wheelhouse/*.whl
76+
77+
build_wheels:
78+
name: Build wheel on ${{ matrix.os }}/auto/${{matrix.python_tag}}
79+
runs-on: ${{ matrix.os }}
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
python_tag: ["cp37-*", "cp38-*", "cp39-*"]
84+
os: [windows-latest, macos-latest]
85+
env:
86+
CIBW_BUILD: ${{matrix.python_tag}}
87+
CIBW_BUILD_VERBOSITY: 3
88+
89+
steps:
90+
- uses: actions/checkout@v2
91+
with:
92+
submodules: 'true'
93+
94+
- name: Build wheels
95+
uses: pypa/[email protected]
96+
with:
97+
output-dir: wheelhouse
98+
99+
- name: Upload wheels
100+
uses: actions/upload-artifact@v2
101+
with:
102+
path: ./wheelhouse/*.whl
103+
104+
build_wheels_apple_silicon:
105+
name: Build wheel on macos-latest/universal2+arm64/${{matrix.python_tag}}
106+
runs-on: macos-latest
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
python_tag: ["cp38-*", "cp39-*"]
111+
env:
112+
CIBW_BUILD: ${{matrix.python_tag}}
113+
CIBW_ARCHS_MACOS: "universal2 arm64"
114+
CIBW_BUILD_VERBOSITY: 3
115+
116+
steps:
117+
- uses: actions/checkout@v2
118+
with:
119+
submodules: 'true'
120+
121+
- name: Build wheels
122+
uses: pypa/[email protected]
123+
with:
124+
output-dir: wheelhouse
125+
126+
- name: Upload wheels
127+
uses: actions/upload-artifact@v2
128+
with:
129+
path: ./wheelhouse/*.whl
130+
131+
build_wheels_manylinux:
132+
name: Build wheels on ubuntu-latest/${{matrix.arch}}/${{matrix.python_tag}}
133+
runs-on: ubuntu-latest
134+
strategy:
135+
fail-fast: false
136+
matrix:
137+
arch: [auto, aarch64, ppc64le, s390x]
138+
python_tag: [ "cp36-*", "cp37-*", "cp38-*", "cp39-*"]
139+
env:
140+
CIBW_ARCHS_LINUX: ${{matrix.arch}}
141+
CIBW_BUILD: ${{matrix.python_tag}}
142+
CIBW_BUILD_VERBOSITY: 3
143+
144+
steps:
145+
- uses: actions/checkout@v2
146+
with:
147+
submodules: 'true'
148+
149+
- uses: docker/setup-qemu-action@v1
150+
name: Set up QEMU
151+
152+
- name: Build wheel
153+
uses: pypa/[email protected]
154+
with:
155+
output-dir: wheelhouse
156+
157+
- name: Upload wheels
158+
uses: actions/upload-artifact@v2
159+
with:
160+
path: ./wheelhouse/*.whl
161+
162+
build_wheels_pypy:
163+
name: Build wheel on ${{ matrix.os }}/auto/pp37-*
164+
runs-on: ${{ matrix.os }}
165+
strategy:
166+
fail-fast: false
167+
matrix:
168+
# numpy ships no wheels for pypy on mac os
169+
os: [ubuntu-latest, windows-latest]
170+
env:
171+
CIBW_BUILD: "pp37-*"
172+
CIBW_BUILD_VERBOSITY: 3
173+
174+
steps:
175+
- uses: actions/checkout@v2
176+
with:
177+
submodules: 'true'
178+
179+
- name: Build wheels
180+
uses: pypa/[email protected]
181+
with:
182+
output-dir: wheelhouse
183+
184+
- name: Upload wheels
185+
uses: actions/upload-artifact@v2
186+
with:
187+
path: ./wheelhouse/*.whl
188+
189+
build_sdist:
190+
name: Build source distribution
191+
runs-on: ubuntu-latest
192+
steps:
193+
- uses: actions/checkout@v2
194+
with:
195+
submodules: 'true'
196+
197+
- uses: actions/setup-python@v2
198+
name: Install Python
199+
with:
200+
python-version: '3.7'
201+
202+
- name: Build sdist
203+
run: |
204+
pip3 install build; python3 -m build --sdist
205+
# test whether tarball contains all files required for compiling
206+
pip3 install dist/cydifflib-*.tar.gz
207+
pip3 uninstall cydifflib --yes
208+
209+
- uses: actions/upload-artifact@v2
210+
with:
211+
path: dist/*.tar.gz
212+
213+
deploy-wheels:
214+
if: github.event_name == 'release' && github.event.action == 'published'
215+
needs: [build_legacy, build_windows_27_legacy, build_wheels, build_wheels_apple_silicon, build_wheels_manylinux, build_wheels_pypy, build_sdist]
216+
name: deploy wheels to pypi
217+
runs-on: ubuntu-18.04
218+
219+
steps:
220+
- uses: actions/download-artifact@v2
221+
with:
222+
name: artifact
223+
path: dist
224+
225+
- uses: pypa/gh-action-pypi-publish@master
226+
with:
227+
user: __token__
228+
password: ${{ secrets.pypi_password }}

setup.cfg

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[metadata]
2+
name = cydifflib
3+
version = 0.1.0
4+
url = https://github.com/maxbachmann/cydifflib
5+
author = Max Bachmann
6+
author_email = [email protected]
7+
description = Fast difflib reimplementation in Cython
8+
long_description = file: README.md
9+
long_description_content_type = text/markdown
10+
11+
license = MIT
12+
license_file = LICENSE
13+
classifiers =
14+
Programming Language :: Python :: 2
15+
Programming Language :: Python :: 2.7
16+
Programming Language :: Python :: 3
17+
Programming Language :: Python :: 3.5
18+
Programming Language :: Python :: 3.6
19+
Programming Language :: Python :: 3.7
20+
Programming Language :: Python :: 3.8
21+
Programming Language :: Python :: 3.9
22+
License :: OSI Approved :: MIT License
23+
24+
[options]
25+
zip_safe = False
26+
include_package_data = True
27+
package_dir=
28+
=src
29+
packages = find:
30+
python_requires = >=2.7
31+
32+
[options.packages.find]
33+
where=src

setup.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from setuptools import setup, Extension
2+
from setuptools.command.build_ext import build_ext
3+
import sys
4+
5+
class BuildExt(build_ext):
6+
"""A custom build extension for adding compiler-specific options."""
7+
c_opts = {
8+
'msvc': ['/EHsc', '/O2', '/W4', '/DNDEBUG'],
9+
'unix': ['-O3', '-std=c++11', '-Wextra', '-Wall', '-Wconversion', '-g0', '-DNDEBUG'],
10+
}
11+
l_opts = {
12+
'msvc': [],
13+
'unix': [],
14+
}
15+
16+
if sys.platform == 'darwin':
17+
darwin_opts = ['-stdlib=libc++', '-mmacosx-version-min=10.9']
18+
c_opts['unix'] += darwin_opts
19+
l_opts['unix'] += darwin_opts
20+
21+
def build_extensions(self):
22+
ct = self.compiler.compiler_type
23+
opts = self.c_opts.get(ct, [])
24+
link_opts = self.l_opts.get(ct, [])
25+
if ct == 'unix':
26+
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
27+
elif ct == 'msvc':
28+
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
29+
for ext in self.extensions:
30+
ext.extra_compile_args += opts
31+
ext.extra_link_args += link_opts
32+
build_ext.build_extensions(self)
33+
34+
ext_modules = [
35+
Extension(
36+
name='cydifflib',
37+
sources=['src/cydifflib.cpp'],
38+
language='c++',
39+
)
40+
]
41+
42+
if __name__ == "__main__":
43+
setup(
44+
cmdclass={'build_ext': BuildExt},
45+
ext_modules = ext_modules
46+
)

0 commit comments

Comments
 (0)