dev-shell: make python shell load fast
- Add caching for editable installs - Remove sleep statement in GUI code
This commit is contained in:
@@ -49,9 +49,9 @@
|
|||||||
|
|
||||||
## PYTHON
|
## PYTHON
|
||||||
|
|
||||||
tmp_path=$(realpath ./.direnv)
|
tmp_path="$(realpath ./.direnv/python)"
|
||||||
repo_root=$(realpath .)
|
repo_root=$(realpath .)
|
||||||
mkdir -p "$tmp_path/python/${pythonWithDeps.sitePackages}"
|
mkdir -p "$tmp_path/${pythonWithDeps.sitePackages}"
|
||||||
|
|
||||||
# local dependencies
|
# local dependencies
|
||||||
localPackages=(
|
localPackages=(
|
||||||
@@ -59,28 +59,41 @@
|
|||||||
$repo_root/pkgs/clan-vm-manager
|
$repo_root/pkgs/clan-vm-manager
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install the package in editable mode
|
# Install executable wrappers for local python packages scripts
|
||||||
# This allows executing `clan` from within the dev-shell using the current
|
# This is done by utilizing `pip install --editable`
|
||||||
# version of the code and its dependencies.
|
# As a result, executables like `clan` can be executed from within the dev-shell
|
||||||
# TODO: this is slow. get rid of pip or add better caching
|
# while using the current version of the code and its dependencies.
|
||||||
echo "==== Installing local python packages in editable mode ===="
|
|
||||||
for package in "''${localPackages[@]}"; do
|
for package in "''${localPackages[@]}"; do
|
||||||
${pythonWithDeps}/bin/pip install \
|
pname=$(basename "$package")
|
||||||
--quiet \
|
if
|
||||||
--disable-pip-version-check \
|
[ ! -e "$tmp_path/meta/$pname/pyproject.toml" ] \
|
||||||
--no-index \
|
|| [ ! -e "$package/pyproject.toml" ] \
|
||||||
--no-build-isolation \
|
|| ! cmp -s "$tmp_path/meta/$pname/pyproject.toml" "$package/pyproject.toml"
|
||||||
--prefix "$tmp_path/python" \
|
then
|
||||||
--editable "$package"
|
echo "==== Installing local python package $pname in editable mode ===="
|
||||||
|
mkdir -p "$tmp_path/meta/$pname"
|
||||||
|
cp $package/pyproject.toml $tmp_path/meta/$pname/pyproject.toml
|
||||||
|
${python3.pkgs.pip}/bin/pip install \
|
||||||
|
--quiet \
|
||||||
|
--disable-pip-version-check \
|
||||||
|
--no-index \
|
||||||
|
--no-build-isolation \
|
||||||
|
--prefix "$tmp_path" \
|
||||||
|
--editable "$package"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
export PATH="$tmp_path/python/bin:$PATH"
|
export PATH="$tmp_path/bin:$PATH"
|
||||||
export PYTHONPATH="''${PYTHONPATH:+$PYTHONPATH:}$tmp_path/python/${pythonWithDeps.sitePackages}"
|
export PYTHONPATH="''${PYTHONPATH:+$PYTHONPATH:}$tmp_path/${pythonWithDeps.sitePackages}"
|
||||||
|
|
||||||
for package in "''${localPackages[@]}"; do
|
for package in "''${localPackages[@]}"; do
|
||||||
export PYTHONPATH="$package:$PYTHONPATH"
|
export PYTHONPATH="$package:$PYTHONPATH"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## GUI
|
||||||
|
|
||||||
if ! command -v xdg-mime &> /dev/null; then
|
if ! command -v xdg-mime &> /dev/null; then
|
||||||
echo "Warning: 'xdg-mime' is not available. The desktop file cannot be installed."
|
echo "Warning: 'xdg-mime' is not available. The desktop file cannot be installed."
|
||||||
fi
|
fi
|
||||||
@@ -93,7 +106,6 @@
|
|||||||
UI_BIN="clan-vm-manager"
|
UI_BIN="clan-vm-manager"
|
||||||
|
|
||||||
cp -f $DESKTOP_SRC $DESKTOP_DST
|
cp -f $DESKTOP_SRC $DESKTOP_DST
|
||||||
sleep 2
|
|
||||||
sed -i "s|Exec=.*clan-vm-manager|Exec=$UI_BIN|" $DESKTOP_DST
|
sed -i "s|Exec=.*clan-vm-manager|Exec=$UI_BIN|" $DESKTOP_DST
|
||||||
xdg-mime default $DESKTOP_FILE_NAME x-scheme-handler/clan
|
xdg-mime default $DESKTOP_FILE_NAME x-scheme-handler/clan
|
||||||
echo "==== Validating desktop file installation ===="
|
echo "==== Validating desktop file installation ===="
|
||||||
|
|||||||
Reference in New Issue
Block a user