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
@@ -155,15 +133,24 @@ The following mechanisms add to the set of **_excluded_ extensions**:
155
133
156
134
### Show all installed extensions
157
135
158
-
```bash
136
+
```batch
159
137
python3 -c "import duckdb; print(duckdb.sql('SELECT extension_name, installed, description FROM duckdb_extensions();'))"
160
138
```
161
139
162
140
## Development Environment
163
141
164
-
To set up the codebase for development you should run build duckdb as follows:
142
+
This section walks you through the following steps:
165
143
166
-
```bash
144
+
* Creating a CMake profile for development
145
+
* Debugging the Python extension code with lldb
146
+
147
+
You can do this either on the CLI or from an IDE. The documentation below shows the configuration for CLion, but you should be able to get it to work with other IDEs like VSCode as well.
148
+
149
+
### Debugging From the CLI
150
+
151
+
Run this to configure the CMake profile needed to debug on the CLI:
152
+
153
+
```batch
167
154
GEN=ninja BUILD_PYTHON=1 PYTHON_DEV=1 make debug
168
155
```
169
156
@@ -174,13 +161,11 @@ This will take care of the following:
174
161
175
162
Once the build completes, do a sanity check to make sure everything works:
After creating a debug build with `PYTHON_DEV` enabled, you should be able to get debugging going in an IDE that support `lldb`. Below are the instructions forCLion, but you should be able to get this goingin e.g. VSCode as well.
204
+
You should be able to get debugging going in an IDE that support `lldb`. Below are the instructions for CLion but you can copy the settings for your favorite IDE.
220
205
221
-
#### Configure the CMake Debug Profile
206
+
#### Configure a CMake Debug Profile
222
207
223
-
This is a prerequisite for debugging, and will enableIntellisense and clang-tidy by generating a `compile-commands.json` file so your IDE knows how to inspect the source code. It also makes sure your Python virtual env can be found by your IDE's cmake.
208
+
The following CMake profile enables Intellisense and clang-tidy by generating a `compile-commands.json` file so your IDE knows how to inspect the source code, and makes sure that the Python package will be built and installed in your Python virtual env.
224
209
225
-
Under `Settings | Build, Execution, Deployment | CMake` add the following CMake options:
Under Run -> Edit Configurations... create a new CMake Application. Use the following values:
235
-
* Name: Python Debug
236
-
* Target: `python_src` (it doesn't actually matter what you selecthere)
237
-
* Program arguments: `$FilePath$`
238
-
* Working directory: `$ProjectFileDir$`
226
+
***Name**: Python Debug
227
+
***Target**: `All targets`
228
+
***Executable**: `[ABS_PATH_TO_YOUR_VENV]/bin/python3` (careful: this is a symlink and sometimes an IDE might try and follow it and fill in the path to the actual executable, but that will not work)
229
+
***Program arguments**: `$FilePath$`
230
+
***Working directory**: `$ProjectFileDir$`
231
+
***Before Launch**: `Build` (this should already be set)
239
232
240
233
That should be enough: Save and close.
241
234
242
-
Now you can set a breakpoint in a C++ file. You then open your Python script in your editor and use this config to start a debug session.
235
+
Now you can set a breakpoint in a C++ file. You then open your Python script in your editor and use this config and run `Python Debug` in debug mode.
243
236
244
237
### Development and Stubs
245
238
@@ -250,7 +243,7 @@ Now you can set a breakpoint in a C++ file. You then open your Python script in
250
243
These stubs are important for autocomplete in many IDEs, as static-analysis based language servers can't introspect `duckdb`'s binary module.
251
244
252
245
To verify the stubs match the actual implementation:
253
-
```bash
246
+
```batch
254
247
python3 -m pytest tests/stubs
255
248
```
256
249
@@ -274,7 +267,7 @@ When directly interacting with python functions that return a `PyObject*`, such
274
267
275
268
If you've forked DuckDB you may run into trouble when building the Python package when you haven't pulled in the tags.
0 commit comments