Skip to content

Commit

Permalink
bug(job_modules): should be case insensitive
Browse files Browse the repository at this point in the history
and now they are. as of this fix

see pep https://peps.python.org/pep-0508/
  • Loading branch information
wiwichips committed Sep 6, 2024
1 parent 35494a0 commit d01e022
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 10 additions & 1 deletion dcp/api/job_modules.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
"""
Converts Job modules (Pyodide core packages) for Pyodide worktime.
Author: Severn Lortie <[email protected]>
Author:
Severn Lortie <[email protected]>
Will Pringle <[email protected]>
Date: Aug 2024
"""

from ..resources import pyodide_lock_repodata_json as repodata

def pyodide_full_module_dependencies(modules):
"""Generates a list of every required pip package."""
dependencies = []

# PIP packages are case insensitive, see pep-0508
modules = list(map(lambda x: x.lower(), modules))

for module in modules:
if not module in repodata['packages']:
raise Exception('Usage of unsupported module "${module}". "${module}" is currently not supported by the Pyodide Worktime.')
Expand All @@ -25,12 +32,14 @@ def pyodide_full_module_dependencies(modules):

# TODO: do we need this?
def convert_modules_to_requires(modules):
"""Convert pip module package names to dcp package names."""
dcp_packages = []
for pyodide_module in modules:
dcp_packages.append(f"pyodide-{pyodide_module}/pyodide-{pyodide_module}.js")
return dcp_packages

def convert_module_names_to_import_names(modules):
"""Converts pip module package name to import names."""
imports = []
for module in modules:
imports.extend(repodata['packages'][module]['imports']) # 1 or more unique imports per module
Expand Down
2 changes: 0 additions & 2 deletions dcp/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
file_dirn = os.path.dirname(__file__)
file_path = os.path.join(file_dirn, 'pyodide-lock.json')

print(file_path)

with open(file_path, 'r') as file:
pyodide_lock_repodata_json = json.load(file)

Expand Down

0 comments on commit d01e022

Please sign in to comment.