Skip to main content

Actually we can keep my venvs clean with a global env

ID
e1dbdf8
date
2023-11-26 03:08:16+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
3d38821
message
Actually we can keep my venvs clean with a global env
changed files
2 files, 12 additions, 8 deletions

Changed files

README.md (1816) → README.md (1493)

diff --git a/README.md b/README.md
index 3b984dc..030a51f 100644
--- a/README.md
+++ b/README.md
@@ -21,15 +21,8 @@ To set up this repo on a new computer, I run the following commands in a Fish sh
     $ source .venv/bin/activate.fish
     $ pip install -r requirements.txt
     ```
-
-3.  Add some global pip config to [prevent installing anything outside virtual environments](https://blog.glyph.im/2023/08/get-your-mac-python-from-python-dot-org.html#and-always-use-virtual-environments):
-
-    ```console
-    $ mkdir -p ~/.pip
-    $ echo -e "[global]\nrequire-virtualenv = true" > ~/.pip/pip.conf
-    ```
     
-4.  Install my Fish config, so Fish knows where to find all these scripts:
+3.  Install my Fish config, so Fish knows where to find all these scripts:
 
     ```console
     $ ln -s ~/repos/scripts/config.fish ~/.config/fish/config.fish

config.fish (2311) → config.fish (2652)

diff --git a/config.fish b/config.fish
index d52f058..f6bd932 100644
--- a/config.fish
+++ b/config.fish
@@ -22,6 +22,17 @@ set -x fish_function_path ~/repos/scripts/fish_functions $fish_function_path
 fish_add_path /Library/Frameworks/Python.framework/Versions/3.12/bin
 
 
+# This prevents me from installing packages with pip without being
+# in a virtualenv first.
+#
+# This allows me to keep my system Python clean, and install all my
+# packages inside virtualenvs.
+#
+# See https://docs.python-guide.org/dev/pip-virtualenv/#requiring-an-active-virtual-environment-for-pip
+#
+set -g -x PIP_REQUIRE_VIRTUALENV true
+
+
 # This tells fish to run a couple of functions as event handlers --
 # that is, to run a function when a variable changes or something similar.
 # These functions can't be autoloaded.