Skip to content

Commit

Permalink
Fix: System packages had priority over user installed
Browse files Browse the repository at this point in the history
By appending the path `/opt/packages` to the Python Path, system packages were loaded in priority. This prevented users from shipping their own versions of packages also present on the OS.
  • Loading branch information
hoh committed Oct 3, 2023
1 parent b2d6314 commit 144b1fa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions runtimes/aleph-debian-11-python/init1.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ async def send(response: Dict):
async def setup_code_asgi(
code: bytes, encoding: Encoding, entrypoint: str
) -> ASGIApplication:
# Allow importing packages from /opt/packages
sys.path.append("/opt/packages")
# Allow importing packages from /opt/packages, give it priority
sys.path.insert(0, "/opt/packages")

logger.debug("Extracting code")
app: ASGIApplication
if encoding == Encoding.squashfs:
sys.path.append("/opt/code")
sys.path.insert(0, "/opt/code")
module_name, app_name = entrypoint.split(":", 1)
logger.debug("import module")
module = __import__(module_name)
Expand All @@ -255,7 +255,7 @@ async def setup_code_asgi(
open("/opt/archive.zip", "wb").write(code)
logger.debug("Run unzip")
os.system("unzip -q /opt/archive.zip -d /opt")
sys.path.append("/opt")
sys.path.insert(0, "/opt")
module_name, app_name = entrypoint.split(":", 1)
logger.debug("import module")
module = __import__(module_name)
Expand Down

0 comments on commit 144b1fa

Please sign in to comment.