If you have any questions, comments, or suggestions - please contact StJohn Piano on Tela:
Situation: You want to build a feature that will require changes to multiple Python packages that are in a dependency chain
It will be easiest to edit all the packages simultaneously.
This can be accomplished by using "editable installs" - the parent package will install a link file in its virtualenv that points to your local copy of the child package.
Any changes that you make in the local copy of a dependency package will be immediately reflected within the virtualenv of the parent package.
You can then work on all the packages at the same time, using a branch on each package repo with the same name e.g.
feature/20240101_feature_name, until the feature is ready. Then you can go through the merge process for each package repo.
I have developed two simple Python packages:
python3-editable-installs-1 imports python3-editable-installs-2.
python3-editable-installs-2 has been released on Github, so there's a tag that can be used for specifying the package version.
I assume that you've aliased
Open a terminal.
mkdir editable && cd editable
git clone firstname.lastname@example.org:sj-piano/python3-editable-installs-1.git
git clone email@example.com:sj-piano/python3-editable-installs-2.git
python -m venv .venv
pip install -r requirements.txt
Here's the contents of requirements.txt:
# PyPI imports
# Github imports
python3-editable-installs-2 @ git+https://firstname.lastname@example.org
Now if I run
pip freeze, I see this output:
(.venv) stjohn@horizon python3-editable-installs-1 % pip freeze
python3-editable-installs-2 @ git+https://github.com/sj-piano/python3-editable-installs-2@acbdb57c1744354c147deff3175b7e0a08e18ddf
Note: Although I specified a tag for python3-editable-installs-2 in requirements.txt, the tag is mapped to a commit hash, which is then used.
Ok, now that python3-editable-installs-1 has been set up, we can change python3-editable-installs-2 to be an editable install of the local copy of the package.
pip install --no-deps --editable ../python3-editable-installs-2
We don't need to uninstall it first. The new
pip install command will overwrite the existing package.
We use the
--no-deps option to prevent pip from changing any dependencies of the target package. This becomes useful in the situation where we are editing 3 packages simultaneously, for example if
python3-editable-installs-2 had another child package called
Now, run the test (stored in
This should succeed.
Now, in the local copy of python3-editable-installs-2, open the file
editable_installs_2/foo.py and change the value of
Now re-run the test command
pytest test. It should fail.
What's happened here ? Well, you've changed the local copy of a dependency, and this change has been reflected immediately in the parent package that imports it.
This means that you can work on both packages simultaneously.
I recommend creating a new branch in each package repo, with the same name e.g.
feature/20240101_feature_name. When the feature is ready, go through the merge process for each package repo.
This approach can be extended to 3 or more packages in a chain. Be sure to use the
--no-deps option when making each editable install.
Follow Tela Network on LinkedIn:
Follow Tela Network on Twitter:
Join Tela Network and become a consultant:
Join the Tela Social channel on Telegram to get every new update:
Follow Tela Network on Instagram: