411 on Editable Installs
From
ram@ram@zedat.fu-berlin.de (Stefan Ram) to
comp.lang.python on Mon Aug 26 10:50:03 2024
From Newsgroup: comp.lang.python
So, you're cruising along in your Python journey, and bam!
You hit that wall where you wanna import your homemade module
"mymodule" into different projects scattered across your
hard drive like so many In-N-Out wrappers.
Most Python books ghost this topic harder than your Tinder
matches. If you pester enough people, they'll tell you to
whip up an "editable install" with
pip install -e <path to your modules>
. But hold up, you got to craft a "setup.py" or "pyproject.toml"
first. Then you run into this whole "setuptools" rigmarole.
You're supposed to install those bad boys ("Batteries included"),
but even when you do and "import setuptools" runs smoother than
the 405 at 3 AM, pip still throws a fit about missing setuptools!
This ain't my cup of kombucha, folks. It's giving me Java flashbacks.
After some trial and error that'd make a Silicon Valley startup
blush, I stumbled on this hack that works with the latest CPython:
Mosey on over to the "Lib/site-packages" directory in your
Python install. Create a file ending in ".pth" - let's call it
"mymodule.pth". Drop a single line in there with the file system
path to the directory housing your modules. Boom, you're golden.
It's so stupid simple, I bet the Python overlords have already
slapped a "deprecated" sticker on it and are plotting its
demise as we speak . . .
--- Synchronet 3.20a-Linux NewsLink 1.114