Created
February 15, 2025 06:18
-
-
Save sdatsenko/34686685426989fa283df1e9596b4c02 to your computer and use it in GitHub Desktop.
Running ipython with packages
This file contains 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
#!/bin/sh | |
# itry - A portable script for launching ipython with uvx packages | |
# from https://til.simonwillison.net/python/itry | |
# with auto import of listed packages | |
# Show help if requested | |
[ "$1" = "--help" ] && { | |
echo "Usage: itry [packages...]" | |
echo "Example: itry llm sqlite-utils datasette" | |
exit 0 | |
} | |
# Initialize empty string for packages | |
PACKAGES="" | |
IMPORTS="" | |
# Process all arguments, adding --with before each | |
for arg in "$@"; do | |
PACKAGES="${PACKAGES}--with $arg " | |
IMPORTS="${IMPORTS}import $arg; " | |
done | |
# Execute uvx command with Python 3.13 | |
exec uvx $PACKAGES --python 3.13 ipython --InteractiveShellApp.exec_lines="$IMPORTS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is slight variation of
itry
script from Simon Willison’s TILs, adding automatic import of listed modules, and deleting (IMHO unnecessary) space removal.