Skip to content

Commit 2b99eeb

Browse files
committed
fix(pmpm): fix importing pmpm for post-install-hook
1 parent fb4b0af commit 2b99eeb

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

Diff for: python/pminit/post-install-hook.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
import os
2-
import sys
3-
import importlib
4-
import importlib.util
2+
import pmpm
53

64
WORK_DIR = os.path.join(
75
os.path.realpath(os.path.dirname(__file__)),
86
"pythonmonkey"
97
)
108

11-
def import_file(module_name: str, file_path: str):
12-
"""
13-
Import a Python file from its relative path directly.
14-
15-
See https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
16-
"""
17-
spec = importlib.util.spec_from_file_location(module_name, file_path)
18-
module = importlib.util.module_from_spec(spec) # type: ignore
19-
sys.modules[module_name] = module
20-
spec.loader.exec_module(module) # type: ignore
21-
return module
22-
239
def main():
24-
pmpm = import_file("pmpm", os.path.join(os.path.dirname(__file__), "./pmpm.py")) # from . import pmpm
2510
pmpm.main(WORK_DIR) # cd pythonmonkey && npm i
2611

2712
if __name__ == "__main__":

Diff for: python/pminit/pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ authors = [
99
"Hamada Gasmallah <[email protected]>"
1010
]
1111
include = [
12+
"pmpm.py",
1213
# Install extra files into the pythonmonkey package
1314
"pythonmonkey/package*.json",
1415
{ path = "pythonmonkey/node_modules/**/*", format = "wheel" },

0 commit comments

Comments
 (0)