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

Packaging fails when the metadata has no url #236

Open
tmontes opened this issue Jul 17, 2022 · 1 comment
Open

Packaging fails when the metadata has no url #236

tmontes opened this issue Jul 17, 2022 · 1 comment
Labels
bug Something isn't working @ core
Milestone

Comments

@tmontes
Copy link
Member

tmontes commented Jul 17, 2022

THOUGHT:

  • Maybe some other metadata fields are actually required?
  • Could these be passed as CLI options? Setting the missing values and/or overriding existing ones?
@tmontes tmontes added bug Something isn't working @ core labels Jul 17, 2022
@tmontes tmontes added this to the NEXT milestone Jul 17, 2022
@EasyIsrael
Copy link

EasyIsrael commented Feb 9, 2024

there are different ways to set package metadata (pyproject.toml, setup.py and setup.cfg).

pip prefers pyproject.toml over setup.py because it is the new standardized format to describe project metadata declaratively, introduced with PEP 621. It's easier to work with and allows for shared configuration between different tools.

the problem is, if you package your project with pyproject.toml instead of setup.py, then metadata.home_page will not be filled. it is always None.

there is a discussion in the pip-development team (pypa/pip#11221)

when you still want to use the homepage as an application_id for pup, then somethin like this could solve this issue:

from collections import OrderedDict

def _homepage(self):
        _urls = OrderedDict()
        if self.src_metadata.home_page:
            _urls["Homepage"] = self.src_metadata.home_page
        if self.src_metadata.download_url:
            _urls["Download"] = self.src_metadata.download_url
        purls = {pair.split(", ")[0]: pair.split(", ")[1] for pair in self.src_metadata.project_urls}
        for name, url in purls.items():
            # avoid duplicating homepage/download links in case the same
            # url is specified in the pkginfo twice (in the Home-page
            # or Download-URL field and again in the Project-URL fields)
            comp_name = name.casefold().replace("-", "").replace("_", "")
            if comp_name == "homepage" and url == _urls.get("Homepage"):
                continue
            if comp_name == "downloadurl" and url == _urls.get("Download"):
                continue
            _urls[name] = url
        return next(iter(_urls.values()))

in create_msi.py and context.py you could use self._homepage() instead of self.src_metadata.home_page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @ core
Projects
None yet
Development

No branches or pull requests

2 participants