Skip to content

Commit 1338d7c

Browse files
committed
Update build-local-conda-package to fix some corner case errors
The PyPI URL has changed in the feedstock, plus conda enforces that the minimum python in the pyproject.toml and the conda forge recipe match.
1 parent 26d9986 commit 1338d7c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

scripts/build-local-conda-package.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ function main() {
2222

2323
local package_path="$( get_package_path )"
2424
local package_name="$( basename -- "$package_path")"
25-
local package_version=$( get_package_version "$package_name" )
25+
local package_version="$( get_package_version "$package_name" )"
26+
local python_min_version="$( get_python_min_version )"
2627

2728
tmp_dir="$( mktemp -d --tmpdir "emsarray-conda-build.XXXXXXX" )"
2829
files_to_clean+=( "$tmp_dir" )
2930
cd "$tmp_dir"
3031

3132
cp -R "$feedstock_path/recipe" "$tmp_dir/recipe"
3233
recipe_path="$tmp_dir/recipe/meta.yaml"
33-
update_recipe "$recipe_path" "$package_path" "$package_version"
34+
update_recipe "$recipe_path" "$package_path" "$package_version" "$python_min_version"
3435

3536
cat "$recipe_path"
3637

@@ -57,14 +58,30 @@ function get_package_version() {
5758
echo "$package_version"
5859
}
5960

61+
function get_python_min_version() {
62+
local pyproject_path="$PROJECT/pyproject.toml"
63+
local python_min_version="$( cat "$pyproject_path" \
64+
| grep "requires-python" \
65+
| sed 's!requires-python = "[>=]*\(.*\)".*$!\1!' )"
66+
67+
if [[ -z "$python_min_version" ]] ; then
68+
echo "Could not find requires-python line in pyproject.toml"
69+
exit 1
70+
fi
71+
72+
echo "$python_min_version"
73+
}
74+
6075
function update_recipe() {
6176
local recipe_path="$1"
6277
local package_path="$2"
6378
local package_version="$3"
79+
local python_min_version="$4"
6480

6581
sed \
66-
-e 's!set version = ".*"!set version = "'"$package_version"'"!' \
67-
-e 's!url: https://pypi.io/.*!url: "file://'"$package_path"'"!' \
82+
-e 's!{% set version = .* %}!{% set version = "'"$package_version"'" %}!' \
83+
-e 's!{% set python_min = .* %}!{% set python_min = "'"$python_min_version"'" %}!' \
84+
-e 's!url: https://pypi.org/.*!url: "file://'"$package_path"'"!' \
6885
-e '/sha256:/d' \
6986
-i "$recipe_path"
7087
}

0 commit comments

Comments
 (0)