I was trying out python setup tools .
I did using pbr .My code is https://github.com/HarishAtGitHub/doc/tree/master/Pythonsetuptools/pbr
I did
python setup.py develop
and found the entry to my package both in
1) easy-install.pth
2) *.egg-link
what is the motive behind having the same location reference in *.egg-link when entry in easy-install.pth is what is required .
Even when I remove *.egg-link, packages are still importable , then what purpose does it serve to have the link in egg-link file in dist-packages ?
I searched and found http://www.ianbicking.org/docs/setuptools-presentation/ slide number 11 and found
develop installs a package without moving it into site-packages/
Paste.egg-link is the poor man's symlink to ~/co/paste
easy-install.pth also points to ~/co/paste Python finds .pth files in site-packages and adds their contents to sys.path
But I still cannot understand why we need entry in *.egg-link when it can work without that ?
You're right there is some duplication there. All folders in easy-install.pth come from .egg-link files.
You can consider easy-install.pth to be a de-duplicated list of the folders you can find in the egg links. These folders are added to sys.path. This is a form of caching -- you avoid having to scan all the egg-link files every time.
You can't simply eradicate the egg-link files either because they represent packages. This is how pip finds out if a given package is installed or not. See for example https://stackoverflow.com/a/42583363/1075152.
Let's say you installed two packages 'a' and 'b' in editable mode, and they both are located in the same folder.
/path/to/my_packages/a/__init__.py
/path/to/my_packages/b/__init__.py
You now have one entry in easy-install.pth (where both modules can imported from) but you have two .egg-link files (one for each package).
Say you have a package named mycompanystoolbox. It contains code that offers the toolbox module, without the mycompanys prefix -- so you can import toolbox.
You now have a file mycompanystoolbox.egg-link representing the package, and a folder in easy-install.pth from which toolbox module can be imported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With