Skip to content

Commit ff0ecad

Browse files
authored
Merge pull request #149: Make pyproject.toml PEP 517 / 518 / 621–compliant
*Update pyproject.toml and CI* - pyproject.toml is made PEP 517 / 518 / 621–compliant, which makes it easy to inherit dependencies - it is more tool-agnostic (no poetry required & facilitates uv packaging). - Python versions 3.10 up to 3.12 - Tensorflow installation is restricted to python < 3.11 for windows - CI is updated to test more Python versions and to use uv instead of poetry.
2 parents cbc23ed + c6f7813 commit ff0ecad

4 files changed

Lines changed: 103 additions & 83 deletions

File tree

.github/workflows/testing.yml

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,35 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python-version: ["3.10"]
16+
python-version: ["3.10", "3.11", "3.12"]
1717
include:
1818
- os: ubuntu-latest
1919
path: ~/.cache/pip
2020
- os: macos-latest
2121
path: ~/Library/Caches/pip
2222
- os: windows-latest
2323
path: ~\AppData\Local\pip\Cache
24+
exclude:
25+
- os: windows-latest
26+
python-version: "3.11"
27+
- os: windows-latest
28+
python-version: "3.12"
2429

2530
steps:
2631
- name: Checkout code
2732
uses: actions/checkout@v4
2833

29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v4
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v6
3136
with:
37+
enable-cache: true
38+
version: "0.9.5"
3239
python-version: ${{ matrix.python-version }}
3340

34-
- name: Set up Python
35-
uses: conda-incubator/setup-miniconda@v3
36-
with:
37-
channels: conda-forge,defaults
38-
channel-priority: strict
39-
python-version: ${{ matrix.python-version }}
40-
41+
- name: Install the project
42+
run: uv sync --all-extras --dev
43+
shell: bash
44+
4145
- name: Install ffmpeg
4246
run: |
4347
if [ "$RUNNER_OS" == "Linux" ]; then
@@ -49,27 +53,9 @@ jobs:
4953
choco install ffmpeg
5054
fi
5155
shell: bash
52-
53-
- name: Install and test
54-
shell: bash -el {0} # Important: activates the conda environment
55-
run: |
56-
conda install pytables==3.8.0 "numpy<2"
57-
58-
- name: Install dependencies via Conda
59-
shell: bash -el {0}
60-
run: conda install -y "numpy>=1.26,<2.0"
61-
62-
- name: Install Poetry
63-
run: pip install --upgrade pip wheel poetry
64-
65-
- name: Regenerate Poetry lock
66-
run: poetry lock --no-cache
67-
68-
- name: Install project dependencies
69-
run: poetry install --with dev --extras "tf" --extras "pytorch"
7056

7157
- name: Run DLC Live Tests
72-
run: poetry run dlc-live-test --nodisplay
58+
run: uv run dlc-live-test --nodisplay
7359

7460
- name: Run Functional Benchmark Test
75-
run: poetry run pytest tests/test_benchmark_script.py
61+
run: uv run pytest tests/test_benchmark_script.py

dlclive/display.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
Licensed under GNU Lesser General Public License v3.0
66
"""
77

8-
from tkinter import Label, Tk
8+
try:
9+
from tkinter import Label, Tk
10+
from PIL import ImageTk
11+
_TKINTER_AVAILABLE = True
12+
except ImportError:
13+
_TKINTER_AVAILABLE = False
14+
Label = None
15+
Tk = None
16+
ImageTk = None
917

1018
import colorcet as cc
11-
from PIL import Image, ImageDraw, ImageTk
19+
from PIL import Image, ImageDraw
1220

1321

1422
class Display:
@@ -24,6 +32,10 @@ class Display:
2432
"""
2533

2634
def __init__(self, cmap="bmy", radius=3, pcutoff=0.5):
35+
if not _TKINTER_AVAILABLE:
36+
raise ImportError(
37+
"tkinter is not available. Display functionality requires tkinter. "
38+
)
2739
self.cmap = cmap
2840
self.colors = None
2941
self.radius = radius
@@ -61,6 +73,9 @@ def display_frame(self, frame, pose=None):
6173
pose :class:`numpy.ndarray`
6274
the pose estimated by DeepLabCut for the image
6375
"""
76+
if not _TKINTER_AVAILABLE:
77+
raise ImportError("tkinter is not available. Cannot display frames.")
78+
6479
im_size = (frame.shape[1], frame.shape[0])
6580
if pose is not None:
6681
img = Image.fromarray(frame)

pyproject.toml

Lines changed: 70 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,90 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
26
name = "deeplabcut-live"
37
version = "1.1.0"
48
description = "Class to load exported DeepLabCut networks and perform pose estimation on single frames (from a camera feed)"
5-
authors = ["A. & M. Mathis Labs <admin@deeplabcut.org>"]
6-
license = "AGPL-3.0-or-later"
79
readme = "README.md"
8-
homepage = "https://github.com/DeepLabCut/DeepLabCut-live"
9-
repository = "https://github.com/DeepLabCut/DeepLabCut-live"
10+
requires-python = ">=3.10,<3.13"
11+
license = { text = "GNU Affero General Public License v3 or later (AGPLv3+)" }
12+
authors = [
13+
{ name = "A. & M. Mathis Labs", email = "admin@deeplabcut.org" }
14+
]
15+
16+
keywords = ["deeplabcut", "pose-estimation", "real-time", "deep-learning"]
17+
1018
classifiers = [
1119
"Programming Language :: Python :: 3",
1220
"Programming Language :: Python :: 3.10",
1321
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
1423
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
15-
"Operating System :: OS Independent"
24+
"Operating System :: OS Independent",
25+
]
26+
27+
dependencies = [
28+
"numpy>=1.20,<2",
29+
"ruamel.yaml>=0.17.20",
30+
"colorcet>=3.0.0",
31+
"einops>=0.6.1",
32+
"Pillow>=8.0.0",
33+
"py-cpuinfo>=5.0.0",
34+
"tqdm>=4.62.3",
35+
"pandas>=1.0.1,!=1.5.0",
36+
"tables>=3.8",
37+
"opencv-python-headless>=4.5",
38+
"dlclibrary>=0.0.6",
39+
"scipy>=1.9",
40+
"pip",
41+
]
42+
43+
[project.optional-dependencies]
44+
pytorch = [
45+
"timm>=1.0.7",
46+
"torch>=2.0.0",
47+
"torchvision>=0.15",
1648
]
49+
50+
tf = [
51+
"tensorflow>=2.7.0,<2.12; platform_system == 'Linux' and python_version < '3.11'",
52+
"tensorflow>=2.12.0; platform_system == 'Linux' and python_version >= '3.11'",
53+
"tensorflow-macos>=2.7.0,<2.12; platform_system == 'Darwin' and python_version < '3.11'",
54+
"tensorflow-macos>=2.12.0; platform_system == 'Darwin' and python_version >= '3.11'",
55+
# Tensorflow is not supported on Windows with Python >= 3.11
56+
"tensorflow>=2.7,<=2.10; platform_system == 'Windows' and python_version < '3.11'",
57+
"tensorflow-io-gcs-filesystem==0.27; platform_system == 'Windows' and python_version < '3.11'",
58+
"tensorflow-io-gcs-filesystem; platform_system != 'Windows'",
59+
]
60+
61+
[dependency-groups]
62+
dev = [
63+
"pytest",
64+
"black",
65+
"ruff",
66+
]
67+
68+
# Keep only for backward compatibility with Poetry
69+
# (without this section, Poetry assumes the wrong root directory of the project)
70+
[tool.poetry]
1771
packages = [
1872
{ include = "dlclive" }
1973
]
20-
include = ["dlclive/check_install/*"]
2174

22-
[tool.poetry.scripts]
75+
[project.scripts]
2376
dlc-live-test = "dlclive.check_install.check_install:main"
2477
dlc-live-benchmark = "dlclive.benchmark:main"
2578

26-
[tool.poetry.dependencies]
27-
python = ">=3.10,<3.12"
28-
numpy = ">=1.26,<2.0"
29-
"ruamel.yaml" = "^0.17.20"
30-
colorcet = "^3.0.0"
31-
einops = ">=0.6.1"
32-
Pillow = ">=8.0.0"
33-
opencv-python-headless = ">=4.5.0,<5.0.0"
34-
py-cpuinfo = ">=5.0.0"
35-
tqdm = "^4.62.3"
36-
pandas = ">=1.0.1,!=1.5.0"
37-
tables = "^3.8"
38-
pytest = "^8.0"
39-
dlclibrary = ">=0.0.6"
79+
[project.urls]
80+
Homepage = "https://github.com/DeepLabCut/DeepLabCut-live"
81+
Repository = "https://github.com/DeepLabCut/DeepLabCut-live"
4082

41-
# PyTorch models
42-
scipy = ">=1.9"
43-
timm = { version = ">=1.0.7", optional = true }
44-
torch = { version = ">=2.0.0", optional = true }
45-
torchvision = { version = ">=0.15", optional = true }
46-
# TensorFlow models
47-
tensorflow = [
48-
{ version = "^2.7.0,<=2.10", optional = true, platform = "win32" },
49-
{ version = "^2.7.0,<=2.12", optional = true, platform = "linux" },
50-
]
51-
tensorflow-macos = { version = "^2.7.0,<=2.12", optional = true, markers = "sys_platform == 'darwin'" }
52-
tensorflow-io-gcs-filesystem = [
53-
{ version = "==0.27", optional = true, platform = "win32", python = ">=3.10,<3.11" },
54-
{ version = "*", optional = true, platform = "linux" },
55-
{ version = "*", optional = true, markers = "sys_platform == 'darwin'" }
56-
]
83+
[tool.setuptools]
84+
include-package-data = true
5785

58-
[tool.poetry.extras]
59-
tf = [ "tensorflow", "tensorflow-macos", "tensorflow-io-gcs-filesystem"]
60-
pytorch = ["scipy", "timm", "torch", "torchvision"]
86+
[tool.setuptools.packages.find]
87+
include = ["dlclive*"]
6188

62-
[tool.poetry.group.dev.dependencies]
63-
64-
[build-system]
65-
requires = ["poetry-core>=1.0.0"]
66-
build-backend = "poetry.core.masonry.api"
89+
[tool.setuptools.package-data]
90+
dlclive = ["check_install/*"]

reinstall.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)