Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building Lambdas in Python 3.9 #336

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions werkit/aws_lambda/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
import sys
import sysconfig
import venv
import zipfile
from executor import execute
Expand Down Expand Up @@ -47,18 +48,6 @@ def create_venv_with_dependencies(
execute(*args, environment=environment)


def find_site_packages_dir(venv_dir):
for candidate_result in [
os.path.join(venv_dir, "lib64", "python3.8", "site-packages"),
os.path.join(venv_dir, "lib", "python3.8", "site-packages"),
os.path.join(venv_dir, "lib64", "python3.7", "site-packages"),
os.path.join(venv_dir, "lib", "python3.7", "site-packages"),
]:
if os.path.exists(candidate_result):
return candidate_result
raise ValueError(f"Unable to locate site-packages folder in {venv_dir}")


def collect_zipfile_contents(
target_dir, venv_dir, src_files=[], src_dirs=[], lib_files=[], verbose=False
):
Expand All @@ -72,7 +61,7 @@ def pif(x):
raise ValueError(f"venv_dir should already be populated: {venv_dir}")

# Copy dependencies from venv.
site_packages_dir = find_site_packages_dir(venv_dir)
site_packages_dir = sysconfig.get_paths()["purelib"]
pif(f"Copying dependencies from {site_packages_dir} to {target_dir}")
shutil.copytree(site_packages_dir, target_dir)

Expand Down