Skip to content

Commit 84eaa54

Browse files
committed
Compile with Cython when available.
1 parent f946ac4 commit 84eaa54

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ lib64/
2020
parts/
2121
sdist/
2222
var/
23+
.idea/
2324
*.egg-info/
2425
.installed.cfg
2526
*.egg

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
if version < ('2', '7'):
99
install_requires.append('ordereddict>=1.1')
1010

11+
try:
12+
from Cython.Build import cythonize
13+
ext_modules = cythonize("bencoder.pyx")
14+
except ImportError:
15+
ext_modules = [Extension('bencoder', ['bencoder.c'])]
16+
17+
1118
setup(
1219
name='bencoder.pyx',
1320
version='1.1.0',
@@ -39,7 +46,7 @@
3946
'Programming Language :: Python :: Implementation :: PyPy',
4047
'Topic :: Software Development :: Libraries :: Python Modules',
4148
],
42-
ext_modules=[Extension('bencoder', ['bencoder.c'])],
49+
ext_modules=ext_modules,
4350
install_requires=install_requires,
4451
tests_require=['nose'],
4552
test_suite='nose.collector',

0 commit comments

Comments
 (0)