Skip to content

Commit

Permalink
added some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhmancs committed Oct 20, 2024
1 parent 7573ea7 commit 4883bae
Showing 1 changed file with 48 additions and 34 deletions.
82 changes: 48 additions & 34 deletions flake-parts/templates/python/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,61 @@
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
venvDir = ".venv";
packages = with pkgs;
[ python311 ]
++ (with pkgs.python311Packages; [
pip
venvShellHook
packages = with pkgs; [
(pkgs.python3.withPackages (ps: [
ps.pip
ps.tkinter
ps.venvShellHook
ipython
ipykernel # required for jupyter notebooks
black
ipykernel
setuptools
pylint
#poetry
]);
]))
python3Packages.python-lsp-server
poetry # Instead of pip, you can use $ poetry init -n --name <name> and $ poetry add request <package> to install python packages
];
# packages = with pkgs;
# [ python311 ]
# ++ (with pkgs.python311Packages; [
# pip
# venvShellHook
# ipython
# ipykernel # required for jupyter notebooks
# black
# setuptools
# pylint
# #poetry
# ]);
shellHook = ''
# Define shell aliases
alias py='python'
alias py2='python2'
alias py3='python3'
alias po='poetry'
alias ipy='ipython --no-banner'
alias ipylab='ipython --pylab=qt5 --no-banner'
# Define shell aliases
alias py='python'
alias py2='python2'
alias py3='python3'
alias po='poetry'
alias ipy='ipython --no-banner'
alias ipylab='ipython --pylab=qt5 --no-banner'
# Set environment variables
export PYTHONPYCACHEPREFIX="$XDG_CACHE_HOME/python"
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc"
export PYTHONUSERBASE="$XDG_DATA_HOME/python"
export PYTHON_EGG_CACHE="$XDG_CACHE_HOME/python-eggs"
export PYTHONHISTFILE="$XDG_DATA_HOME/python/python_history"
export IPYTHONDIR="$XDG_CONFIG_HOME/ipython"
export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME/jupyter"
export PIP_CONFIG_FILE="$XDG_CONFIG_HOME/pip/pip.conf"
export PIP_LOG_FILE="$XDG_STATE_HOME/pip/log"
export PYLINTHOME="$XDG_DATA_HOME/pylint"
export PYLINTRC="$XDG_CONFIG_HOME/pylint/pylintrc"
export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
# Set environment variables
# export PYTHONPYCACHEPREFIX="$XDG_CACHE_HOME/python"
# export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc"
# export PYTHONUSERBASE="$XDG_DATA_HOME/python"
# export PYTHON_EGG_CACHE="$XDG_CACHE_HOME/python-eggs"
# export PYTHONHISTFILE="$XDG_DATA_HOME/python/python_history"
# export IPYTHONDIR="$XDG_CONFIG_HOME/ipython"
# export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME/jupyter"
# export PIP_CONFIG_FILE="$XDG_CONFIG_HOME/pip/pip.conf"
# export PIP_LOG_FILE="$XDG_STATE_HOME/pip/log"
# export PYLINTHOME="$XDG_DATA_HOME/pylint"
# export PYLINTRC="$XDG_CONFIG_HOME/pylint/pylintrc"
# export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
# Tells pip to put packages into $PIP_PREFIX instead of the usual locations.
# See https://pip.pypa.io/en/stable/user_guide/#environment-variables.
export PIP_PREFIX=$(pwd)/_build/pip_packages
export PYTHONPATH="$PIP_PREFIX/${pkgs.python3.sitePackages}:$PYTHONPATH"
export PATH="$PIP_PREFIX/bin:$PATH"
unset SOURCE_DATE_EPOCH
# Tells pip to put packages into $PIP_PREFIX instead of the usual locations.
# See https://pip.pypa.io/en/stable/user_guide/#environment-variables.
export PIP_PREFIX=$(pwd)/_build/pip_packages
export PYTHONPATH="$PIP_PREFIX/${pkgs.python3.sitePackages}:$PYTHONPATH"
export PATH="$PIP_PREFIX/bin:$PATH"
unset SOURCE_DATE_EPOCH
'';
};
});
Expand Down

0 comments on commit 4883bae

Please sign in to comment.