Skip to content

Commit

Permalink
introduce REQUIRE_SCANDIR_EXTENSION=1 envvar
Browse files Browse the repository at this point in the history
  • Loading branch information
cielavenir committed Aug 28, 2023
1 parent 4d9d52d commit 8fff475
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
python -m pip install wheel
- name: Install
run: |
python -m pip install .
REQUIRE_SCANDIR_EXTENSION=1 python -m pip install .
- name: Run tests
run: |
python test/run_tests.py
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import sys
import logging

REQUIRE_EXTENSION = bool(os.environ.get("REQUIRE_SCANDIR_EXTENSION"))

# Get version without importing scandir because that will lock the
# .pyd file (if scandir is already installed) so it can't be
# overwritten during the install process
Expand All @@ -42,6 +44,9 @@ def build_extension(self, ext):
try:
base_build_ext.build_extension(self, ext)
except Exception:
if REQUIRE_EXTENSION:
logging.error('REQUIRE_SCANDIR_EXTENSION is set, not falling back to Python implementation')
raise
info = sys.exc_info()
logging.warn("building %s failed with %s: %s", ext.name, info[0], info[1])

Expand Down

0 comments on commit 8fff475

Please sign in to comment.