Skip to content

Commit

Permalink
macOS: Reduce .dmg size by excluding "PIL"
Browse files Browse the repository at this point in the history
59.1 MB -> 50.7 MB
  • Loading branch information
davidfstr committed Sep 5, 2023
1 parent 6667bb0 commit 0dc7239
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
'excludes': [
'numpy',
'test', # CPython test data
'PIL',
]
}},
)
Expand Down
18 changes: 11 additions & 7 deletions src/crystal/tests/util/screenshots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from contextlib import contextmanager
import os
import pyscreeze
import sys
from typing import Iterator

Expand All @@ -13,11 +12,16 @@ def screenshot_if_raises() -> Iterator[None]:
# Take screenshot if screenshots directory path defined
screenshots_dirpath = os.environ.get('CRYSTAL_SCREENSHOTS_DIRPATH')
if screenshots_dirpath is not None:
os.makedirs(screenshots_dirpath, exist_ok=True)

screenshot_filename = os.environ.get('CRYSTAL_SCREENSHOT_ID', 'screenshot') + '.png'
screenshot_filepath = os.path.join(screenshots_dirpath, screenshot_filename)
print('*** Saving screenshot to: ' + os.path.abspath(screenshot_filepath), file=sys.stderr)
pyscreeze.screenshot(screenshot_filepath)
try:
import pyscreeze
except ImportError: # probably PIL missing
print('*** Unable to save screenshot because pyscreeze not available. Probably PIL is missing.', file=sys.stderr)
else:
os.makedirs(screenshots_dirpath, exist_ok=True)

screenshot_filename = os.environ.get('CRYSTAL_SCREENSHOT_ID', 'screenshot') + '.png'
screenshot_filepath = os.path.join(screenshots_dirpath, screenshot_filename)
print('*** Saving screenshot to: ' + os.path.abspath(screenshot_filepath), file=sys.stderr)
pyscreeze.screenshot(screenshot_filepath)

raise

0 comments on commit 0dc7239

Please sign in to comment.