Skip to content

Commit 4868efe

Browse files
author
jwiltse
committed
- Add cfg_src_suffix to handle github releases asset endpoints
1 parent 6775b16 commit 4868efe

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/portable_python/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ def cfg_url(self, version):
507507
url_expanded = os.path.expandvars(url_subbed)
508508
return url_expanded
509509

510+
def cfg_src_suffix(self):
511+
return PPG.config.get_value("%s-src-suffix" % self.m_name)
512+
510513
def cfg_configure(self, deps_lib_dir, deps_lib64_dir):
511514
if configure := PPG.config.get_value("%s-configure" % self.m_name):
512515
configure_template = Template(configure)
@@ -642,9 +645,11 @@ def compile(self):
642645
self._finalize()
643646
return
644647

645-
if ".tar.gz" not in self.url and ".zip" not in self.url:
646-
# TODO: add self.cfg_src_extension to remove assumption of .tar.gz
647-
basename = f"{self.m_name}-{self.version}.tar.gz"
648+
# Some src_url don't end in file extension, such as with redirects
649+
# Github releases asset endpoint is this way .../releases/assets/48151
650+
if self.url.endswith(".zip", ".tar.gz"):
651+
suffix = self.cfg_src_suffix() or ".tar.gz"
652+
basename = f"{self.m_name}-{self.version}.{suffix}"
648653
else:
649654
# Split on '#' for urls that include a checksum, such as #sha256=... fragment
650655
basename = runez.basename(self.url, extension_marker="#")

0 commit comments

Comments
 (0)