Fix inconsistent pip package name that breaks pip install of requirements.txt#83
Fix inconsistent pip package name that breaks pip install of requirements.txt#83rtyley wants to merge 1 commit intoSysCV:mainfrom
pip install of requirements.txt#83Conversation
This project is released as `segment-anything-hq` in pip: https://pypi.org/project/segment-anything-hq/ ...but the setup here just said `segment_anything`, which seems to be the cause of this error message: ``` WARNING: Generating metadata for package segment-anything-hq produced metadata for project name segment-anything ``` ...while trying to pip install a requirements file that had a line like this: ``` segment-anything-hq @ git+https://github.com/SysCV/sam-hq@5fd027ec559806dec9f876b56938175a63dfc625 ``` Full error logs: ``` Collecting segment-anything-hq@ git+https://github.com/SysCV/sam-hq@5fd027ec559806dec9f876b56938175a63dfc625 (from -r requirements.txt (line 9)) Cloning https://github.com/SysCV/sam-hq (to revision 5fd027e) to /private/var/folders/28/pjfz24p92bxcj5j7gsnnk9xm0000gp/T/pip-install-cmpqwucv/segment-anything-hq_bd753024d0a540f5bcb3225886933667 Running command git clone --filter=blob:none --quiet https://github.com/SysCV/sam-hq /private/var/folders/28/pjfz24p92bxcj5j7gsnnk9xm0000gp/T/pip-install-cmpqwucv/segment-anything-hq_bd753024d0a540f5bcb3225886933667 Running command git rev-parse -q --verify 'sha^5fd027ec559806dec9f876b56938175a63dfc625' Running command git fetch -q https://github.com/SysCV/sam-hq 5fd027e Resolved https://github.com/SysCV/sam-hq to commit 5fd027e Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done WARNING: Generating metadata for package segment-anything-hq produced metadata for project name segment-anything. Fix your #egg=segment-anything-hq fragments. Discarding git+https://github.com/SysCV/sam-hq@5fd027ec559806dec9f876b56938175a63dfc625: Requested segment-anything from git+https://github.com/SysCV/sam-hq@5fd027ec559806dec9f876b56938175a63dfc625 (from -r requirements.txt (line 9)) has inconsistent name: expected 'segment-anything-hq', but metadata has 'segment-anything' ``` See also: pypa/pipenv#5445 (comment)
|
|
||
| setup( | ||
| name="segment_anything", | ||
| name="segment_anything_hq", |
There was a problem hiding this comment.
I believe this is the crucial fix for the "Generating metadata for package segment-anything-hq produced metadata for project name segment-anything" error - here, we're correcting the Distribution Package name as used by pip, rather than the Import Package.
See also pypa/pipenv#5445 (comment)
| known_standard_library=numpy,setuptools | ||
| skip_glob=*/__init__.py | ||
| known_myself=segment_anything | ||
| known_myself=segment_anything_hq |
There was a problem hiding this comment.
This bit of configuration isn't crucial - it only relates to isort configuration, to ensure that when python code imports are sorted, they are sorted in a sensible fashion. Strangely, although isort documents several other known_... settings (eg known_third_party), it doesn't document known_myself, and that identifier doesn't appear anywhere in the isort codebase.
| import matplotlib.pyplot as plt | ||
| import cv2 | ||
| from segment_anything import sam_model_registry, SamPredictor | ||
| from segment_anything_hq import sam_model_registry, SamPredictor |
There was a problem hiding this comment.
Here we're updating the Import Package in this example to match the name given in the HQ-SAM documentation:
Line 90 in 5fd027e
Note that in order for this to work, we need to rename the /segment-anything/ folder to /segment-anything-hq/ (which in Git, means a lot of files get their paths renamed).
This PR fixes two packaging inconsistencies in the
sam-hqproject:segment-anything-hq, notsegment-anythingsegment_anything_hq, notsegment_anything, according to the HQ-SAM documentation.Distribution Package (
pip installproblem)In particular, the wrong Distribution Package name (ie the name used by
pip), will cause a fatal error when trying to usepip's ability to install directly from VCS, eg with a line like this in a project'srequirements.txt:The error is:
If I change my requirements file to point at the branch for this PR, including the simple metadata fix in
setup.py, thepip installof the requirements file succeeds, and my code using HQ-SAM succeeds:Error logs from
pip installThis is just with the current
mainbranch ofsam-hq:Import Package
The HQ-SAM documentation says the Import Package is
segment-anything-hq:sam-hq/README.md
Line 90 in 5fd027e
To fix the code to match the documentation we need to rename the
/segment-anything/folder to/segment-anything-hq/.