magpylib-studio 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. magpylib_studio-0.1.0/.github/workflows/cd.yml +78 -0
  2. magpylib_studio-0.1.0/.github/workflows/ci.yml +62 -0
  3. magpylib_studio-0.1.0/.github/workflows/release.yml +84 -0
  4. magpylib_studio-0.1.0/.gitignore +11 -0
  5. magpylib_studio-0.1.0/.vscode/extensions.json +5 -0
  6. magpylib_studio-0.1.0/.vscode/launch.json +50 -0
  7. magpylib_studio-0.1.0/.vscode/tasks.json +26 -0
  8. magpylib_studio-0.1.0/CONTINUE.md +749 -0
  9. magpylib_studio-0.1.0/LICENSE +28 -0
  10. magpylib_studio-0.1.0/PKG-INFO +237 -0
  11. magpylib_studio-0.1.0/README.md +208 -0
  12. magpylib_studio-0.1.0/magpylib_studio/__init__.py +5 -0
  13. magpylib_studio-0.1.0/magpylib_studio/__main__.py +6 -0
  14. magpylib_studio-0.1.0/magpylib_studio/_version.py +24 -0
  15. magpylib_studio-0.1.0/magpylib_studio/expressions.py +255 -0
  16. magpylib_studio-0.1.0/magpylib_studio/importer.py +549 -0
  17. magpylib_studio-0.1.0/magpylib_studio/rpc.py +109 -0
  18. magpylib_studio-0.1.0/magpylib_studio/session.py +3062 -0
  19. magpylib_studio-0.1.0/magpylib_studio/style_compat.py +115 -0
  20. magpylib_studio-0.1.0/magpylib_studio/style_schemas.json +1524 -0
  21. magpylib_studio-0.1.0/pyproject.toml +48 -0
  22. magpylib_studio-0.1.0/sandbox/README.md +14 -0
  23. magpylib_studio-0.1.0/tests/test_session.py +2309 -0
  24. magpylib_studio-0.1.0/vscode-extension/.gitignore +4 -0
  25. magpylib_studio-0.1.0/vscode-extension/.vscode-test.mjs +31 -0
  26. magpylib_studio-0.1.0/vscode-extension/.vscodeignore +29 -0
  27. magpylib_studio-0.1.0/vscode-extension/CHANGELOG.md +55 -0
  28. magpylib_studio-0.1.0/vscode-extension/README.md +223 -0
  29. magpylib_studio-0.1.0/vscode-extension/eslint.config.mjs +62 -0
  30. magpylib_studio-0.1.0/vscode-extension/harness/check-contributions.js +138 -0
  31. magpylib_studio-0.1.0/vscode-extension/harness/check-webview-scripts.js +46 -0
  32. magpylib_studio-0.1.0/vscode-extension/harness/webview-harness.js +384 -0
  33. magpylib_studio-0.1.0/vscode-extension/media/field.css +6 -0
  34. magpylib_studio-0.1.0/vscode-extension/media/field.js +159 -0
  35. magpylib_studio-0.1.0/vscode-extension/media/icon.png +0 -0
  36. magpylib_studio-0.1.0/vscode-extension/media/icons/cuboid.svg +4 -0
  37. magpylib_studio-0.1.0/vscode-extension/media/icons/custom.svg +4 -0
  38. magpylib_studio-0.1.0/vscode-extension/media/icons/cylinder-segment.svg +5 -0
  39. magpylib_studio-0.1.0/vscode-extension/media/icons/cylinder.svg +4 -0
  40. magpylib_studio-0.1.0/vscode-extension/media/icons/dipole.svg +4 -0
  41. magpylib_studio-0.1.0/vscode-extension/media/icons/loop.svg +4 -0
  42. magpylib_studio-0.1.0/vscode-extension/media/icons/mesh.svg +4 -0
  43. magpylib_studio-0.1.0/vscode-extension/media/icons/polyline.svg +4 -0
  44. magpylib_studio-0.1.0/vscode-extension/media/icons/sensor.svg +4 -0
  45. magpylib_studio-0.1.0/vscode-extension/media/icons/sphere.svg +4 -0
  46. magpylib_studio-0.1.0/vscode-extension/media/icons/tetrahedron.svg +4 -0
  47. magpylib_studio-0.1.0/vscode-extension/media/inspector.css +40 -0
  48. magpylib_studio-0.1.0/vscode-extension/media/inspector.js +602 -0
  49. magpylib_studio-0.1.0/vscode-extension/media/jsconfig.json +13 -0
  50. magpylib_studio-0.1.0/vscode-extension/media/magnet.svg +6 -0
  51. magpylib_studio-0.1.0/vscode-extension/media/studio.css +8 -0
  52. magpylib_studio-0.1.0/vscode-extension/media/studio.js +76 -0
  53. magpylib_studio-0.1.0/vscode-extension/media/variables.css +17 -0
  54. magpylib_studio-0.1.0/vscode-extension/media/variables.js +188 -0
  55. magpylib_studio-0.1.0/vscode-extension/package-lock.json +3136 -0
  56. magpylib_studio-0.1.0/vscode-extension/package.json +1586 -0
  57. magpylib_studio-0.1.0/vscode-extension/schemas/magpy-scene.schema.json +228 -0
  58. magpylib_studio-0.1.0/vscode-extension/src/engineClient.ts +117 -0
  59. magpylib_studio-0.1.0/vscode-extension/src/extension.ts +2554 -0
  60. magpylib_studio-0.1.0/vscode-extension/src/historyView.ts +61 -0
  61. magpylib_studio-0.1.0/vscode-extension/src/inspectorView.ts +123 -0
  62. magpylib_studio-0.1.0/vscode-extension/src/sceneTree.ts +253 -0
  63. magpylib_studio-0.1.0/vscode-extension/src/test/extension.test.ts +386 -0
  64. magpylib_studio-0.1.0/vscode-extension/src/variablesView.ts +145 -0
  65. magpylib_studio-0.1.0/vscode-extension/src/webview.ts +29 -0
  66. magpylib_studio-0.1.0/vscode-extension/tsconfig.json +15 -0
  67. magpylib_studio-0.1.0/vscode-extension/walkthroughs/add-object.md +8 -0
  68. magpylib_studio-0.1.0/vscode-extension/walkthroughs/ask-copilot.md +12 -0
  69. magpylib_studio-0.1.0/vscode-extension/walkthroughs/field-view.md +7 -0
  70. magpylib_studio-0.1.0/vscode-extension/walkthroughs/load-example.md +14 -0
  71. magpylib_studio-0.1.0/vscode-extension/walkthroughs/open-studio.md +7 -0
  72. magpylib_studio-0.1.0/vscode-extension/walkthroughs/save-scene.md +8 -0
@@ -0,0 +1,78 @@
1
+ # Publishes the magpylib_studio engine to PyPI. Needs the same two things set
2
+ # up on the account side before the publish job can succeed: a PyPI Trusted
3
+ # Publisher for "magpylib-studio" linked to this repo/workflow/environment,
4
+ # and a GitHub environment named "pypi" here, restricted to tags matching v*.
5
+ #
6
+ # Triggered directly by the `v*` tag push, the same as release.yml — NOT by
7
+ # that workflow's release being published, and not by `workflow_run` either.
8
+ # Tried first: release.yml creates its release with the default GITHUB_TOKEN,
9
+ # and GitHub deliberately does not let a GITHUB_TOKEN-authored event trigger
10
+ # further workflows (or every push could chain into itself). `workflow_run`
11
+ # would dodge that, but then runs in the *branch* the workflow file lives on,
12
+ # not the tag — which the `pypi` environment's tag-only rule would then
13
+ # reject. A real tag push is the one trigger that is neither. Consequence:
14
+ # the two workflows no longer share a test run, so `test` below is this one's
15
+ # own gate rather than trusting release.yml's.
16
+ name: CD
17
+
18
+ on:
19
+ workflow_dispatch:
20
+ pull_request:
21
+ push:
22
+ branches: [main]
23
+ tags: ['v*']
24
+
25
+ concurrency:
26
+ group: ${{ github.workflow }}-${{ github.ref }}
27
+ cancel-in-progress: true
28
+
29
+ env:
30
+ FORCE_COLOR: 3
31
+
32
+ jobs:
33
+ test:
34
+ name: Engine tests
35
+ runs-on: ubuntu-latest
36
+
37
+ steps:
38
+ - uses: actions/checkout@v6
39
+ - uses: actions/setup-python@v5
40
+ with:
41
+ python-version: '3.13'
42
+ - run: pip install -e ".[dev]"
43
+ - run: python -m pytest -q
44
+
45
+ dist:
46
+ name: Distribution build
47
+ runs-on: ubuntu-latest
48
+
49
+ steps:
50
+ - uses: actions/checkout@v6
51
+ with:
52
+ fetch-depth: 0
53
+
54
+ - uses: hynek/build-and-inspect-python-package@v2
55
+
56
+ publish:
57
+ needs: [test, dist]
58
+ name: Publish to PyPI
59
+ environment: pypi
60
+ permissions:
61
+ id-token: write
62
+ attestations: write
63
+ contents: read
64
+ runs-on: ubuntu-latest
65
+ if: github.ref_type == 'tag'
66
+
67
+ steps:
68
+ - uses: actions/download-artifact@v8
69
+ with:
70
+ name: Packages
71
+ path: dist
72
+
73
+ - name: Generate artifact attestation for sdist and wheel
74
+ uses: actions/attest-build-provenance@v4.1.0
75
+ with:
76
+ subject-path: "dist/*"
77
+
78
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,62 @@
1
+ # Everything green on a machine that is not the one it was written on.
2
+ #
3
+ # Two jobs because they fail for different reasons: the engine against both
4
+ # magpylib versions (the README claims it works with either, and that claim
5
+ # was only ever checked by hand), and the extension end to end in a real VS
6
+ # Code — which needs the engine installed, since that is what it drives.
7
+ name: CI
8
+
9
+ on:
10
+ push:
11
+ branches: [main]
12
+ pull_request:
13
+ workflow_dispatch:
14
+
15
+ jobs:
16
+ engine:
17
+ name: engine (magpylib ${{ matrix.magpylib }})
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ # `released` is what `pip install magpylib-studio` gets anyone;
23
+ # `property-tree` is the branch that adds the first-class style API.
24
+ # style_compat.py exists to make both work, so both are tested.
25
+ magpylib: [released, property-tree]
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: actions/setup-python@v5
29
+ with:
30
+ python-version: '3.13'
31
+ - run: pip install -e ".[dev]"
32
+ - name: Switch to the property-tree branch
33
+ if: matrix.magpylib == 'property-tree'
34
+ run: pip install "magpylib @ git+https://github.com/magpylib/magpylib@feat/improve-style"
35
+ - run: python -m pytest -q
36
+
37
+ extension:
38
+ name: extension
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+ - uses: actions/setup-python@v5
43
+ with:
44
+ python-version: '3.13'
45
+ - uses: actions/setup-node@v4
46
+ with:
47
+ node-version: '20'
48
+ cache: npm
49
+ cache-dependency-path: vscode-extension/package-lock.json
50
+ # The extension spawns `python -m magpylib_studio`; with no .venv here it
51
+ # falls through to python3 on PATH, which is this one.
52
+ - run: pip install -e .
53
+ - name: Install
54
+ working-directory: vscode-extension
55
+ run: npm ci
56
+ - name: Compile, lint and check contributions
57
+ working-directory: vscode-extension
58
+ run: npm run compile
59
+ # VS Code needs a display even headless.
60
+ - name: Integration tests
61
+ working-directory: vscode-extension
62
+ run: xvfb-run -a npm test
@@ -0,0 +1,84 @@
1
+ # Tag a version, get an installable .vsix on the release page.
2
+ #
3
+ # git tag v0.0.1 && git push origin v0.0.1
4
+ #
5
+ # This is deliberately *not* Marketplace publishing. That needs a publisher id
6
+ # on the Marketplace and a PAT in secrets, and — more to the point — the engine
7
+ # on PyPI, so that installing the extension is not followed by "now go and pip
8
+ # install this git URL". Until then a release asset is the honest channel:
9
+ #
10
+ # code --install-extension magpylib-studio-vscode-0.0.1.vsix
11
+ name: Release
12
+
13
+ on:
14
+ push:
15
+ tags: ['v*']
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: write # to create the release and attach the .vsix
20
+
21
+ jobs:
22
+ release:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: '3.13'
29
+ - uses: actions/setup-node@v4
30
+ with:
31
+ node-version: '20'
32
+ cache: npm
33
+ cache-dependency-path: vscode-extension/package-lock.json
34
+ - run: pip install -e ".[dev]"
35
+
36
+ # Shipping an untested build is the one thing a release must not do.
37
+ - name: Engine tests
38
+ run: python -m pytest -q
39
+ - name: Install
40
+ working-directory: vscode-extension
41
+ run: npm ci
42
+ - name: Integration tests
43
+ working-directory: vscode-extension
44
+ run: xvfb-run -a npm test
45
+
46
+ # package.json's version is what vsce embeds in the .vsix, and it does
47
+ # not follow the tag on its own — so a v0.1.0 tag would otherwise still
48
+ # ship a .vsix internally labelled 0.0.1. Marketplace versions can't
49
+ # carry a pre-release suffix, so a v0.1.0rc1-style tag is left alone
50
+ # and the .vsix keeps whatever the last real release set.
51
+ - name: Sync extension version to the release tag
52
+ working-directory: vscode-extension
53
+ run: |
54
+ version="${GITHUB_REF_NAME#v}"
55
+ if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
56
+ npm version "$version" --no-git-tag-version --allow-same-version
57
+ else
58
+ echo "::notice::${GITHUB_REF_NAME} is a pre-release tag; leaving package.json version as the last synced release"
59
+ fi
60
+
61
+ # vsce runs vscode:prepublish, which copies the LICENSE in and compiles.
62
+ - name: Package
63
+ working-directory: vscode-extension
64
+ run: npx @vscode/vsce package --out "${{ github.workspace }}/magpylib-studio-${{ github.ref_name }}.vsix"
65
+
66
+ - uses: softprops/action-gh-release@v2
67
+ with:
68
+ files: magpylib-studio-*.vsix
69
+ generate_release_notes: true
70
+ body: |
71
+ Install into VS Code:
72
+
73
+ ```sh
74
+ code --install-extension magpylib-studio-${{ github.ref_name }}.vsix
75
+ ```
76
+
77
+ The extension is the UI only — it drives a Python engine, which
78
+ has to be installed separately into an interpreter it can find:
79
+
80
+ ```sh
81
+ pip install "magpylib-studio @ git+https://github.com/magpylib/magpylib-studio.git"
82
+ ```
83
+
84
+ Then set `magpylib-studio.pythonPath` to that interpreter.
@@ -0,0 +1,11 @@
1
+ # Copied from the repo root at package time (npm run license) so the VSIX
2
+ # carries it. Not tracked: one licence file, no second copy to drift.
3
+ vscode-extension/LICENSE
4
+
5
+ .venv/
6
+ __pycache__/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ *.pyc
11
+ magpylib_studio/_version.py
@@ -0,0 +1,5 @@
1
+ {
2
+ // The extension folder used to carry its own recommendation, for the TSLint
3
+ // plugin — deprecated in 2019 in favour of ESLint, which this repo now has.
4
+ "recommendations": ["dbaeumer.vscode-eslint", "ms-python.python"]
5
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ // F5 from the repo root, which is where both halves live: the engine is a
3
+ // Python package here, the extension is a folder inside it. There is no
4
+ // second window to open first — that was an artifact of the only launch
5
+ // config living in vscode-extension/, and it is gone.
6
+ //
7
+ // The host opens `sandbox/` rather than nothing, so that its workspace —
8
+ // and therefore the extension storage holding the script tab's scene.py —
9
+ // is the same one every time. See sandbox/README.md.
10
+ "version": "0.2.0",
11
+ "configurations": [
12
+ {
13
+ "name": "Run Extension",
14
+ "type": "extensionHost",
15
+ "request": "launch",
16
+ "runtimeExecutable": "${execPath}",
17
+ "args": [
18
+ "${workspaceFolder}/sandbox",
19
+ "--extensionDevelopmentPath=${workspaceFolder}/vscode-extension"
20
+ ],
21
+ "outFiles": ["${workspaceFolder}/vscode-extension/out/**/*.js"],
22
+ "preLaunchTask": "npm: compile"
23
+ },
24
+ {
25
+ // Same host, without rebuilding first — for when tsc is already
26
+ // watching and you just want the window back.
27
+ "name": "Run Extension (no build)",
28
+ "type": "extensionHost",
29
+ "request": "launch",
30
+ "runtimeExecutable": "${execPath}",
31
+ "args": [
32
+ "${workspaceFolder}/sandbox",
33
+ "--extensionDevelopmentPath=${workspaceFolder}/vscode-extension"
34
+ ],
35
+ "outFiles": ["${workspaceFolder}/vscode-extension/out/**/*.js"]
36
+ },
37
+ {
38
+ "name": "Extension Tests",
39
+ "type": "extensionHost",
40
+ "request": "launch",
41
+ "runtimeExecutable": "${execPath}",
42
+ "args": [
43
+ "--extensionDevelopmentPath=${workspaceFolder}/vscode-extension",
44
+ "--extensionTestsPath=${workspaceFolder}/vscode-extension/out/test"
45
+ ],
46
+ "outFiles": ["${workspaceFolder}/vscode-extension/out/test/**/*.js"],
47
+ "preLaunchTask": "npm: compile"
48
+ }
49
+ ]
50
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ // "npm: compile" is what the launch config waits for, so F5 never starts a
3
+ // host on stale JavaScript. It runs tsc *and* the webview script check, so
4
+ // a panel that cannot parse fails here rather than showing up blank.
5
+ "version": "2.0.0",
6
+ "tasks": [
7
+ {
8
+ "type": "npm",
9
+ "script": "compile",
10
+ "path": "vscode-extension",
11
+ "group": "build",
12
+ "problemMatcher": ["$tsc"],
13
+ "label": "npm: compile",
14
+ "detail": "tsc -p ./ && node harness/check-webview-scripts.js"
15
+ },
16
+ {
17
+ "type": "npm",
18
+ "script": "watch",
19
+ "path": "vscode-extension",
20
+ "group": "build",
21
+ "isBackground": true,
22
+ "problemMatcher": ["$tsc-watch"],
23
+ "label": "npm: watch"
24
+ }
25
+ ]
26
+ }