Browse Source

WIP for pipx installations

pull/206/head
Scott Walsh 1 year ago
parent
commit
f9df9db866
  1. 3
      poetry.lock
  2. 7
      pyproject.toml
  3. 72
      setup.sh

3
poetry.lock

@ -2501,7 +2501,6 @@ files = [
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
@ -3673,4 +3672,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "76e17c74f2e939c22858a9edaea512766a05d0d7737825b13f8b9928cc91e188"
content-hash = "f2995ca96c32fda2c1567d045cb36422b0f5541e809c47e24ff96025a35ac7b0"

7
pyproject.toml

@ -8,7 +8,8 @@ authors = [
"Scott Behrens <https://github.com/sbehrens>",
]
packages = [
{ include = "installer"}
{ include = "installer"},
{ include = "helpers"}
]
[tool.poetry.dependencies]
@ -24,6 +25,10 @@ youtube-transcript-api = "^0.6.2"
pydub = "^0.25.1"
ollama = "^0.1.7"
anthropic = "^0.18.1"
python-dotenv = "^1.0.1"
pyperclip = "^1.8.2"
jwt = "^1.3.1"
flask = "^3.0.2"
[tool.poetry.group.cli.dependencies]
pyyaml = "^6.0.1"

72
setup.sh

@ -2,66 +2,68 @@
# Check if pyproject.toml exists in the current directory
if [ ! -f "pyproject.toml" ]; then
echo "Poetry could not find a pyproject.toml file in the current directory or its parents."
echo "Please navigate to the project directory where pyproject.toml is located and rerun this script."
exit 1
fi
# Installs poetry-based python dependencies
echo "Installing python dependencies"
poetry install
# List of commands to check and add or update alias for
# Add 'yt' and 'ts' to the list of commands
commands=("fabric" "fabric-api" "fabric-webui" "ts" "yt")
echo "Installing fabric via pipx"
pipx install .
pipx ensurepath
# Path to the bootstrap file
bootstrap_file="$HOME/.config/fabric/fabric-bootstrap.inc"
fabric_path="$HOME/.config/fabric/"
bootstrap="fabric-bootstrap.inc"
context="context.md"
bootstrap_file="$fabric_path$bootstrap"
context_file="$fabric_path$context"
# Ensure the directory for the bootstrap file exists
mkdir -p "$(dirname "$bootstrap_file")"
# Start the bootstrap file with a shebang if it doesn't already exist
if [ ! -f "$bootstrap_file" ]; then
echo "#!/bin/bash" > "$bootstrap_file"
if [ -e "$bootstrap_file" ]; then
echo "$bootstrap_file exists. Will only append new aliases"
else
touch $bootstrap_file
echo "created $bootstrap_file"
fi
if [ -e "$context_file" ]; then
echo "$context_file exists. Doing nothing"
else
touch $bootstrap_file
echo "created $bootstrap_file"
fi
# List of shell configuration files to update
config_files=("$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.bash_profile")
for config_file in "${config_files[@]}"; do
for config_file in "${config_files[@]}"
do
# Check if the configuration file exists
if [ -f "$config_file" ]; then
if [ -e "$config_file" ]; then
echo "Checking $config_file"
# Ensure the bootstrap script is sourced from the shell configuration file
source_line="if [ -f \"$bootstrap_file\" ]; then . \"$bootstrap_file\"; fi"
if ! grep -qF -- "$source_line" "$config_file"; then
echo -e "\n# Load custom aliases\n$source_line" >> "$config_file"
echo -e "\n# Load custom aliases for fabric\n$source_line" >> "$config_file"
echo "Added source command for $bootstrap_file in $config_file."
fi
sed -i '' '/alias fabric=/d' "$config_file"
sed -i '' '/fabric --pattern/d' "$config_file"
else
echo "$config_file does not exist."
fi
done
# Add aliases to the bootstrap file
for cmd in "${commands[@]}"; do
CMD_PATH=$(poetry run which $cmd 2>/dev/null)
if [ -z "$CMD_PATH" ]; then
echo "Command $cmd not found in the current Poetry environment."
continue
fi
# Check if the alias already exists in the bootstrap file
if ! grep -qF "alias $cmd=" "$bootstrap_file"; then
echo "alias $cmd='$CMD_PATH'" >> "$bootstrap_file"
echo "Added alias for $cmd to $bootstrap_file."
# set aliases for all known patterns
echo "Checking alises:"
for i in $(fabric --list)
do
new="alias $i='fabric -cp $i'"
if ! grep -qF -- "$new" "$bootstrap_file"; then
echo $new >> $bootstrap_file
echo " - $i added to aliases"
else
echo " - $i alias exists- skipping"
fi
done
echo "Setup completed. Please restart your terminal or source your configuration files to apply changes."
echo "Please restart your terminal or source $bootstrap_file with '. $bootstrap_file'."
echo "Setup completed."

Loading…
Cancel
Save