@@ -14,24 +14,24 @@ This extension introduces the <code>pythonExtension</code> build extension, whic
1414 - <code >run</code >: Executes Python commands with proper environment setup.
1515 - <code >runInline</code >: Executes inline Python code directly from Node.
1616 - <code >runScript</code >: Executes standalone <code >.py</code > script files.
17- - ** Custom Python Path:** In development, you can configure <code >pythonBinaryPath </code > to point to a custom Python installation.
17+ - ** Custom Python Path:** In development, you can configure <code >devPythonBinaryPath </code > to point to a custom Python installation.
1818
1919## Usage
2020
21211 . Add the extension to your <code >trigger.config.ts</code > file:
2222
2323``` typescript
2424import { defineConfig } from " @trigger.dev/sdk/v3" ;
25- import pythonExtension from " @trigger.dev/python/extension" ;
25+ import { pythonExtension } from " @trigger.dev/python/extension" ;
2626
2727export default defineConfig ({
2828 project: " <project ref>" ,
2929 build: {
3030 extensions: [
3131 pythonExtension ({
3232 requirementsFile: " ./requirements.txt" , // Optional: Path to your requirements file
33- pythonBinaryPath: path . join ( rootDir , ` . venv/bin/python` ) , // Optional: Custom Python binary path
34- scripts: [" my_script .py" ], // List of Python scripts to include
33+ devPythonBinaryPath: " . venv/bin/python" , // Optional: Custom Python binary path
34+ scripts: [" src/python/**/* .py" ], // Glob pattern for Python scripts
3535 }),
3636 ],
3737 },
@@ -40,13 +40,34 @@ export default defineConfig({
4040
41412 . (Optional) Create a <code >requirements.txt</code > file in your project root with the necessary Python dependencies.
4242
43+ ``` plaintext title="requirements.txt"
44+ pandas==1.3.3
45+ numpy==1.21.2
46+ ```
47+
48+ ``` typescript title="trigger.config.ts"
49+ import { defineConfig } from " @trigger.dev/sdk/v3" ;
50+ import { pythonExtension } from " @trigger.dev/python/extension" ;
51+
52+ export default defineConfig ({
53+ project: " <project ref>" ,
54+ build: {
55+ extensions: [
56+ pythonExtension ({
57+ requirementsFile: " ./requirements.txt" ,
58+ }),
59+ ],
60+ },
61+ });
62+ ```
63+
43643 . Execute Python scripts within your tasks using one of the provided functions:
4465
4566### Running a Python Script
4667
4768``` typescript
4869import { task } from " @trigger.dev/sdk/v3" ;
49- import python from " @trigger.dev/python" ;
70+ import { python } from " @trigger.dev/python" ;
5071
5172export const myScript = task ({
5273 id: " my-python-script" ,
@@ -61,15 +82,15 @@ export const myScript = task({
6182
6283``` typescript
6384import { task } from " @trigger.dev/sdk/v3" ;
64- import python from " @trigger.dev/python" ;
85+ import { python } from " @trigger.dev/python" ;
6586
6687export const myTask = task ({
6788 id: " to_datetime-task" ,
6889 run : async () => {
6990 const result = await python .runInline (`
7091import pandas as pd
7192
72- pandas .to_datetime("${+ new Date () / 1000 }")
93+ pd .to_datetime("${+ new Date () / 1000 }")
7394` );
7495 return result .stdout ;
7596 },
@@ -80,7 +101,7 @@ pandas.to_datetime("${+new Date() / 1000}")
80101
81102``` typescript
82103import { task } from " @trigger.dev/sdk/v3" ;
83- import python from " @trigger.dev/python" ;
104+ import { python } from " @trigger.dev/python" ;
84105
85106export const pythonVersionTask = task ({
86107 id: " python-version-task" ,
@@ -94,7 +115,6 @@ export const pythonVersionTask = task({
94115## Limitations
95116
96117- This is a ** partial implementation** and does not provide full Python support as an execution runtime for tasks.
97- - Only basic Python script execution is supported; scripts are not automatically copied to staging/production containers.
98118- Manual intervention may be required for installing and configuring binary dependencies in development environments.
99119
100120## Additional Information
0 commit comments