-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inconsistent pip package name that breaks pip install
of requirements.txt
#83
base: main
Are you sure you want to change the base?
Conversation
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)
name="segment_anything", | ||
name="segment_anything_hq", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_myself=segment_anything | ||
known_myself=segment_anything_hq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -2,7 +2,7 @@ | |||
import torch | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we're updating the Import Package in this example to match the name given in the HQ-SAM documentation:
Line 90 in 5fd027e
from segment_anything_hq import sam_model_registry |
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-hq
project:segment-anything-hq
, notsegment-anything
segment_anything_hq
, notsegment_anything
, according to the HQ-SAM documentation.Distribution Package (
pip install
problem)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 install
of the requirements file succeeds, and my code using HQ-SAM succeeds:Error logs from
pip install
This is just with the current
main
branch 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/
.