Skip to content

Commit

Permalink
Optimistically import the importlib_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblock committed Aug 28, 2023
1 parent 4a2cfaf commit 83f1700
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

---

## [3.3.1] 2023-08-28

### Changed

- Optimistically import `importlib_metadata` during Python treeshaking in case it's already installed in the system

---

## [3.3.0] 2023-07-31

### Added
Expand Down
24 changes: 13 additions & 11 deletions src/actions/autoinstall/python/py/get_python_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
import pathlib
import sys

dir_path = os.path.dirname(os.path.realpath(__file__))
vendor_path = os.path.join(dir_path, "vendor")
sys.path.append(vendor_path)
if not os.path.exists(vendor_path):
import zipfile

vendor_zip = os.path.join(dir_path, "vendor.zip")
with zipfile.ZipFile(vendor_zip, "r") as zipped:
zipped.extractall(dir_path)

import importlib_metadata
try:
import importlib_metadata
except Exception:
dir_path = os.path.dirname(os.path.realpath(__file__))
vendor_path = os.path.join(dir_path, "vendor")
sys.path.append(vendor_path)
if not os.path.exists(vendor_path):
import zipfile

vendor_zip = os.path.join(dir_path, "vendor.zip")
with zipfile.ZipFile(vendor_zip, "r") as zipped:
zipped.extractall(dir_path)
import importlib_metadata

# This script expects to be run like so: `get_python_deps.py $lambda_runtime $arc_src_dir`
# The Lambda runtime (e.g. `python3.10`) is used to fetch the stdlib json file
Expand Down

0 comments on commit 83f1700

Please sign in to comment.