feat(python): add support for creating python .venv and installing dependencies#346
Open
feat(python): add support for creating python .venv and installing dependencies#346
Conversation
Swap pip install order so pyproject.toml is installed first to set up the project package, then requirements.txt pins take precedence as the lockfile.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #346 +/- ##
==========================================
+ Coverage 64.73% 64.77% +0.04%
==========================================
Files 212 212
Lines 17809 17860 +51
==========================================
+ Hits 11528 11569 +41
- Misses 5207 5212 +5
- Partials 1074 1079 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Clarify error messages in installPyProjectToml to include "updating pyproject.toml" context, and remove early return on file update errors so pip install is attempted regardless.
mwbrooks
commented
Feb 20, 2026
Member
Author
mwbrooks
left a comment
There was a problem hiding this comment.
Comments for the kind folks 👓
| if !exists { | ||
| err := fmt.Errorf("pyproject.toml missing project section") | ||
| return fmt.Sprintf("Error: %s", err), err | ||
| return fmt.Sprintf("Error updating pyproject.toml: %s", err), err |
Member
Author
There was a problem hiding this comment.
note: Improving error messages when there is an error adding slack-cli-hooks to pyproject.toml.
Route createVirtualEnvironment and runPipInstall through HookExecutor instead of os/exec, matching the npm runtime pattern. This makes the functions testable with the mock filesystem. Also add missing AddDefaultMocks call, remove stale test cases, and fix assertion strings.
mwbrooks
commented
Feb 21, 2026
Comment on lines
+98
to
+108
| hookScript := hooks.HookScript{ | ||
| Name: "CreateVirtualEnvironment", | ||
| Command: fmt.Sprintf("%s -m venv .venv", getPythonExecutable()), | ||
| } | ||
| stdout := bytes.Buffer{} | ||
| hookExecOpts := hooks.HookExecOpts{ | ||
| Hook: hookScript, | ||
| Stdout: &stdout, | ||
| Directory: projectDirPath, | ||
| } | ||
| _, err := hookExecutor.Execute(ctx, hookExecOpts) |
Member
Author
There was a problem hiding this comment.
note: While it's verbose, we use the hookExecutor so that we can mock the exec calls during tests. This is how we also handle npm install.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Summary
This pull request adds support for creating a Python virtual environment when it doesn't already exist and installs the dependencies defined in
requirements.txtandpyproject.toml.Out-of-scope:
Known issues:
pyproject.tomldoesn't include a[project]section ordependenciesarray, the Slack CLI will display an error. It gracefully fails by continuing with the installation process for requirements.txt. However, I think we have an opportunity to update the Slack CLI to display a "Skipped updating pyproject.toml: no dependencies array" message instead of an error. That can be handled in a follow-up PR.Related PRs:
Preview
Example of an app with a valid
pyproject.toml:Example of an app with an incomplete
pyproject.toml:Reviewers
Example of an app with a valid
pyproject.toml:Example of an app with an incomplete
pyproject.toml:Requirements