Skip to content

feat: support pyproject.toml and uv in python extension (#3118)#3177

Closed
deepshekhardas wants to merge 1 commit intotriggerdotdev:mainfrom
deepshekhardas:feat/pyproject-toml-support
Closed

feat: support pyproject.toml and uv in python extension (#3118)#3177
deepshekhardas wants to merge 1 commit intotriggerdotdev:mainfrom
deepshekhardas:feat/pyproject-toml-support

Conversation

@deepshekhardas
Copy link

Summary

Modern Python projects are increasingly adopting pyproject.toml for dependency management and project configuration, often using faster tools like uv. The current Trigger.dev Python extension only supports requirements.txt or inline requirements.

This PR adds support for pyproject.toml and the optional use of the uv package manager during the build process.

Closes #3118

Changes

  • Added pyprojectFile and useUv to PythonOptions.
  • Updated the Python build extension to:
    • Install uv if useUv is set to true.
    • Detect and use pyproject.toml for dependency installation (pip install . or uv pip install .).
    • Fallback to requirements.txt or inline requirements with uv support if enabled.

Testing

  • Manually verified the generated Dockerfile instructions in the build extension logic.
  • Verified that uv installation and usage instructions are correctly injected into the build layers.

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

⚠️ No Changeset found

Latest commit: 242abdf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Hi @deepshekhardas, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e16c6a79-b7d1-4252-9474-c7b64554fa94

📥 Commits

Reviewing files that changed from the base of the PR and between c013322 and 242abdf.

📒 Files selected for processing (1)
  • packages/python/src/extension.ts

Walkthrough

The PR introduces optional UV package manager support to the Python extension. Two new configuration options are added to PythonOptions: pyprojectFile for specifying a pyproject.toml file path, and useUv to enable UV-based dependency installation. The implementation adds validation for the pyproject file, conditionally injects UV installation during build initialization, and modifies the dependency installation workflow to support both uv-based and standard pip installation methods for both requirements files and pyproject-based configurations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot closed this Mar 5, 2026
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +61 to +66
if (this.options.pyprojectFile) {
assert(
fs.existsSync(this.options.pyprojectFile),
`pyproject.toml not found: ${this.options.pyprojectFile}`
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing mutual-exclusion validation for pyprojectFile against requirements/requirementsFile

The constructor validates that requirements and requirementsFile cannot both be specified (line 46-48), but pyprojectFile is never checked against either option. Because onBuildComplete uses an if/else if chain (requirementsFilepyprojectFilerequirements), conflicting combinations are silently resolved by priority rather than flagged as errors. For example, passing { pyprojectFile: "pyproject.toml", requirementsFile: "requirements.txt" } silently ignores pyprojectFile, and passing { pyprojectFile: "pyproject.toml", requirements: ["numpy"] } silently ignores requirements. This is inconsistent with the existing assertion pattern that explicitly rejects conflicting options.

Suggested change
if (this.options.pyprojectFile) {
assert(
fs.existsSync(this.options.pyprojectFile),
`pyproject.toml not found: ${this.options.pyprojectFile}`
);
}
if (this.options.pyprojectFile) {
assert(
!(this.options.requirements || this.options.requirementsFile),
"Cannot specify pyprojectFile together with requirements or requirementsFile"
);
assert(
fs.existsSync(this.options.pyprojectFile),
`pyproject.toml not found: ${this.options.pyprojectFile}`
);
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +160 to +168
// Add a layer to the build that installs the dependencies
context.addLayer({
id: "python-dependencies",
image: {
instructions: splitAndCleanComments(`
# Copy the pyproject file
COPY ${this.options.pyprojectFile} .
# Install dependencies
${this.options.useUv ? "RUN uv pip install ." : "RUN pip install ."}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 pip install . with only pyproject.toml may fail at Docker build time

When using the pyprojectFile path (line 149-174), only the pyproject.toml file itself is copied into the container via addAdditionalFilesToBuild. The subsequent RUN pip install . (or uv pip install .) expects a full installable Python package directory — at minimum the source code referenced by the pyproject config. Unless the user also copies the rest of their project via the scripts option or another mechanism, this Docker layer will fail at build time. This isn't necessarily a code bug (the user controls what gets copied), but the ergonomics are surprising — most users would expect pyprojectFile to "just work" like requirementsFile does. Consider documenting this requirement or automatically including sibling files.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support pyproject.toml + entry point for python projects

1 participant