From 0d14bc2ec536e3e39a244e2dbf164087afcb2531 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 6 Jul 2023 21:14:47 +0000 Subject: [PATCH 1/8] chore: add debugger configurations for VSCode --- .vscode/launch.json | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..16065fb5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,38 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Debug", + "type": "cppdbg", + "request": "launch", + "program": "python", + "args": [ + "${file}" + ], + "pipeTransport": { + "pipeCwd": "${workspaceFolder}", + "pipeProgram": "poetry", + "quoteArgs": false, + "pipeArgs": [ + "run" + ], + }, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + }, + ] +} \ No newline at end of file From 2b18db2c2d7c362f8b8da394ddeab0a945a17b62 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 6 Jul 2023 23:39:27 +0000 Subject: [PATCH 2/8] chore: add tasks configuration for VSCode --- .vscode/tasks.json | 86 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..bafe0068 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,86 @@ +{ + "tasks": [ + // + // Build + // + { + "label": "Build pminit", + "type": "process", + "command": "poetry", + "args": [ + "run", + "pip", + "install", + "--verbose", + "python/pminit", + ], + }, + { + "label": "Build pythonmonkey", + "type": "cppbuild", + "command": "poetry", + "args": [ + "run", + "pip", + "install", + "--verbose", + ".", + ], + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "Build", + "dependsOrder": "sequence", + "dependsOn": [ + "Build pminit", + "Build pythonmonkey", + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + // + // Test + // + { + "label": "Install development dependencies", + "type": "process", + "command": "poetry", + "args": [ + "install", + "--no-root", + "--only=dev" + ], + }, + { + "label": "Run pytest", + "type": "process", + "command": "poetry", + "args": [ + "run", + "pytest", + "./tests/python" + ], + }, + { + "label": "Test", + "dependsOrder": "sequence", + "dependsOn": [ + "Install development dependencies", + "Run pytest", + ], + "group": { + "kind": "test", + "isDefault": true + } + }, + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [], + "version": "2.0.0" +} \ No newline at end of file From 0f7b0caf4753132cc77b827d5b05b49a96cefbc5 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 7 Jul 2023 00:25:25 +0000 Subject: [PATCH 3/8] chore: add `Setup SpiderMonkey` task for VSCode --- .vscode/tasks.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bafe0068..2dbd526c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,5 +1,13 @@ { "tasks": [ + // + // Setup + // + { + "label": "Setup SpiderMonkey", + "type": "process", + "command": "./setup.sh", + }, // // Build // From f1d22eba6a6dd3af6fe487d9f19e256845296b73 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Fri, 7 Jul 2023 00:33:56 +0000 Subject: [PATCH 4/8] docs(README): add instructions for VSCode tasks and debugging steps --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b0d15d9c..4e38cc3b 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,10 @@ this package to execute our complex `dcp-client` library, which is written in JS - JS TypedArrays coerce to Python TypeArrays ## Build Instructions -1. You will need the following installed (which can be done automatically by running ``./setup.sh``): + +Read this if you want to build a local version. + +1. You will need the following installed (which can be done automatically by running `./setup.sh`): - cmake - doxygen - graphviz @@ -59,11 +62,15 @@ this package to execute our complex `dcp-client` library, which is written in JS 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. +If you are using VSCode, you can just press Ctrl + Shift + B to [run build task](https://code.visualstudio.com/docs/editor/tasks#_custom-tasks) - We have [the `tasks.json` file configured for you](.vscode/tasks.json). + ## Running tests 1. Compile the project 2. Install development dependencies: `poetry install --no-root --only=dev` 3. From the root directory, run `poetry run pytest ./tests/python` +For VSCode users, similar to the Build Task, we have a Test Task ready to use. + ## Using the library ### Install from [PyPI](https://pypi.org/project/pythonmonkey/) @@ -98,6 +105,14 @@ Type "help", "copyright", "credits" or "license" for more information. Alternatively, you can build a `wheel` package by running `poetry build --format=wheel`, and install it by `pip install dist/*.whl`. +## Debugging Steps + +1. [build the project locally](#build-instructions) +2. To use gdb, run `poetry run gdb python`. +See [Python Wiki: DebuggingWithGdb](https://wiki.python.org/moin/DebuggingWithGdb) + +If you are using VSCode, it's more convenient to debug in [VSCode's built-in debugger](https://code.visualstudio.com/docs/editor/debugging). Simply press F5 on an open Python to start debugging - We have [the `launch.json` file configured for you](.vscode/launch.json). + ## Examples * [examples/](examples/) From a43fae40abb9917d48c1659315991ffbeb935fd6 Mon Sep 17 00:00:00 2001 From: Tom Wenzheng Tang Date: Mon, 10 Jul 2023 15:48:59 -0400 Subject: [PATCH 5/8] chore: remove `TODO.md` --- TODO.md | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 TODO.md diff --git a/TODO.md b/TODO.md deleted file mode 100644 index ee552898..00000000 --- a/TODO.md +++ /dev/null @@ -1,2 +0,0 @@ -### Project Setup Todo's -- cmake for all(reasonable) os's \ No newline at end of file From 41cb521261dd61e576f9bc011953420f92c00f50 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 10 Jul 2023 20:33:12 +0000 Subject: [PATCH 6/8] chore: change the Build Task to only run `poetry install` --- .vscode/tasks.json | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2dbd526c..3b1ce567 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,38 +12,14 @@ // Build // { - "label": "Build pminit", - "type": "process", - "command": "poetry", - "args": [ - "run", - "pip", - "install", - "--verbose", - "python/pminit", - ], - }, - { - "label": "Build pythonmonkey", + "label": "Build", "type": "cppbuild", "command": "poetry", "args": [ - "run", - "pip", "install", - "--verbose", - ".", ], "problemMatcher": [ "$gcc" - ] - }, - { - "label": "Build", - "dependsOrder": "sequence", - "dependsOn": [ - "Build pminit", - "Build pythonmonkey", ], "group": { "kind": "build", From 9391bc506db520b40fbcee58c5fc922868a4e087 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 10 Jul 2023 20:37:00 +0000 Subject: [PATCH 7/8] chore: run build before debugging in VSCode --- .vscode/launch.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 16065fb5..5f5e6ea3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,6 +17,7 @@ "run" ], }, + "preLaunchTask": "Build", "cwd": "${fileDirname}", "environment": [], "externalConsole": false, From f0108de5cb47101203815e207b14e807831edbdc Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Mon, 10 Jul 2023 23:06:01 +0000 Subject: [PATCH 8/8] fix: run Build Task if the VSCode C/C++ extension is not installed there is no registered task type 'cppbuild' --- .vscode/tasks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3b1ce567..fd317f4b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,7 +13,7 @@ // { "label": "Build", - "type": "cppbuild", + "type": "process", "command": "poetry", "args": [ "install",