Skip to content

Commit 301fa37

Browse files
authored
Merge pull request #80 from Distributive-Network/Xmader/chore/improve-pminit
Improve developer experience
2 parents 7792a23 + c2ff52c commit 301fa37

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ this package to execute our complex `dcp-client` library, which is written in JS
5757
- [Poetry](https://python-poetry.org/docs/#installation)
5858
- [poetry-dynamic-versioning](https://github.com/mtkennerly/poetry-dynamic-versioning)
5959

60-
2. Run `poetry run pip install --verbose python/pminit ./`. This command automatically compiles the project and installs the project as well as dependencies into the poetry virtualenv.
60+
2. Run `poetry install`. This command automatically compiles the project and installs the project as well as dependencies into the poetry virtualenv.
6161

6262
## Running tests
6363
1. Compile the project

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ numpy = [
5555
{version = "^2.0.0.dev0", allow-prereleases = true, source = "anaconda", python = "3.12.*"},
5656
{version = "^1.24.3", python = "<3.12"},
5757
]
58+
pminit = { path = "./python/pminit", develop = true }
5859

5960

6061
[[tool.poetry.source]]

python/pythonmonkey/require.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@
2626
import sys, os
2727
from typing import Union, Dict
2828
import importlib
29+
import importlib.util
2930
from importlib import machinery
3031
import inspect
3132
import functools
3233

3334
from . import pythonmonkey as pm
35+
node_modules = os.path.abspath(
36+
os.path.join(
37+
importlib.util.find_spec("pminit").submodule_search_locations[0],
38+
"..",
39+
"pythonmonkey",
40+
"node_modules"
41+
)
42+
)
3443

3544
# Add some python functions to the global python object for code in this file to use.
3645
globalThis = pm.eval("globalThis;");
@@ -183,7 +192,7 @@ def existsSync(filename: str) -> bool:
183192
# require and exports symbols injected from the bootstrap object above. Current PythonMonkey bugs
184193
# prevent us from injecting names properly so they are stolen from trail left behind in the global
185194
# scope until that can be fixed.
186-
with open(os.path.dirname(__file__) + "/node_modules/ctx-module/ctx-module.js", "r") as ctxModuleSource:
195+
with open(node_modules + "/ctx-module/ctx-module.js", "r") as ctxModuleSource:
187196
initCtxModule = pm.eval("""'use strict';
188197
(function moduleWrapper_forCtxModule(broken_require, broken_exports)
189198
{

0 commit comments

Comments
 (0)