Skip to content

Commit

Permalink
Fix sdist package getting wrong name
Browse files Browse the repository at this point in the history
Should fix this release attempt failure.
https://github.com/pypdfium2-team/pypdfium2/actions/runs/6827951737
It failed during testpypi upload because the sdist package erroneously
got the name "pypdfium2_helpers":

Unfortunately, release commit and tag had already been published. This
has been undone by force push.
  • Loading branch information
mara004 committed Nov 10, 2023
1 parent 1b0a5c6 commit 1da3677
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def run_setup(modnames, pl_name, pdfium_ver):
install_requires = [],
)

if modnames == [ModuleHelpers]:
if modnames == [ModuleHelpers] and pl_name != ExtPlats.none:
# do not do this for sdist (none)
kwargs["name"] += "_helpers"
kwargs["description"] += " (helpers module)"
kwargs["install_requires"] += ["pypdfium2_raw"]
Expand All @@ -112,7 +113,7 @@ def run_setup(modnames, pl_name, pdfium_ver):
if ModuleRaw in modnames:
kwargs["package_dir"]["pypdfium2_raw"] = "src/pypdfium2_raw"

if ModuleRaw not in modnames:
if ModuleRaw not in modnames or pl_name == ExtPlats.none:
kwargs["exclude_package_data"] = {"pypdfium2_raw": PLATFILES_GLOB}
if pl_name == ExtPlats.none:
kwargs["license_files"] += LICENSES_SDIST
Expand Down Expand Up @@ -142,9 +143,9 @@ def main():

# NOTE in principle, it may be possible to achieve the same as `prepared!` by just filling the data/ cache manually, but this is more explicit, formally disabling the generating code paths
with_prepare, pl_name, pdfium_ver, use_v8 = parse_pl_spec(pl_spec)
modnames = parse_modspec(modspec, pl_name)
modnames = parse_modspec(modspec)

if ModuleRaw in modnames and with_prepare:
if ModuleRaw in modnames and with_prepare and pl_name != ExtPlats.none:
prepare_setup(pl_name, pdfium_ver, use_v8)
run_setup(modnames, pl_name, pdfium_ver)

Expand Down
10 changes: 3 additions & 7 deletions setupsrc/pypdfium2_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SysNames:
class ExtPlats:
sourcebuild = "sourcebuild"
system = "system"
none = "none"
none = "none" # FIXME rename to sdist?
auto = "auto"

# TODO align with either python or google platform names?
Expand Down Expand Up @@ -234,6 +234,7 @@ def plat_to_system(pl_name):
if pl_name == ExtPlats.sourcebuild:
# FIXME If doing a sourcebuild on an unknown host system, this returns None, which will cause binary detection code to fail (we need to know the platform-specific binary name) - handle this downsteam with fallback value?
return Host.system
# NOTE other ExtPlats not supported here
return getattr(SysNames, pl_name.split("_", maxsplit=1)[0])


Expand Down Expand Up @@ -554,16 +555,11 @@ def parse_pl_spec(pl_spec, need_prepare=True):
return need_prepare, pl_name, req_ver, use_v8


def parse_modspec(modspec, pl_name):
def parse_modspec(modspec):
if modspec:
modnames = modspec.split(",")
assert set(modnames).issubset(ModulesAll)
assert len(modnames) in (1, 2)
else:
modnames = ModulesAll

modnames = list(modnames)
if pl_name == ExtPlats.none and ModuleRaw in modnames:
modnames.remove(ModuleRaw)

return modnames

0 comments on commit 1da3677

Please sign in to comment.