25

I know I can install with

$ pip install -e git+https://git.repo/some_pkg#egg=SomePackage

but -- when I'm trying to use somebody else's package -- how do I determine what the name of the egg is?

Brian Dant
  • 4,029
  • 6
  • 33
  • 47

1 Answers1

45

Look at the git repo, find the setup.py, setup.cfg or pyproject.toml file in the root and find what name has been set.

  • In setup.py, look for the name keyword in the setup() function call.
  • In setup.cfg, look for the name entry under the [metadata] section.
  • If there is only a pyproject.toml file, then look for a [tool.poetry] or [tool.flit.metadata] or [project] section, and the name entry under that section. (Which section exactly depends on the packaging tool used; flint and poetry expect different sections and there may be other projects using pyproject.toml to create Python packages in future).

For example, the Pyramid project has a setup.py file, which has:

setup(
  name='pyramid',

so you'd use:

$ pip install -e git+https://github.com/Pylons/pyramid.git#egg=pyramid

Or, if you look at the FastAPI repository, then you'd find a pyproject.toml file with:

[tool.flit.metadata]
module = "fastapi"

and so you'd use

$ pip install -e git+https://github.com/tiangolo/fastapi.git#egg=fastapi
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 1
    Could you explain what is `egg` and why it's needed? I tried to search for it but couldn't find any explanation. – Sanghyun Lee Aug 16 '19 at 14:59
  • 2
    @SanghyunLee: The [Python egg format](http://peak.telecommunity.com/DevCenter/PythonEggs) is a distribution format and standard for tracking what is installed. The `#egg=` part tells `pip` under what name the project is installed so it can determine if you already have an existing installation, etc. – Martijn Pieters Aug 16 '19 at 15:05
  • Oh, I thought it was something specific to `pipenv` as I found this thread through https://stackoverflow.com/questions/51201515/pipenv-requires-an-egg-fragment-for-version-controlled-dependencies-warning-w that's why I couldn't search for what it is. Thanks a lot! – Sanghyun Lee Aug 16 '19 at 15:12
  • name could also be elsewhere rather than in setup.py., like in setup.cfg – Goku Apr 28 '22 at 19:48
  • @Goku: my answer was originally written before setup.cfg files were a thing. I've updated the answer to cover those, plus pyproject.toml files. Thanks for pointing out my answer was no longer as complete as it could be! – Martijn Pieters Apr 29 '22 at 11:11
  • @MartijnPieters No problem- thank you for updating the answer! I just now noticed it was an old question. – Goku Apr 29 '22 at 18:21