**Concrete example of using `--editable` in development**
You can play with [this test package](https://github.com/cirosantilli/vcdvcd/tree/5dd4205c37ed0244ecaf443d8106fadb2f9cfbb8) as in:
```
cd ~
git clone https://github.com/cirosantilli/vcdvcd
cd vcdvcd
git checkout 5dd4205c37ed0244ecaf443d8106fadb2f9cfbb8
python -m pip install --editable . --user
```
then it outputs:
```lang-plaintext
Obtaining file:///home/ciro/bak/git/vcdvcd
Installing collected packages: vcdvcd
Attempting uninstall: vcdvcd
Found existing installation: vcdvcd 1.0.6
Can't uninstall 'vcdvcd'. No files were found to uninstall.
Running setup.py develop for vcdvcd
Successfully installed vcdvcd-1.0.6
```
The `Can't uninstall 'vcdvcd'` is normal: it tried to uninstall any existing `vcdvcd` to then replace them with the "symlink-like mechanism" that is produced in the following steps, but failed because there were no previous installations.
Then it generates a file:
```lang-plaintext
~/.local/lib/python3.8/site-packages/vcdvcd.egg-link
```
which contains:
```
/home/ciro/vcdvcd
.
```
and acts as a "symlink" to the Python interpreter.
So now, if I make any changes to the git source code under `/home/ciro/vcdvcd`, it reflects automatically on importers who can from any directory do:
```
python -c 'import vcdvcd'
```
Note however that at my `pip` version at least, binary files installed with `--editable`, such as the `vcdcat` script provided by that package via `scripts=` on `setup.py`, do not get symlinked, just copied to:
```lang-plaintext
~/.local/bin/vcdcat
```
just like for regular installs, and therefore updates to the git repository won't directly affect them.
By comparison, a regular non `--editable` install from the git source:
```
python -m pip uninstall vcdvcd
python -m pip install --user .
```
produces a copy of the installed files under:
```lang-plaintext
~/.local/lib/python3.8/site-packages/vcdvcd
```
Uninstall of an editable package as done above requires a new enough pip as mentioned at: https://stackoverflow.com/questions/17346619/how-to-uninstall-editable-packages-with-pip-installed-with-e
Tested in Python 3.8, pip 20.0.2, Ubuntu 20.04.
**Recommendation: develop directly in-tree whenever possible**
The editable setup is useful when you are testing your patch to a package through another project.
If however you can fully test your change in-tree, just do that instead of generating an editable install which is more complex.
E.g., the vcdvcd package above is setup in a way that you can just `cd` into the source and do `./vcdcat` without pip installing the package itself (in general, you might need to install dependencies from `requirements.txt` though), and the `import vcdvcd` that that executable does (or possibly your own custom test) just finds the package correctly in the same directory it lives in.
**Concrete example of using `--editable` in development**
If you play with [this test package](https://github.com/cirosantilli/vcdvcd/tree/5dd4205c37ed0244ecaf443d8106fadb2f9cfbb8) as in:
```
cd ~
git clone https://github.com/cirosantilli/vcdvcd
cd vcdvcd
git checkout 5dd4205c37ed0244ecaf443d8106fadb2f9cfbb8
python -m pip install --editable . --user
```
it outputs:
```lang-plaintext
Obtaining file:///home/ciro/bak/git/vcdvcd
Installing collected packages: vcdvcd
Attempting uninstall: vcdvcd
Found existing installation: vcdvcd 1.0.6
Can't uninstall 'vcdvcd'. No files were found to uninstall.
Running setup.py develop for vcdvcd
Successfully installed vcdvcd-1.0.6
```
The `Can't uninstall 'vcdvcd'` is normal: it tried to uninstall any existing `vcdvcd` to then replace them with the "symlink-like mechanism" that is produced in the following steps, but failed because there were no previous installations.
Then it generates a file:
```lang-plaintext
~/.local/lib/python3.8/site-packages/vcdvcd.egg-link
```
which contains:
```
/home/ciro/vcdvcd
.
```
and acts as a "symlink" to the Python interpreter.
So now, if I make any changes to the git source code under `/home/ciro/vcdvcd`, it reflects automatically on importers who can from any directory do:
```
python -c 'import vcdvcd'
```
Note however that at my `pip` version at least, binary files installed with `--editable`, such as the `vcdcat` script provided by that package via `scripts=` on `setup.py`, do not get symlinked, just copied to:
```lang-plaintext
~/.local/bin/vcdcat
```
just like for regular installs, and therefore updates to the git repository won't directly affect them.
By comparison, a regular non `--editable` install from the git source:
```
python -m pip uninstall vcdvcd
python -m pip install --user .
```
produces a copy of the installed files under:
```lang-plaintext
~/.local/lib/python3.8/site-packages/vcdvcd
```
Uninstall of an editable package as done above requires a new enough pip as mentioned at: https://stackoverflow.com/questions/17346619/how-to-uninstall-editable-packages-with-pip-installed-with-e
Tested in Python 3.8, pip 20.0.2, Ubuntu 20.04.
**Recommendation: develop directly in-tree whenever possible**
The editable setup is useful when you are testing your patch to a package through another project.
If however you can fully test your change in-tree, just do that instead of generating an editable install which is more complex.
E.g., the vcdvcd package above is setup in a way that you can just `cd` into the source and do `./vcdcat` without pip installing the package itself (in general, you might need to install dependencies from `requirements.txt` though), and the `import vcdvcd` that that executable does (or possibly your own custom test) just finds the package correctly in the same directory it lives in.