@@ -8,31 +8,29 @@ PACKAGE_NAME=alphaquant
88# BUILD_NAME is taken from environment variables, e.g. alphaquant-1.2.3-macos-darwin-arm64 or alphaquant-1.2.3-macos-darwin-x64
99rm -rf ${BUILD_NAME} .pkg
1010
11- curl_github () {
11+ curl_with_retries () {
1212 local args=(
1313 -L
1414 -f
1515 --retry 3
1616 --retry-delay 2
17- -H " Accept: application/vnd.github+json"
1817 -H " User-Agent: alphaquant-release-build"
1918 )
2019
21- local github_token=" ${GITHUB_TOKEN:- ${GH_TOKEN:- } } "
22- if [ -n " $github_token " ]; then
23- args+=(-H " Authorization: Bearer ${github_token} " )
24- fi
25-
2620 curl " ${args[@]} " " $@ "
2721}
2822
29- extract_alphamap_data_urls () {
30- python -c ' import json, sys
31- for item in json.load(sys.stdin):
32- name = item.get("name", "")
33- url = item.get("download_url")
34- if url and name.endswith((".fasta", ".csv")):
35- print(url)'
23+ list_alphamap_data_downloads () {
24+ python -c ' from urllib.parse import quote
25+ from alphamap.organisms_data import all_organisms
26+ base_url = "https://raw.githubusercontent.com/MannLabs/alphamap/main/alphamap/data/"
27+ seen = set()
28+ for organism in all_organisms.values():
29+ for key in ("fasta_name", "uniprot_name"):
30+ name = organism[key]
31+ if name not in seen:
32+ seen.add(name)
33+ print(f"{name}\t{base_url}{quote(name)}")'
3634}
3735
3836# If needed, include additional source such as e.g.:
@@ -63,21 +61,14 @@ mkdir -p ${CONTENTS_FOLDER}/Frameworks/alphamap/data/
6361# ###
6462# ###Download all AlphaMap FASTA and CSV files from GitHub, which are needed for the further analyses. There is a lot of error checking to ensure that the files get actually added during the build
6563echo " Starting downloads of FASTA and CSV files..."
66- if ! DOWNLOAD_LIST=$( curl_github https://api.github.com/repos/MannLabs/alphamap/contents/alphamap/data? ref=main) ; then
67- echo " Error: Failed to fetch file list from GitHub API"
68- exit 1
69- fi
70-
71- echo " $DOWNLOAD_LIST " | \
72- extract_alphamap_data_urls | \
73- while read url; do
74- if [ -z " $url " ]; then
64+ list_alphamap_data_downloads | \
65+ while IFS=$' \t ' read -r filename url; do
66+ if [ -z " $filename " ] || [ -z " $url " ]; then
7567 echo " Warning: Empty URL detected, skipping..."
7668 continue
7769 fi
78- filename=$( basename $url )
7970 echo " Downloading $filename ..."
80- if ! curl_github " $url " -o " ${CONTENTS_FOLDER} /Frameworks/alphamap/data/$filename " ; then
71+ if ! curl_with_retries " $url " -o " ${CONTENTS_FOLDER} /Frameworks/alphamap/data/$filename " ; then
8172 echo " Error: Failed to download $filename "
8273 exit 1
8374 fi
@@ -101,7 +92,7 @@ mkdir -p ${CONTENTS_FOLDER}/MacOS/_internal/alphaquant/resources/
10192# Download and extract the first zip file
10293echo " Downloading and extracting first resource from datashare..."
10394TEMP_ZIP1=$( mktemp)
104- if ! curl -L -f " https://datashare.biochem.mpg.de/s/ezPzeqStEgDD8gg/download" -o " $TEMP_ZIP1 " ; then
95+ if ! curl_with_retries " https://datashare.biochem.mpg.de/s/ezPzeqStEgDD8gg/download" -o " $TEMP_ZIP1 " ; then
10596 echo " Error: Failed to download first resource from datashare"
10697 exit 1
10798fi
@@ -112,7 +103,7 @@ rm "$TEMP_ZIP1"
112103# Download and extract the second zip file
113104echo " Downloading and extracting second resource from datashare..."
114105TEMP_ZIP2=$( mktemp)
115- if ! curl -L -f " https://datashare.biochem.mpg.de/s/stH9pmNe6O9CRHG/download" -o " $TEMP_ZIP2 " ; then
106+ if ! curl_with_retries " https://datashare.biochem.mpg.de/s/stH9pmNe6O9CRHG/download" -o " $TEMP_ZIP2 " ; then
116107 echo " Error: Failed to download second resource from datashare"
117108 exit 1
118109fi
0 commit comments