Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/test_bootstrap_build_tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fromager \
--settings-file="$SCRIPTDIR/bootstrap_settings.yaml" \
bootstrap --cache-wheel-server-url=$WHEEL_SERVER_URL 'stevedore==5.2.0'

if ! grep -q "stevedore: found built wheel on cache server" "$LOGFILE"; then
if ! grep -q "stevedore-5.2.0: found built wheel on cache server" "$LOGFILE"; then
echo "FAIL: Did not find log message found built wheel on cache server in $LOGFILE" 1>&2
pass=false
fi
Expand All @@ -77,7 +77,7 @@ fromager \
--settings-file="$SCRIPTDIR/bootstrap_settings.yaml" \
bootstrap --cache-wheel-server-url=$WHEEL_SERVER_URL 'stevedore==5.2.0'

if ! grep -q "stevedore: found existing wheel " "$LOGFILE"; then
if ! grep -q "stevedore-5.2.0: found existing wheel " "$LOGFILE"; then
echo "FAIL: Did not find log message found existing wheel in $LOGFILE" 1>&2
pass=false
fi
Expand Down
18 changes: 9 additions & 9 deletions e2e/test_bootstrap_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ fromager \
bootstrap --cache-wheel-server-url="https://pypi.org/simple" "$DIST==$VER"

EXPECTED_LOG_MESSAGES=(
"$DIST: looking for existing wheel for version $VER with build tag () in"
"$DIST: found existing wheel"
"$DIST-$VER: looking for existing wheel for version $VER with build tag () in"
"$DIST-$VER: found existing wheel"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
)
for pattern in "${EXPECTED_LOG_MESSAGES[@]}"; do
if ! grep -q "$pattern" "$OUTDIR/bootstrap.log"; then
if ! grep -qF "$pattern" "$OUTDIR/bootstrap.log"; then
echo "FAIL: Did not find log message $pattern in $OUTDIR/bootstrap.log" 1>&2
pass=false
fi
done
$pass

UNEXPECTED_LOG_MESSAGES=(
"$DIST: checking if wheel was already uploaded to https://pypi.org/simple"
"$DIST-$VER: checking if wheel was already uploaded to https://pypi.org/simple"
)

for pattern in "${UNEXPECTED_LOG_MESSAGES[@]}"; do
if grep -q "$pattern" "$OUTDIR/bootstrap.log"; then
if grep -qF "$pattern" "$OUTDIR/bootstrap.log"; then
echo "FAIL: Found log message $pattern in $OUTDIR/bootstrap.log" 1>&2
pass=false
fi
Expand Down Expand Up @@ -105,14 +105,14 @@ done
$pass

UNEXPECTED_LOG_MESSAGES=(
"$DIST: loading build sdist dependencies from build-sdist-requirements.txt"
"$DIST: loading build backend dependencies from build-backend-requirements.txt"
"$DIST: loading build system dependencies from build-system-requirements.txt"
"$DIST-$VER: loading build sdist dependencies from build-sdist-requirements.txt"
"$DIST-$VER: loading build backend dependencies from build-backend-requirements.txt"
"$DIST-$VER: loading build system dependencies from build-system-requirements.txt"
)

for pattern in "${UNEXPECTED_LOG_MESSAGES[@]}"; do
echo $pattern
if grep -q "$pattern" "$OUTDIR/bootstrap.log"; then
if grep -qF "$pattern" "$OUTDIR/bootstrap.log"; then
echo "FAIL: found log message $pattern in $OUTDIR/bootstrap.log" 1>&2
pass=false
fi
Expand Down
2 changes: 1 addition & 1 deletion e2e/test_bootstrap_cooldown_prebuilt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if ! grep -q "new toplevel dependency stevedore resolves to 5.3.0" "$OUTDIR/boot
fi

# The wheel must have been downloaded as a pre-built (not built from source).
if ! grep -q "uses a pre-built wheel" "$OUTDIR/bootstrap.log"; then
if ! grep -q "using pre-built wheel" "$OUTDIR/bootstrap.log"; then
echo "FAIL: stevedore was not downloaded as a pre-built wheel" 1>&2
pass=false
fi
Expand Down
4 changes: 2 additions & 2 deletions e2e/test_bootstrap_prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fromager \
pass=true

# Check for log message that the override is loaded
if ! grep -q "flit_core: new toplevel dependency flit_core<2.0.1 resolves to 2.0" "$OUTDIR/bootstrap.log"; then
if ! grep -q "flit_core-2.0: new toplevel dependency flit_core<2.0.1 resolves to 2.0" "$OUTDIR/bootstrap.log"; then
Comment thread
coderabbitai[bot] marked this conversation as resolved.
echo "FAIL: flit_core did not resolve to 2.0 $OUTDIR/bootstrap.log" 1>&2
pass=false
fi
Expand All @@ -41,7 +41,7 @@ DEBUG_RESOLVER=true fromager \


# Check for log message that the override is loaded
if ! grep -q "flit_core: new toplevel dependency flit_core<2.0.1 resolves to 2.0rc3" "$OUTDIR/bootstrap.log"; then
if ! grep -q "flit_core-2.0rc3: new toplevel dependency flit_core<2.0.1 resolves to 2.0rc3" "$OUTDIR/bootstrap.log"; then
echo "FAIL: flit_core did not resolve to 2.0rc3 $OUTDIR/bootstrap.log" 1>&2
pass=false
fi
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ features = ["docs"]
build = "sphinx-build -M html docs docs/_build -j auto --keep-going {args:--fail-on-warning --fresh-env -n}"

[tool.pytest.ini_options]
testpaths = ["tests"]
markers = [
"network: test that need network access",
]
35 changes: 35 additions & 0 deletions src/fromager/bootstrap_requirement_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ def resolve(
pbi = self.ctx.package_build_info(req)
pre_built = pbi.pre_built

# Check session cache BEFORE the git URL guard so that background
# threads can retrieve pre-cached git URL resolutions (populated by
# Bootstrapper.resolve_versions() on the main thread before bootstrap()
# is called) without hitting the ValueError.
cached_result = self.get_cached_resolution(req, pre_built)
if cached_result is not None:
logger.debug(f"resolved {req} from cache")
return list(cached_result) if return_all_versions else [cached_result[0]]

Comment thread
dhellmann marked this conversation as resolved.
# Git URL source resolution must be handled by Bootstrapper.
# But git URL prebuilt resolution is allowed - we look for wheels on PyPI
# (test mode fallback uses this path).
Expand Down Expand Up @@ -146,6 +155,32 @@ def resolve(
return matching
return [matching[0]]

def get_cached_resolution(
self,
req: Requirement,
pre_built: bool,
) -> list[tuple[str, Version]] | None:
"""Return cached matching versions if this requirement was already resolved.

Returns ``None`` if the requirement has not been resolved yet, allowing
callers to distinguish between "no matching versions" and "not yet resolved".

Used by background threads to retrieve pre-cached git URL resolutions
populated by the main thread before entering the parallel section.

Args:
req: Package requirement
pre_built: Whether looking for prebuilt or source resolution

Returns:
List of (url, version) tuples if previously resolved, None otherwise.
"""
rule_key = (str(req), pre_built)
with self._lock:
if rule_key in self._resolved_rules:
return self._get_matching_versions(req, pre_built)
return None

def _resolve_and_extend(
self,
req: Requirement,
Expand Down
Loading
Loading