Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit 6d0d65a

Browse files
chore: adds dynamic README handling and setup script (huggingface#2724)
1 parent 60efd87 commit 6d0d65a

4 files changed

Lines changed: 75 additions & 3 deletions

File tree

docker/Dockerfile.internal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ENV HOME=/home/user_lerobot \
7373
RUN uv venv --python python${PYTHON_VERSION}
7474

7575
# Install Python dependencies for caching
76-
COPY --chown=user_lerobot:user_lerobot pyproject.toml README.md MANIFEST.in ./
76+
COPY --chown=user_lerobot:user_lerobot setup.py pyproject.toml README.md MANIFEST.in ./
7777
COPY --chown=user_lerobot:user_lerobot src/ src/
7878

7979
ARG UNBOUND_DEPS=false

docker/Dockerfile.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ENV HOME=/home/user_lerobot \
5959
RUN uv venv
6060

6161
# Install Python dependencies for caching
62-
COPY --chown=user_lerobot:user_lerobot pyproject.toml README.md MANIFEST.in ./
62+
COPY --chown=user_lerobot:user_lerobot setup.py pyproject.toml README.md MANIFEST.in ./
6363
COPY --chown=user_lerobot:user_lerobot src/ src/
6464

6565
ARG UNBOUND_DEPS=false

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ discord = "https://discord.gg/s3KuuzsPFb"
2727
name = "lerobot"
2828
version = "0.4.3"
2929
description = "🤗 LeRobot: State-of-the-art Machine Learning for Real-World Robotics in Pytorch"
30-
readme = "README.md"
30+
dynamic = ["readme"]
3131
license = { text = "Apache-2.0" }
3232
requires-python = ">=3.10"
3333
authors = [

setup.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2025 The HuggingFace Inc. team. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
from setuptools import setup
17+
18+
19+
def get_version_from_toml() -> str:
20+
"""Return the project's version string parsed from `pyproject.toml`.
21+
22+
The function scans `pyproject.toml` line-by-line looking for a line
23+
that starts with ``version`` (for example: ``version = "1.2.3"``)
24+
and returns the value without surrounding quotes. If no such line is
25+
found a :class:`ValueError` is raised.
26+
27+
Returns:
28+
The version string from `pyproject.toml` (e.g. ``"1.2.3"`` ->
29+
``1.2.3``).
30+
"""
31+
32+
version = None
33+
with open("pyproject.toml", encoding="utf-8") as f:
34+
for line in f:
35+
if line.strip().startswith("version"):
36+
version = line.split("=")[1].strip().strip('"')
37+
break
38+
if version is None:
39+
raise ValueError("Version not found in pyproject.toml")
40+
return version
41+
42+
43+
def read_long_description() -> str:
44+
"""Read and return the project's long description for setup.
45+
46+
This function reads `README.md` and replaces image links that point
47+
to the local `./media/` directory with absolute raw GitHub URLs that
48+
reference the release tag corresponding to the version parsed from
49+
`pyproject.toml` (for example, ``v1.2.3``). The modified README
50+
content is returned as a string suitable for passing to
51+
``setuptools.setup(long_description=...)``.
52+
53+
Returns:
54+
The README content with rewritten media links.
55+
"""
56+
57+
with open("README.md", encoding="utf-8") as f:
58+
content = f.read()
59+
60+
version = get_version_from_toml()
61+
git_tag = f"v{version}"
62+
63+
base_raw_url = f"https://raw.githubusercontent.com/huggingface/lerobot/{git_tag}/"
64+
content = content.replace('src="./media/', f'src="{base_raw_url}media/')
65+
66+
return content
67+
68+
69+
setup(
70+
long_description=read_long_description(),
71+
long_description_content_type="text/markdown",
72+
)

0 commit comments

Comments
 (0)