Skip to content

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

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)#3176
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.

@github-actions github-actions bot closed this Mar 5, 2026
@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: 829892a1-9d15-4d49-b542-269600047bf4

📥 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 changes add support for pyproject.toml-based Python dependency management to the extension. Two new optional fields are introduced to PythonOptions: pyprojectFile (string) and useUv (boolean). When pyprojectFile is provided, its existence is validated and the file is copied into the container for dependency installation using either uv pip or standard pip. A new python-dependencies layer is created for pyproject-based workflows. The changes also conditionally inject uv installation in build steps and extend both requirements.txt and pyproject.toml installation paths to optionally use uv for package management.

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.

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 4 potential issues.

Open in Devin Review

Copy link
Contributor

Choose a reason for hiding this comment

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

🚩 Pre-existing: requirementsFile warning always fires spuriously

In onBuildComplete at lines 114-119, there's a warning logged when both requirementsFile and requirements are set. However, the constructor at lines 51-58 always sets this.options.requirements from the file contents when requirementsFile is provided. The assert at line 46-48 prevents both from being user-specified simultaneously. This means the warning at line 115-118 will fire every time requirementsFile is used, even though the requirements array was set by the constructor itself, not by the user. The warning message ('requirements will be ignored') is misleading in this context. This is pre-existing and not introduced by this PR.

(Refers to lines 114-119)

Open in Devin Review

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

Copy link
Contributor

Choose a reason for hiding this comment

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

🚩 Missing changeset for public package modification

The CLAUDE.md and CONTRIBUTING.md both state that modifications to any public package (packages/*) require a changeset via pnpm run changeset:add. This PR modifies packages/python/src/extension.ts (adding new pyprojectFile and useUv options) but no changeset file was added to .changeset/. This is a release management concern — without a changeset, this feature won't appear in the changelog and the package version won't be bumped on release.

Open in Devin Review

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

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 the new pyprojectFile option has no such validation. A user can pass { pyprojectFile: "pyproject.toml", requirements: ["numpy"] } or { pyprojectFile: "pyproject.toml", requirementsFile: "requirements.txt" } without error. In onBuildComplete, the if/else if/else if chain at lines 114-199 silently picks one option and ignores the other — requirementsFile wins over pyprojectFile, which wins over requirements. The user gets no error or warning that their configuration is conflicting and one dependency source is being dropped.

Prompt for agents
In packages/python/src/extension.ts, in the constructor (around lines 45-66), add assertions that prevent pyprojectFile from being used together with requirements or requirementsFile. Before the existing assert on line 46, or after it, add:

assert(
  !(this.options.pyprojectFile && this.options.requirements),
  "Cannot specify both pyprojectFile and requirements"
);
assert(
  !(this.options.pyprojectFile && this.options.requirementsFile),
  "Cannot specify both pyprojectFile and requirementsFile"
);

This matches the existing validation pattern at lines 46-48 and ensures users get a clear error when they provide conflicting dependency sources.
Open in Devin Review

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

Comment on lines +160 to 171
// 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 ."}
`),
},
deploy: {
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 build time

When pyprojectFile is used (lines 149-174), only the pyproject.toml file is copied into the container via addAdditionalFilesToBuild, and then pip install . (or uv pip install .) is executed. The pip install . command attempts to build and install the current directory as a Python package, which typically requires the full source tree (not just pyproject.toml). If the pyproject.toml only declares dependencies without a buildable package, or if the source files aren't present, the build will fail. Users would need to also use the scripts option to copy their Python source files for this to work. This isn't strictly a code bug since the Docker build would fail with a clear error, but it may warrant documentation or a different pip invocation (e.g., pip install with dependency extraction from pyproject.toml).

(Refers to lines 160-174)

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