-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve which python executable is being used #45
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #45 +/- ##
==========================================
+ Coverage 94.55% 94.58% +0.02%
==========================================
Files 11 11
Lines 202 203 +1
==========================================
+ Hits 191 192 +1
Misses 11 11 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be one of my favorite PRs - such an elegant solution to something that's gone through so much discussion. And it works so dang cleanly 😭
Tested this in a virtualenv
with both python3
and python
and even pyhon
and these all work as I'd hope. pyhon
fails and the other two show the correct executable path in debug logs:
[2024-06-04 10:54:29] initialized SDK CLI config: {Runtime:python Hooks:{BuildProject:{Command: Name:BuildProject} CheckUpdate:{Command:/Users/ethan.zimbelman/programming/sandbox/trusting-armadillo-332/.venv/bin/python -m slack_cli_hooks.hooks.check_update Name:CheckUpdate} Deploy:{Command: Name:Deploy} Doctor:{Comma
nd:/Users/ethan.zimbelman/programming/sandbox/trusting-armadillo-332/.venv/bin/python -m slack_cli_hooks.hooks.doctor Name:Doctor} GetHooks:{Command:python -m slack_cli_hooks.hooks.get_hooks Name:GetHooks} GetManifest:{Command:/Users/ethan.zimbelman/programming/sandbox/trusting-armadillo-332/.venv/bin/python -m slack
_cli_hooks.hooks.get_manifest Name:GetManifest} GetTrigger:{Command: Name:GetTrigger} InstallUpdate:{Command: Name:InstallUpdate} Start:{Command:/Users/et
han.zimbelman/programming/sandbox/trusting-armadillo-332/.venv/bin/python -X dev -m slack_cli_hooks.hooks.start Name:Start}} Config:{Watch:{FilterRegex:(^manifest\.json$) Paths:[.]} SDKManagedConnection:true TriggerPaths:[] SupportedProtocols:[message-boundaries default]} WorkingDirectory:}
I let this simmer in thought, and this solution seems to cover things so well. A single update to slack.json
seems reasonable to ask folks to make if needed IMO!
The only concern I have is around sharing this customized slack.json
with teammates, but it's my understanding that a similar build tool or python
executable is used by the entire team, so this change could be shared easily.
I'm like, actually so excited to see this 🏆 🚀 LGTM but am curious about hidden edges with this approach, if any exist 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you a thousand times for testing those scenarios so thoroughly ! That was exactly the kind of stuff I was going to test myself to see how it functions. The fact this is compatible with both global and virtualenv binaries is 💯
And mirroring @zimeg's comments: super elegant solution. As for the collaboration angle, I feel like this is where a team working on an app would use environment variables as part of their own setup: set some env var pointing to the relevant python binary, and then encode the name for that env var in the version-controled app slack.json
. Different teammates don't need to tweak the slack.json
and that can remain static, but each teammate can override the env var to suit their particular machine's needs. Done!
🙇 thank you But as @zimeg pointed out I am also curious about hidden edges with this approach, I will wait for @seratch review that may or may not uncover some edges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Left one suggestion for an edge case 😉
Co-authored-by: Kazuhiro Sera <[email protected]>
Summary
This PR changes which python executable is used to populate the
get-hooks
payload.This PR sets the python executable of other hooks command to the python executable used to run the
get-hooks
hook, defined in theslack.json
file.This allows developers to select which python executable the CLI must use to invoke hooks. This is accomplished by changing which executable is used to invoke the
get-hooks
hook. Here are some examples of "get-hooks" values.Examples:
Testing
scripts/build_pypi_package.sh
.whl
file to import the changes in a python projectpip install /path/to/python-slack-hooks/dist/slack_cli_hooks-0.0.1-py3-none-any.whl
python3 -m slack_cli_hooks.hooks.get_hooks
"/Users/bob/path/to/my/project/env_3.12.2/bin/python -m slack_cli_hooks.hooks.get_manifest"
and not"python3 -m slack_cli_hooks.hooks.get_manifest"
Special notes
Here are the scenarios I've tested
python3
alias inslack.json
🟢python
alias inslack.json
🟢python3
alias inslack.json
🟢python
alias inslack.json
🟢/Users/bob/path/to/virtural/env/bolt-python-project/env_3.12.2/bin/python
alias set inslack.json
🟢slack.json
🟢"start"
hook only 🟢python3
alias inslack.json
🟢slack.json
🟢space
in the python executable path, ex:./env 3.10.7/bin/python
using thepython3
alias inslack.json
🟢PowerShell
to run the app with a virtual environment set up that contains aspace
in the python executable path, ex:./env 3.10.7/bin/python
using thepython3
alias inslack.json
🟢Requirements
./scripts/install_and_run_tests.sh
after making the changes.