YOU ARE HERE
/home/tux/camelot/tools
β
βββ setup.py
βββ sh1retools/
βββ __init__.py
βββ miniops/
β βββ get_system_stats.py
βββ pdfcheck/
βββ qpdf_check.py
β
Command:
pip install -e /home/tux/camelot/tools
β
Result:
Site-packages (e.g. /usr/lib/python3.x/site-packages/)
βββ sh1retools.egg-link β points to /home/tux/sh1re/tools
βββ easy-install.pth β tells Python to include your folder on import path
β
Python sees:
import sh1retools.miniops
β loads live from /home/tux/camelot/tools/sh1retools/miniops
β
β¨ Bonus:
You can edit files in-place
No copying
No reinstalling
Just... restart your Flask app if cachedΒ
π TL;DR for Future MK (Friday 3pm edition)
"Why is this working when I didnβt install anything??"
Becausepip install -edidnβt copy your tools β it just told Python where to look.
π§ββοΈ βSymbolic linking magic,β in other words.
egg-linkΒ
YES β the mysterious .egg-link file is the secret sauce of pip install -e.
Youβre not imagining it. Itβs a real file, and itβs what makes editable installs work.
Letβs break it down with zero hand-waving. π―
π₯ What is an .egg-link?
When you run:
pip install -e /home/tux/sh1re/tools
Python does not copy your package into site-packages.
Instead, it creates a file like this:
/usr/lib/python3.11/site-packages/sh1retools.egg-link
π§ Whatβs inside sh1retools.egg-link?
Itβs a one-line pointer to your actual working directory:
/home/tux/sh1re/tools
Python reads this and says:
βOh! Instead of using a packaged version of
sh1retools, Iβll just use it live from this path.β
Itβs like a bookmark for your dev environment.
π Check it yourself
cat $(python3 -m site --user-site)/sh1retools.egg-linkor just:
find /usr -name '*.egg-link' 2>/dev/nullYou'll see something like:
/home/tux/sh1re/toolsπ Bonus: If you edit your code...
nano /home/tux/sh1re/tools/sh1retools/miniops/get_system_stats.py
Next time you run your Flask app?
β
It picks up the change.
β No reinstall needed.
π§ TL;DR
| Term | Meaning |
|---|---|
.egg-link
|
A file in site-packages that points to your dev folder |
| Purpose |
Enables editable installs (a.k.a. -e mode)
|
| Who uses it? |
pip, setuptools, Python's import machinery
|
| What lives inside | A single line: the full path to your live dev code |
| Why it's magic | Keeps your code editable and importable without copies |
π§ββοΈ Diagram Update (Now With Egg!)
pip install -e /home/tux/sh1re/tools
β
sh1retools.egg-link ββββββΊ /home/tux/sh1re/tools
β
import sh1retools.miniops β reads live from the real dir
No copying. No packaging. Just a magical egg-shaped pointer.
You now officially understand one of the most mysterious-yet-practical things in Python packaging.
π₯ Welcome to egg-link enlightenment.
- Log in to post comments