Repair demo with patched CPU-only dependencies

#1
by tomrb - opened
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim@sha256:b18b261e1b4974b4f321451ad5251ded85abb22c2b8b262da527dda1d031ab30
2
+ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 YOLO_AUTOINSTALL=false MPLBACKEND=Agg
3
+ WORKDIR /app
4
+ COPY requirements.txt ./
5
+ RUN pip install --no-cache-dir --only-binary=:all: -r requirements.txt && useradd --create-home --uid 1000 app
6
+ COPY --chown=app:app . .
7
+ USER app
8
+ EXPOSE 7860
9
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -3,8 +3,8 @@ title: YOLOv8-TO Demo
3
  emoji: 🏗️
4
  colorFrom: yellow
5
  colorTo: green
6
- sdk: gradio
7
- app_file: app.py
8
  pinned: false
9
  ---
10
 
 
3
  emoji: 🏗️
4
  colorFrom: yellow
5
  colorTo: green
6
+ sdk: docker
7
+ app_port: 7860
8
  pinned: false
9
  ---
10
 
SECURITY-DEPLOYMENT.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Demo deployment update
2
+
3
+ This proposal moves the demo from Gradio to a CPU-only Docker Space using FastAPI. Gradio's current Pillow restriction conflicts with a patched Pillow release. The original deployment also ran pip at startup and failed while installing CUDA packages. Upload, confidence and IoU controls are retained; PNG/JPEG images are limited to one million pixels and 10 MiB, and the server handles one inference at a time. A request with no detected objects returns an explanatory message.
4
+
5
+ The fixed nano checkpoint is checked against its SHA-256 digest before loading using PyTorch's weights-only loader with a fixed class allowlist. Changing the checkpoint requires reviewing it and updating the digest and allowlist. The base Python image and Python dependencies are pinned. The published CPU PyTorch wheels use local version suffixes; an advisory audit compared their base versions and found no known vulnerabilities among the 47 dependencies. This does not prove the absence of vulnerabilities.
6
+
7
+ The sample image completed the full CPU inference and HTTP upload path in a network-isolated local environment. Invalid images, size and threshold limits, and model digest rejection were also checked. The Docker image has not been built or deployed here; review the Space build logs and test the deployed demo after merging. This changes the Space SDK and user interface, and it does not update the separate GitHub repository.
app.py CHANGED
@@ -1,57 +1,105 @@
1
- import gradio as gr
 
 
 
2
  import sys
3
- sys.path.append('./utils')
 
 
4
 
5
- from yolo_utils import preprocess_image_pil, run_model, process_results, plot_results_gradio
6
- import matplotlib.pyplot as plt
7
- import io
8
- try:
9
- from ultralytics import YOLO
10
- except ImportError:
11
- import os
12
- os.system('pip install ./yolov8-to')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  from ultralytics import YOLO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- def process_image(image,conf,iou):
16
- model = YOLO('./trained_models/nano.pt')
17
- # Preprocess the image
18
- preprocessed_image = preprocess_image_pil(image, threshold_value=0.9, upscale=False)
19
-
20
- # Run the model
21
- results = run_model(model, preprocessed_image, conf=conf, iou=iou, imgsz=640)
22
-
23
- # Process the results
24
- input_image_array_tensor, seg_result, pred_Phi, sum_pred_H, final_H, dice_loss, tversky_loss = process_results(results, preprocessed_image)
25
-
26
- # Plot the results
27
- fig = plot_results_gradio(input_image_array_tensor, seg_result, pred_Phi, sum_pred_H, final_H, dice_loss, tversky_loss)
28
-
29
- # Convert the plot to an image
30
-
31
- return fig
32
-
33
- # Create the Gradio interface
34
- title = "YOLOV8-TO Demo App"
35
- description = """
36
- - **Upload an image** and see the processed results. You can replace the default image with whatever you want to upload.
37
- - **Adjust the confidence and IOU thresholds** as needed.
38
- - Runs the **YOLOv8-TO Nano model size**.
39
- - **Runs on 2 CPU cores**, so please be patient!
40
- - For more details, check out the [GitHub repository](https://github.com/COSIM-Lab/YOLOv8-TO).
41
- - Learn more about the methodology in the related [research paper](https://arxiv.org/abs/2404.18763).
42
- """
43
-
44
-
45
- iface = gr.Interface(
46
- fn=process_image,
47
- inputs=[
48
- gr.Image(type='pil',value ="https://huggingface.co/spaces/tomrb/YOLOv8-TO/resolve/main/test.png", label="Input Image"),
49
- gr.Slider(minimum=0, maximum=1, value=0.1, label="Confidence Threshold"),
50
- gr.Slider(minimum=0, maximum=1, value=0.5, label="IOU Threshold")
51
- ],
52
- outputs="image",
53
- title=title,
54
- description=description
55
- )
56
-
57
- iface.launch()
 
1
+ """CPU-only YOLOv8-TO demo."""
2
+ import hashlib
3
+ import io
4
+ import os
5
  import sys
6
+ import threading
7
+ from functools import lru_cache
8
+ from pathlib import Path
9
 
10
+ from fastapi import FastAPI, HTTPException, Query, Request
11
+ from fastapi.responses import HTMLResponse, Response
12
+ from PIL import Image, UnidentifiedImageError
13
+ from starlette.concurrency import run_in_threadpool
14
+
15
+ ROOT = Path(__file__).resolve().parent
16
+ MODEL = ROOT / 'trained_models' / 'nano.pt'
17
+ MODEL_SHA256 = '4b0860de0cb2c30aac0644adced485a5c0579d6acae413612ee16dd450de88ef'
18
+ MAX_BYTES = 10 * 1024 * 1024
19
+ MAX_PIXELS = 1_000_000
20
+ Image.MAX_IMAGE_PIXELS = MAX_PIXELS
21
+ os.environ['YOLO_AUTOINSTALL'] = 'false'
22
+ os.environ.setdefault('MPLBACKEND', 'Agg')
23
+ os.environ.setdefault('YOLO_CONFIG_DIR', '/tmp/yolo-config')
24
+ os.environ.setdefault('MPLCONFIGDIR', '/tmp/matplotlib')
25
+ sys.path[:0] = [str(ROOT / 'yolov8-to'), str(ROOT / 'utils')]
26
+ app = FastAPI()
27
+ processing = threading.BoundedSemaphore(1)
28
+
29
+
30
+ @lru_cache(maxsize=1)
31
+ def load_model():
32
+ if hashlib.sha256(MODEL.read_bytes()).hexdigest() != MODEL_SHA256:
33
+ raise RuntimeError('Model digest does not match the trusted checkpoint')
34
+ import torch
35
  from ultralytics import YOLO
36
+ from ultralytics.nn.modules.block import DFL, Bottleneck, C2f, Proto, SPPF
37
+ from ultralytics.nn.modules.conv import Concat, Conv
38
+ from ultralytics.nn.modules.head import Detect, ExtendedSegment
39
+ from ultralytics.nn.tasks import SegmentationModel
40
+ from ultralytics.utils import IterableSimpleNamespace
41
+ from ultralytics.utils.loss import BboxLoss, CustomDiceLoss, v8SegmentationLoss
42
+ from ultralytics.utils.tal import TaskAlignedAssigner
43
+ from torch.nn import (SiLU, BatchNorm2d, Sigmoid, ModuleList, Upsample,
44
+ Sequential, ConvTranspose2d, MaxPool2d,
45
+ BCEWithLogitsLoss, Conv2d)
46
+ allowed = [DFL, Bottleneck, C2f, Proto, SPPF, Concat, Conv, Detect,
47
+ ExtendedSegment, SegmentationModel, SiLU, IterableSimpleNamespace,
48
+ BboxLoss, CustomDiceLoss, v8SegmentationLoss, TaskAlignedAssigner,
49
+ BatchNorm2d, Sigmoid, ModuleList, Upsample, Sequential,
50
+ ConvTranspose2d, MaxPool2d, BCEWithLogitsLoss, Conv2d, getattr]
51
+ with torch.serialization.safe_globals(allowed):
52
+ return YOLO(str(MODEL))
53
+
54
+
55
+ def infer(image, conf, iou):
56
+ import torch
57
+ from yolo_utils import preprocess_image_pil, run_model, process_results, plot_results_gradio
58
+ image = preprocess_image_pil(image)
59
+ with torch.inference_mode():
60
+ results = run_model(load_model(), image, conf=conf, iou=iou, imgsz=640)
61
+ if len(results[0].boxes) == 0:
62
+ raise HTTPException(422, 'No objects were detected. Try a lower confidence threshold.')
63
+ output = plot_results_gradio(*process_results(results, image))
64
+ buffer = io.BytesIO()
65
+ output.save(buffer, format='PNG')
66
+ output.close()
67
+ return buffer.getvalue()
68
+
69
+
70
+ @app.get('/', response_class=HTMLResponse)
71
+ def index():
72
+ return '''<!doctype html><html><head><title>YOLOv8-TO demo</title></head><body>
73
+ <h1>YOLOv8-TO demo</h1><p>Upload an image and adjust the thresholds. Inference runs on CPU and may take a while.</p>
74
+ <form id="form"><input id="file" type="file" accept="image/png,image/jpeg" required>
75
+ <p><label>Confidence <input id="conf" type="number" min="0" max="1" step="0.05" value="0.1"></label></p>
76
+ <p><label>IoU <input id="iou" type="number" min="0" max="1" step="0.05" value="0.5"></label></p>
77
+ <button>Run</button></form><p id="status"></p><img id="result" style="max-width:100%">
78
+ <p><a href="https://github.com/COSIM-Lab/YOLOv8-TO">Source</a> · <a href="https://arxiv.org/abs/2404.18763">Research paper</a></p>
79
+ <script>document.getElementById('form').onsubmit=async e=>{e.preventDefault();const s=document.getElementById('status');s.textContent='Processing…';try{const f=document.getElementById('file').files[0];const q=new URLSearchParams({conf:document.getElementById('conf').value,iou:document.getElementById('iou').value});const r=await fetch('/predict?'+q,{method:'POST',body:f,headers:{'Content-Type':f.type}});if(!r.ok){const x=await r.json();throw new Error(x.detail||'Request failed')}document.getElementById('result').src=URL.createObjectURL(await r.blob());s.textContent='Done';}catch(err){s.textContent=err.message}};</script></body></html>'''
80
+
81
 
82
+ @app.post('/predict')
83
+ async def predict(request: Request, conf: float = Query(0.1, ge=0, le=1), iou: float = Query(0.5, ge=0, le=1)):
84
+ data = bytearray()
85
+ async for chunk in request.stream():
86
+ if len(data) + len(chunk) > MAX_BYTES:
87
+ raise HTTPException(413, 'Image is too large')
88
+ data.extend(chunk)
89
+ try:
90
+ with Image.open(io.BytesIO(data)) as source:
91
+ if source.format not in ('PNG', 'JPEG'):
92
+ raise HTTPException(415, 'Upload a PNG or JPEG image')
93
+ if source.width * source.height > MAX_PIXELS:
94
+ raise HTTPException(413, 'Image dimensions are too large')
95
+ image = source.convert('RGB')
96
+ except (UnidentifiedImageError, OSError, Image.DecompressionBombError):
97
+ raise HTTPException(400, 'Invalid image')
98
+ if not processing.acquire(blocking=False):
99
+ raise HTTPException(429, 'The demo is busy; please try again')
100
+ try:
101
+ result = await run_in_threadpool(infer, image, conf, iou)
102
+ return Response(result, media_type='image/png', headers={'Cache-Control': 'no-store'})
103
+ finally:
104
+ processing.release()
105
+ image.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1 +1,48 @@
1
- torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cpu
2
+ annotated-doc==0.0.5
3
+ annotated-types==0.8.0
4
+ anyio==4.16.0
5
+ certifi==2026.10.23
6
+ charset-normalizer==3.5.2
7
+ click==8.5.0
8
+ contourpy==1.4.0
9
+ cycler==0.12.1
10
+ fastapi==0.162.0
11
+ filelock==4.2.7
12
+ fonttools==4.68.0
13
+ fsspec==2026.9.0
14
+ h11==0.16.0
15
+ idna==3.20
16
+ jinja2==3.1.6
17
+ kiwisolver==1.5.1
18
+ markupsafe==3.0.4
19
+ matplotlib==3.11.2
20
+ mpmath==1.3.0
21
+ networkx==3.7
22
+ numpy==2.5.4
23
+ opencv-python-headless==5.0.0.93
24
+ opentelemetry-api==1.45.2
25
+ packaging==26.3
26
+ pandas==3.1.0
27
+ pillow==13.0.0
28
+ psutil==7.2.2
29
+ py-cpuinfo==9.0.0
30
+ pydantic==2.14.2
31
+ pydantic-core==2.50.2
32
+ pyparsing==3.3.3
33
+ python-dateutil==4.0.0
34
+ pyyaml==6.0.3
35
+ requests==2.34.2
36
+ scipy==1.18.1
37
+ seaborn==0.13.2
38
+ setuptools==84.2.1
39
+ starlette==1.10.0
40
+ sympy==1.14.0
41
+ torch==2.15.0+cpu
42
+ torchvision==0.29.1+cpu
43
+ tqdm==4.70.1
44
+ typing-extensions==4.16.0
45
+ typing-inspection==0.4.4
46
+ tzdata==2026.6
47
+ urllib3==2.8.0
48
+ uvicorn==0.54.0
yolov8-to/setup.py CHANGED
@@ -3,14 +3,15 @@
3
  import re
4
  from pathlib import Path
5
 
6
- import pkg_resources as pkg
7
  from setuptools import find_packages, setup
8
 
9
  # Settings
10
  FILE = Path(__file__).resolve()
11
  PARENT = FILE.parent # root directory
12
  README = (PARENT / 'README.md').read_text(encoding='utf-8')
13
- REQUIREMENTS = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements((PARENT / 'requirements.txt').read_text())]
 
 
14
 
15
 
16
  def get_version():
@@ -21,7 +22,7 @@ def get_version():
21
  setup(
22
  name='ultralyticscustom', # name of pypi package
23
  version=get_version(), # version of pypi package
24
- python_requires='>=3.8',
25
  license='AGPL-3.0',
26
  description=('Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, '
27
  'pose estimation and image classification.'),
 
3
  import re
4
  from pathlib import Path
5
 
 
6
  from setuptools import find_packages, setup
7
 
8
  # Settings
9
  FILE = Path(__file__).resolve()
10
  PARENT = FILE.parent # root directory
11
  README = (PARENT / 'README.md').read_text(encoding='utf-8')
12
+ REQUIREMENTS = [line.split(' #', 1)[0].strip() for line in
13
+ (PARENT / 'requirements.txt').read_text().splitlines()
14
+ if line.strip() and not line.lstrip().startswith('#')]
15
 
16
 
17
  def get_version():
 
22
  setup(
23
  name='ultralyticscustom', # name of pypi package
24
  version=get_version(), # version of pypi package
25
+ python_requires='>=3.11',
26
  license='AGPL-3.0',
27
  description=('Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, '
28
  'pose estimation and image classification.'),
yolov8-to/ultralytics/engine/exporter.py CHANGED
@@ -731,9 +731,9 @@ class Exporter:
731
  LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
732
  f = str(tflite_model).replace('.tflite', '_edgetpu.tflite') # Edge TPU model
733
 
734
- cmd = f'edgetpu_compiler -s -d -k 10 --out_dir "{Path(f).parent}" "{tflite_model}"'
735
- LOGGER.info(f"{prefix} running '{cmd}'")
736
- subprocess.run(cmd, shell=True)
737
  self._add_tflite_metadata(f)
738
  return f, None
739
 
@@ -755,9 +755,10 @@ class Exporter:
755
  LOGGER.info(f'\n{prefix} output node names: {outputs}')
756
 
757
  with spaces_in_path(f_pb) as fpb_, spaces_in_path(f) as f_: # exporter can not handle spaces in path
758
- cmd = f'tensorflowjs_converter --input_format=tf_frozen_model --output_node_names={outputs} "{fpb_}" "{f_}"'
759
- LOGGER.info(f"{prefix} running '{cmd}'")
760
- subprocess.run(cmd, shell=True)
 
761
 
762
  if ' ' in str(f):
763
  LOGGER.warning(f"{prefix} WARNING ⚠️ your model may not work correctly with spaces in path '{f}'.")
 
731
  LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
732
  f = str(tflite_model).replace('.tflite', '_edgetpu.tflite') # Edge TPU model
733
 
734
+ cmd = ['edgetpu_compiler', '-s', '-d', '-k', '10', '--out_dir', str(Path(f).parent), str(tflite_model)]
735
+ LOGGER.info(f"{prefix} running {cmd!r}")
736
+ subprocess.run(cmd, check=True)
737
  self._add_tflite_metadata(f)
738
  return f, None
739
 
 
755
  LOGGER.info(f'\n{prefix} output node names: {outputs}')
756
 
757
  with spaces_in_path(f_pb) as fpb_, spaces_in_path(f) as f_: # exporter can not handle spaces in path
758
+ cmd = ['tensorflowjs_converter', '--input_format=tf_frozen_model', f'--output_node_names={outputs}',
759
+ str(fpb_), str(f_)]
760
+ LOGGER.info(f"{prefix} running {cmd!r}")
761
+ subprocess.run(cmd, check=True)
762
 
763
  if ' ' in str(f):
764
  LOGGER.warning(f"{prefix} WARNING ⚠️ your model may not work correctly with spaces in path '{f}'.")
yolov8-to/ultralytics/utils/callbacks/dvc.py CHANGED
@@ -4,7 +4,7 @@ import os
4
  import re
5
  from pathlib import Path
6
 
7
- import pkg_resources as pkg
8
 
9
  from ultralytics.utils import LOGGER, SETTINGS, TESTS_RUNNING
10
  from ultralytics.utils.torch_utils import model_info_for_loggers
@@ -18,7 +18,7 @@ try:
18
  assert SETTINGS['dvc'] is True # verify integration is enabled
19
 
20
  ver = version('dvclive')
21
- if pkg.parse_version(ver) < pkg.parse_version('2.11.0'):
22
  LOGGER.debug(f'DVCLive is detected but version {ver} is incompatible (>=2.11 required).')
23
  dvclive = None # noqa: F811
24
  except (ImportError, AssertionError, TypeError):
 
4
  import re
5
  from pathlib import Path
6
 
7
+ from packaging.version import parse as parse_version
8
 
9
  from ultralytics.utils import LOGGER, SETTINGS, TESTS_RUNNING
10
  from ultralytics.utils.torch_utils import model_info_for_loggers
 
18
  assert SETTINGS['dvc'] is True # verify integration is enabled
19
 
20
  ver = version('dvclive')
21
+ if parse_version(ver) < parse_version('2.11.0'):
22
  LOGGER.debug(f'DVCLive is detected but version {ver} is incompatible (>=2.11 required).')
23
  dvclive = None # noqa: F811
24
  except (ImportError, AssertionError, TypeError):
yolov8-to/ultralytics/utils/checks.py CHANGED
@@ -7,14 +7,16 @@ import os
7
  import platform
8
  import re
9
  import shutil
 
10
  import subprocess
 
11
  import time
12
  from pathlib import Path
13
  from typing import Optional
14
 
15
  import cv2
16
  import numpy as np
17
- import pkg_resources as pkg
18
  import psutil
19
  import requests
20
  import torch
@@ -286,7 +288,7 @@ def check_requirements(requirements=ROOT.parent / 'requirements.txt', exclude=()
286
  try:
287
  t = time.time()
288
  assert is_online(), 'AutoUpdate skipped (offline)'
289
- LOGGER.info(subprocess.check_output(f'pip install --no-cache {s} {cmds}', shell=True).decode())
290
  dt = time.time() - t
291
  LOGGER.info(
292
  f"{prefix} AutoUpdate success ✅ {dt:.1f}s, installed {n} package{'s' * (n > 1)}: {pkgs}\n"
@@ -485,7 +487,7 @@ def check_amp(model):
485
  def git_describe(path=ROOT): # path must be a directory
486
  """Return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe."""
487
  with contextlib.suppress(Exception):
488
- return subprocess.check_output(f'git -C {path} describe --tags --long --always', shell=True).decode()[:-1]
489
  return ''
490
 
491
 
 
7
  import platform
8
  import re
9
  import shutil
10
+ import shlex
11
  import subprocess
12
+ import sys
13
  import time
14
  from pathlib import Path
15
  from typing import Optional
16
 
17
  import cv2
18
  import numpy as np
19
+ from ultralytics.utils import package_compat as pkg
20
  import psutil
21
  import requests
22
  import torch
 
288
  try:
289
  t = time.time()
290
  assert is_online(), 'AutoUpdate skipped (offline)'
291
+ LOGGER.info(subprocess.check_output([sys.executable, "-m", "pip", "install", "--no-cache", *pkgs, *shlex.split(cmds)]).decode())
292
  dt = time.time() - t
293
  LOGGER.info(
294
  f"{prefix} AutoUpdate success ✅ {dt:.1f}s, installed {n} package{'s' * (n > 1)}: {pkgs}\n"
 
487
  def git_describe(path=ROOT): # path must be a directory
488
  """Return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe."""
489
  with contextlib.suppress(Exception):
490
+ return subprocess.check_output(['git', '-C', str(path), 'describe', '--tags', '--long', '--always']).decode().strip()
491
  return ''
492
 
493
 
yolov8-to/ultralytics/utils/downloads.py CHANGED
@@ -270,7 +270,8 @@ def safe_download(url,
270
  """
271
 
272
  # Check if the URL is a Google Drive link
273
- gdrive = 'drive.google.com' in url
 
274
  if gdrive:
275
  url, file = get_google_drive_file_info(url)
276
 
 
270
  """
271
 
272
  # Check if the URL is a Google Drive link
273
+ parsed = parse.urlsplit(str(url))
274
+ gdrive = parsed.scheme in ('http', 'https') and parsed.hostname == 'drive.google.com'
275
  if gdrive:
276
  url, file = get_google_drive_file_info(url)
277
 
yolov8-to/ultralytics/utils/package_compat.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Dependency/version checks without deprecated setuptools pkg_resources."""
2
+
3
+ from importlib import metadata
4
+
5
+ from packaging.requirements import Requirement
6
+ from packaging.version import parse as parse_version
7
+
8
+ DistributionNotFound = metadata.PackageNotFoundError
9
+
10
+
11
+ class VersionConflict(Exception):
12
+ """An installed package does not satisfy a requirement."""
13
+
14
+
15
+ def parse_requirements(lines):
16
+ if isinstance(lines, str):
17
+ lines = lines.splitlines()
18
+ for line in lines:
19
+ line = line.split(" #", 1)[0].strip()
20
+ if line and not line.startswith("#"):
21
+ yield Requirement(line)
22
+
23
+
24
+ def require(specification):
25
+ requirement = Requirement(specification)
26
+ if requirement.marker and not requirement.marker.evaluate():
27
+ return
28
+ installed = metadata.version(requirement.name)
29
+ if requirement.specifier and not requirement.specifier.contains(installed, prereleases=True):
30
+ raise VersionConflict(f"{requirement.name} {installed} does not satisfy {requirement.specifier}")