You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+58-20
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# py: minimal python3 object for max
1
+
# py/js: python3 objects for max
2
2
3
-
An attempt to make a simple (and extensible) max external for python3
3
+
Simple (and extensible) python3 externals for max accessible via patch or js objects
4
4
5
-
repo - https://github.com/shakfu/py
5
+
repo - https://github.com/shakfu/py-js
6
6
7
7
8
8
## Summary
@@ -17,9 +17,9 @@ patchers
17
17
py_repl : a basic single line repl for py
18
18
py_repl_plus : embeds a py object in a py_repl
19
19
20
-
py interpreter object
20
+
py max external
21
21
attributes
22
-
name : unique name
22
+
name : unique object name
23
23
file : file to load into editor
24
24
autoload : load file at start
25
25
pythonpath : add path to python sys.path
@@ -57,27 +57,56 @@ py interpreter object
57
57
left outlet : primary output (anything)
58
58
middle outlet : bang on failure
59
59
right outlet : bang on success
60
+
61
+
62
+
pyjs max external (jsextension)
63
+
attributes
64
+
name : unique object name
65
+
file : file to load in object namespace
66
+
pythonpath : add path to python sys.path
67
+
debug : switch debug logging on/off
68
+
69
+
methods
70
+
core
71
+
code <expr|stmt> : eval/exec/import python code (see above)
72
+
execfile <path> : python 'execfile' semantics
73
+
74
+
60
75
```
61
76
62
77
## Overview
63
78
64
-
The `py` object provides a minimal, high level two-way interface between max and python in a way that feels natural to both languages.
79
+
`py/js`, started out as an attempt (during a covid-19 lockdown), to get a basic python3 external for max, and then evolved into a flexible framework for using python3 in max.
80
+
81
+
There are two implementation 'flavours':
82
+
83
+
1. The `py` external provides a minimal, high level two-way interface between max and python in a way that feels natural to both languages.
84
+
85
+
2. The `pyjs` max jsextension provides a `PyJS` class for the `js` object, which makes available a python intepreter which works nicely with javascript code. This 'flavour' is new, and still under development, so documentation will be minimal. The
86
+
87
+
In addition there are essentially 3 deployment variations:
88
+
89
+
1.`py` external or `pyjs` jsextension which links to a system installed python (homebrew, builtin python, or custom system installed.) This has the benefit of re-using your existing libraries. This is the default option.
65
90
66
-
It really is conceived as a flexible framework which can be customized depending on the requirement.
91
+
2.`py` external or `pyjs` jsextension in a Max package: in this variation, a dedicated python distribution (zipped or otherwise is placed in the `support` folder of the `py/js` package (or any other package) is linked to the `py` external or `pyjs` extension (or both). This can possibly make it usable in standalones (untested).
67
92
68
-
To this end there are essentially 3 deployment flavours:
93
+
3.`py` external or `pyjs` jsextension as a container for a python distribution. In this variation, a whole python distribution (zipped or otherwise) is stored inside the external/jsextension object, which can makes it very portable and usable in standalones.
69
94
70
-
1.`py` external which links to a system installed python (homebrew, builtin python, or custom system installed.) This has the benefit of re-using your existing libraries. This is the default option.
71
95
72
-
2.`py` external in a Max package: in this variation, a dedicated python distribution (zipped or otherwise is placed in the `support` folder of the `py` package (or any other package) is linked to the `py` external. This can possibly make it usable in standalones (untested).
96
+
Deployment Scenario | `py` | `pyjs`
97
+
:------------------- | :--: | :--------:
98
+
Link to sys python | x | x
99
+
Embed in package | x | untested
100
+
Embed in external | x | untested
73
101
74
-
3.`py` external as a container for a python distribution. In this variation, a whole python distribution (zipped or otherwise) is stored inside the external object, which can make it very portable and usable in standalones.
102
+
In addition, to the deployment variations above, onc can choose to use the cython-generated max c-api wrapper or not, which allows regular python code to directly access the max-c-api and script Max objects.
75
103
76
104
77
-
In addition, to the variations above, onc can choose to use the cython-generated max c-api wrapper or not, which allows regular python to script Max objects.
78
105
79
-
Otherwise using plain-vanilla python in Max is also quite usable due to the availability of the following methods:
106
+
### Key Features
107
+
80
108
109
+
The more mature `py` external has the following c-level methods:
The `code` method (also available the `py` object in a more experimental category) which can import/exec/eval python code is 'core' in this implementation.
101
137
102
138
103
139
#### Core
@@ -300,7 +336,10 @@ The style used in this project is specified in the `.clang-format` file.
300
336
301
337
## BUGS
302
338
303
-
-[ ] Sending from the `api` can make max unstable. Keep it simple and investigate.
339
+
-[ ] no-return ops in`pyjs` such as `exec` and `import` somehow make java assume an error has occured.
340
+
341
+
-[ ]`api` object won't reload if a patch is closed (i.e. PyFinalize) and new one opened. Requires a restart of Max. (Python bug which is being worked on).
342
+
304
343
305
344
## TODO
306
345
@@ -309,6 +348,7 @@ The style used in this project is specified in the `.clang-format` file.
@@ -329,12 +369,8 @@ The style used in this project is specified in the `.clang-format` file.
329
369
330
370
### Future Experiments
331
371
332
-
-[ ] Convert `py` into a `js` extension class
333
-
- proof of concept done, but requires a different 'nobox' type of class and data passing via arrays and attributes instead of outlets. But can be done!
334
-
335
-
-[ ] Try to launch an ipython shell somehow
372
+
-[ ] Try to integrate an ipython shell somehow
336
373
337
-
-[ ] try to build a cython extension type as a max external class (-:
338
374
339
375
## CHANGELOG
340
376
@@ -347,6 +383,8 @@ The style used in this project is specified in the `.clang-format` file.
347
383
348
384
##### Core
349
385
386
+
-[x] Convert `py` into a `jsextension` class
387
+
350
388
-[x] create new `py_anything` with heuristics to decide whether to delegate to `py_call` or `py_code`.
351
389
352
390
-[x] add `autoload` attribute to trigger autoload (`load` msg) of code editor code
0 commit comments