To an extent this is because the pyproject.toml
is aimed at
distribution; how to put local-to-you things in such a thing?
Probably the best way is to make an environment. Typically that is a
venv, eg:
python -m venv your-venv-directory-here
and to install into that - now you have an area where the concept of
“this package is/is-not present” makes sense.
For my own dev tree that’s usually a subdirectory venv
with needed
third party packages installed. When I run the code in dev mode I use a
little shell script which:
- puts my dev dir’s
bin
subdir (with the local scripts in it) at the
front of$PATH
followed by thevenv/bin
directory to get the lcal
venv python executable, which is wired to find the packaged installed
in the venv - puts the local dev python code at the start of
$PYTHONPATH
so that
the dev python code is found and used - runs whatever command I intended to run
So the other day I was doing a lot of:
dev python3 bin/hashindex ls
or:
dev hashindex ls
to run my new hashindex
script which relied on the unreleased code in
my local dev tree. Indeed, the script itself was also undergoing change.
Now, when things are local you can do an “editable install” of a
package, which is particularly handy for dev work.
For your personal dev tree you’re ok I’d imagine? Just tweak
$PYTHONPATH
?
I’m assuming specifying one of your own packages as a dependency is for
use by others, or in another (sub)project needing the package. That’s
the time for an editable install, maybe. See:
https://pip.pypa.io/en/stable/topics/local-project-installs/
If you’re using pip
’s requirements file (just a file with required
packages and versions) you can put a -e
line in there. For example,
I’ve got these lines:
-e git+https://github.com/kkroening/ffmpeg-python.git@master#egg=ffmpeg-python
-e git+https://github.com/ytdl-org/youtube-dl.git@26035bde4#egg=youtube-dl
to obtain a specific unreleased version of a package as ffmpeg-python
and youtube-dl
respectively. But you can put a local filesystem path
in there as well, outlined at the URL above.
Then:
./venv/bin/python -m pip install -r requirements.txt
can apply to your environment.
This doesn’t go in the pyproject.toml
AFAIU, that is for distribution
and I think assumes use by a build/install tool which access to a
distribution source like PyPI.