Skip to content
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

Failing with "missing metadata.json" message when trying to upload a wheel #8

Open
ericpascual opened this issue Jan 25, 2019 · 6 comments

Comments

@ericpascual
Copy link

Trying to upload a wheel which works perfectly in other usages fails with the message:
invalid state: Could not find metadata.json

@NixBiks
Copy link

NixBiks commented Mar 20, 2019

I get the same one. If I try to upload .tar instead then I get

error: not enough values to unpack (expected 2, got 1)

@Mallouly
Copy link

Mallouly commented Dec 5, 2019

still no solution?

@caseyduquettesc
Copy link

caseyduquettesc commented Feb 12, 2020

The issue is in the wheel files. The workaround is to parse the METADATA file as a fallback, using effectively the same strategy as __extract_source

Something like this works for me, but I'm still testing different packages,

    def __extract_wheel(self, zpfile):
        class InfoCmd(object):
            def __init__(self):
                self.metadata = {}

            def __call__(self, target):
                m = json.loads(target.read())
                self.metadata["name"] = m["name"]
                self.metadata["version"] = m["version"]
                self.metadata["requirements"] = set([])
                for reqs in m.get("run_requires", []):
                    self.metadata["requirements"].update(reqs["requires"])

        class BackupInfoCmd(object):
            def __init__(self):
                self.metadata = {}

            def __call__(self, target):
                m = {}
                for line in target.readlines():
                    try:
                        if len(line.split(":")) > 1:
                            k, v = line.split(":", 1)
                            if k.upper().strip() not in m:
                                m[k.upper().strip()] = []
                            m[k.upper().strip()].append(v.strip())
                    except ValueError:
                        logging.exception("Failed to parse line '{}'".format(line))

                self.metadata["name"] = "".join(m["name".upper()])
                self.metadata["version"] = "".join(m["version".upper()])
                self.metadata["requirements"] = set([])
                for r in m.get("Requires-Dist".upper(), []):
                    self.metadata["requirements"].add(r)

        cmd = InfoCmd()
        self.__seek_and_apply(zpfile, "metadata.json", cmd)
        if not cmd.metadata:
            cmd = BackupInfoCmd()
            self.__seek_and_apply(zpfile, "METADATA", cmd)
            if not cmd.metadata:
                raise InvalidState("Could not find metadata.json")
        return cmd.metadata

@jerryvurbl
Copy link

jerryvurbl commented Dec 6, 2020

i have found the same error, and seems related to #9

@jerryvurbl
Copy link

Took @caseyduquettesc proto-patch above and applied it in PR #13
This fixes upload of wheels for me.

@shaypoww
Copy link

shaypoww commented Mar 12, 2021

@jerryvurbl
@caseyduquettesc
With all the changes, I am still getting the "Could not find metadata.json" is there any other workaround for this? Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants