Skip to content

Commit 940c8c6

Browse files
committed
Bail out early if extensions would be disabled.
1 parent dab21f7 commit 940c8c6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

setup.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
CFLAGS = ''
2222
LFLAGS = ''
2323

24+
allow_extensions = True
25+
if '__pypy__' in sys.builtin_module_names:
26+
print('NOTICE: C extensions disabled on PyPy (would be broken)!')
27+
allow_extensions = False
28+
if os.environ.get('SETUPPY_FORCE_PURE'):
29+
print('NOTICE: C extensions disabled (SETUPPY_FORCE_PURE)!')
30+
allow_extensions = False
31+
2432

2533
class OptionalBuildExt(build_ext):
2634
"""
@@ -29,10 +37,6 @@ class OptionalBuildExt(build_ext):
2937

3038
def run(self):
3139
try:
32-
if '__pypy__' in sys.builtin_module_names:
33-
raise Exception('C extensions are broken on PyPy!')
34-
if os.environ.get('SETUPPY_FORCE_PURE'):
35-
raise Exception('C extensions disabled (SETUPPY_FORCE_PURE)!')
3640
super().run()
3741
except Exception as e:
3842
self._unavailable(e)
@@ -144,6 +148,8 @@ def read(*names, **kwargs):
144148
include_dirs=[str(path.parent)],
145149
)
146150
for path in Path('src').glob('**/*.c')
147-
],
151+
]
152+
if allow_extensions
153+
else [],
148154
distclass=BinaryDistribution,
149155
)

0 commit comments

Comments
 (0)