pythonpipsetuptools

How is "egg=" used in "pip install -e"?


Trying to test editable installs out and I'm not sure how to interpret the results.

I intentionally made a typo in the egg= portion but it was still able to locate the egg without any help from me:

root@6be8ee41b6c9:/# pip3 install -e git+https://gitlab.com/jame/clientapp.git      
Could not detect requirement name for 'git+https://gitlab.com/jame/clientapp.git', please specify one with #egg=your_package_name

root@6be8ee41b6c9:/# pip3 install -e git+https://gitlab.com/jame/clientapp.git#egg=
Could not detect requirement name for 'git+https://gitlab.com/jame/clientapp.git#egg=', please specify one with #egg=your_package_name

root@6be8ee41b6c9:/# pip3 install -e git+https://gitlab.com/jame/clientapp.git#egg=e
Obtaining e from git+https://gitlab.com/jame/clientapp.git#egg=e
  Cloning https://gitlab.com/jame/clientapp.git to /src/e
  Running setup.py (path:/src/e/setup.py) egg_info for package e produced metadata for project name clientapp. Fix your #egg=e fragments.
Installing collected packages: clientapp
  Found existing installation: ClientApp 0.7
    Can't uninstall 'ClientApp'. No files were found to uninstall.
  Running setup.py develop for clientapp
Successfully installed clientapp

root@6be8ee41b6c9:/# pip3 freeze
asn1crypto==0.24.0
-e git+https://gitlab.com/jame/clientapp.git@5158712c426ce74613215e61cab8c21c7064105c#egg=ClientApp
cryptography==2.6.1
entrypoints==0.3
keyring==17.1.1
keyrings.alt==3.1.1
pycrypto==2.6.1
PyGObject==3.30.4
pyxdg==0.25
SecretStorage==2.3.1
six==1.12.0

So if I could mess the egg name up so bad, why is it considered an error to either leave it blank or set to something empty


Solution

  • This is outdated notation. Nowadays one should use the following notation whenever possible:

    python -m pip install 'ProjectName @ git+https://example.local/repository.git@1.3.1'
    

    My guess, the name matters if the project is a dependency of another project. For example in a case where one wants to install A from PyPI and Z from git, but Z is a dependency of A.

    python -m pip install 'A' 'git+https://example.local/repository.git#egg=Z'
    

    or with new notation:

    python -m pip install 'A' 'Z @ git+https://example.local/repository.git