@@ -67,17 +67,36 @@ trap on_exit EXIT SIGINT SIGTERM
6767
6868start_local_wheel_server () {
6969 local serve_dir=" ${1:- $OUTDIR / wheels-repo/ } "
70- # Start a web server for the wheels-repo. We remember the PID so we
71- # can stop it later, and we determine the primary IP of the host
72- # because podman won't see the server via localhost.
73- python3 -m http.server --directory " $serve_dir " 9999 &
74- HTTP_SERVER_PID= $!
75- if which ip 2>&1 > /dev/null; then
76- # Linux: need host IP because podman can't reach localhost
70+ # Determine the bind address and the URL that clients will use.
71+ # On Linux podman can't reach localhost, so we bind to 0.0.0.0 and
72+ # advertise the host's routable IP. On macOS there is no network
73+ # isolation; we bind explicitly to 127.0.0.1 to avoid IPv6-only
74+ # sockets that python3 -m http.server may create by default.
75+ if command -v ip > /dev/null 2>&1 ; then
76+ local BIND_ADDR= " 0.0.0.0 "
7777 IP=$( ip route get 1.1.1.1 | grep 1.1.1.1 | awk ' {print $7}' )
7878 else
79- # macOS: no network isolation, localhost works
79+ local BIND_ADDR= " 127.0.0.1 "
8080 IP=127.0.0.1
8181 fi
82+ python3 -m http.server --bind " $BIND_ADDR " --directory " $serve_dir " 9999 &
83+ HTTP_SERVER_PID=$!
8284 export WHEEL_SERVER_URL=" http://${IP} :9999/simple"
85+
86+ # Wait for the server to accept connections (up to 15 s).
87+ { set +x; } 2> /dev/null
88+ local ready=false
89+ for _ in $( seq 1 30) ; do
90+ kill -0 " $HTTP_SERVER_PID " 2> /dev/null || break
91+ curl -sf " http://${IP} :9999/" > /dev/null 2>&1 && { ready=true; break ; }
92+ sleep 0.5
93+ done
94+ set -x
95+
96+ if $ready ; then
97+ echo " Wheel server is ready"
98+ return 0
99+ fi
100+ echo " ERROR: wheel server did not become ready" >&2
101+ return 1
83102}
0 commit comments