Skip to content

Commit b67d7fc

Browse files
ENH: Update to anaconda-client v1.12.3 and simplify dependencies (#67)
* ENH: Update to anaconda-client v1.12.3 and simplify dependencies * As anaconda-client v1.12.3 adds the fixes needed for scientific-python/upload-nightly-action v0.4.0 upstream, updating to this version allows for reverting the logic added in scientific-python/upload-nightly-action v0.4.0 and removing curl and jq as required dependencies. - c.f. https://github.com/scientific-python/upload-nightly-action/releases/tag/0.4.0 * Revert logic from fix in scientific-python/upload-nightly-action v0.4.0. * Update Python to 3.12. * Rebuild the lock file for the updated environment. * CI: Update anaconda-client and python in all workflows * Update anaconda-client to v1.12.3. * Update Python to v3.12.
1 parent 2c7042c commit b67d7fc

5 files changed

Lines changed: 68 additions & 304 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
with:
102102
environment-name: remove-wheels
103103
create-args: >-
104-
python=3.11
104+
python=3.12
105105
anaconda-client
106106
107107
- name: Remove test package upload

.github/workflows/remove-wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
with:
3636
environment-name: remove-wheels
3737
create-args: >-
38-
python=3.11
39-
anaconda-client=1.12.1
38+
python=3.12
39+
anaconda-client=1.12.3
4040
curl
4141
jq
4242

cmd.sh

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -67,70 +67,6 @@ micromamba activate upload-nightly-action
6767
# trim trailing slashes from $INPUT_ARTIFACTS_PATH
6868
INPUT_ARTIFACTS_PATH="${INPUT_ARTIFACTS_PATH%/}"
6969

70-
get_wheel_name_version() {
71-
local wheel_name="$1"
72-
if [[ "${wheel_name}" =~ ^([[:alnum:]_-]+)-([0-9][^-]+)-(.+)$ ]]; then
73-
# return the package_name and version_number
74-
local return_values=("${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
75-
echo "${return_values[@]}"
76-
else
77-
echo "The wheel name ${1} does not follow the PEP 491 spec (https://peps.python.org/pep-0491/) and is invalid."
78-
return 1
79-
fi
80-
}
81-
82-
# get the unique package names from all the wheels
83-
package_names=()
84-
for wheel_path in "${INPUT_ARTIFACTS_PATH}"/*.whl; do
85-
# remove the INPUT_ARTIFACTS_PATH/ prefix (including the /)
86-
wheel_name="${wheel_path#${INPUT_ARTIFACTS_PATH}/}"
87-
read -r package_basename_prefix _ <<< "$(get_wheel_name_version ${wheel_name})"
88-
package_names+=("${package_basename_prefix}")
89-
done
90-
package_names=($(tr ' ' '\n' <<< "${package_names[@]}" | sort --unique | tr '\n' ' '))
91-
92-
# If the package version doesn't exist on the package index then there will
93-
# be no files to overwrite and the package can be uploaded safely.
94-
# If the package version exists, is the only version on the package index,
95-
# and only has one distribution file, then that package needs to be removed
96-
# from the index before a wheel of the same name can be uploaded again.
97-
# c.f. https://github.com/Anaconda-Platform/anaconda-client/issues/702
98-
99-
for package_basename_prefix in "${package_names[@]}"; do
100-
# normalize package_name to use '-' as delimiter
101-
package_name="${package_basename_prefix//_/-}"
102-
103-
number_releases=$(curl --silent https://api.anaconda.org/package/"${ANACONDA_ORG}/${package_name}" | \
104-
jq -r '.releases' | \
105-
jq length)
106-
107-
if [ "${number_releases}" -eq 1 ]; then
108-
# get any wheel for the package (they should all have the same version)
109-
wheel_path=$(find "${INPUT_ARTIFACTS_PATH}" -name "${package_basename_prefix}-*.whl" -print -quit)
110-
wheel_name="${wheel_path#${INPUT_ARTIFACTS_PATH}/}"
111-
read -r _ package_version <<< "$(get_wheel_name_version ${wheel_name})"
112-
113-
number_files=$(curl --silent https://api.anaconda.org/release/"${ANACONDA_ORG}/${package_name}/${package_version}" | \
114-
jq -r '.distributions' | \
115-
jq length)
116-
117-
if [ "${number_files}" -eq 1 ]; then
118-
distribution_name=$(curl --silent https://api.anaconda.org/release/"${ANACONDA_ORG}/${package_name}/${package_version}" | \
119-
jq -r '.distributions[].basename')
120-
121-
if [ "${wheel_name}" = "${distribution_name}" ]; then
122-
echo -e "\n# ${distribution_name} is the only distribution file uploaded for the package https://anaconda.org/${ANACONDA_ORG}/${package_name}"
123-
echo "# To avoid https://github.com/Anaconda-Platform/anaconda-client/issues/702 remove the existing release before uploading."
124-
125-
echo -e "\n# Removing ${ANACONDA_ORG}/${package_name}/${package_version}"
126-
anaconda --token "${ANACONDA_TOKEN}" remove \
127-
--force \
128-
"${ANACONDA_ORG}/${package_name}/${package_version}"
129-
fi
130-
fi
131-
fi
132-
done
133-
13470
# upload wheels
13571
echo "Uploading wheels to anaconda.org..."
13672

0 commit comments

Comments
 (0)