From 391d29fe4fc06b89d7caf690d37a47a2fc17b08e Mon Sep 17 00:00:00 2001
From: Anthony Wu <462072+anthonywu@users.noreply.github.com>
Date: Thu, 7 Nov 2024 00:01:54 -0800
Subject: [PATCH 1/3] solve python 3.13 pip install
---
README.md | 10 ++++++++++
pyproject.toml | 12 ++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index efcd1996..f1243584 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,16 @@ uv tool install --upgrade mflux
to get the `mflux-generate` and related command line executables. You can skip to the usage guides below.
+
+For Python 3.13 dev preview
+```sh
+uv venv --python 3.13
+python -V # e.g. Python 3.13.0rc2
+source .venv/bin/activate
+uv pip install --pre --extra-index-url https://download.pytorch.org/whl/nightly -e .
+```
+
+
For the classic way to create a user virtual environment:
diff --git a/pyproject.toml b/pyproject.toml
index b4cc8fd1..60ca5c0a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -14,14 +14,18 @@ license = { file = "LICENSE" }
requires-python = ">=3.10"
dependencies = [
"huggingface-hub>=0.24.5,<1.0",
- "mlx>=0.16.0,<1.0",
+ "mlx>=0.20.0,<1.0",
"numpy>=2.0.1,<3.0",
"opencv-python>=4.10.0,<5.0",
"piexif>=1.1.3,<2.0",
- "pillow>=10.4.0,<11.0",
+ "pillow>=10.4.0,<11.0; python_version<'3.13'",
+ "pillow>=11.0,<12.0; python_version>='3.13'",
"safetensors>=0.4.4,<1.0",
- "sentencepiece>=0.2.0,<1.0",
- "torch>=2.3.1,<3.0",
+ "sentencepiece>=0.2.0,<1.0; python_version<'3.13'",
+ "tokenizers>=0.20.3; python_version>='3.13'", # transformers -> tokenizers
+ "torch>=2.3.1,<3.0; python_version<'3.13'",
+ # torch dev builds: pip install --pre --index-url https://download.pytorch.org/whl/nightly
+ "torch>=2.6.0.dev20241106; python_version>='3.13'",
"tqdm>=4.66.5,<5.0",
"transformers>=4.44.0,<5.0",
]
From 48d2e712074c910f1d4501f8131c664cb323e838 Mon Sep 17 00:00:00 2001
From: Anthony Wu <462072+anthonywu@users.noreply.github.com>
Date: Fri, 8 Nov 2024 00:51:53 -0800
Subject: [PATCH 2/3] add dev note that community whl is available now
---
pyproject.toml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pyproject.toml b/pyproject.toml
index 60ca5c0a..ef61272d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,9 @@ dependencies = [
"pillow>=10.4.0,<11.0; python_version<'3.13'",
"pillow>=11.0,<12.0; python_version>='3.13'",
"safetensors>=0.4.4,<1.0",
+ # python 3.13 workaround for now:
+ # use temporary community build of py13 wheel, use until official project build
+ # uv pip install https://github.com/anthonywu/sentencepiece/releases/download/0.2.1-py13dev/sentencepiece-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
"sentencepiece>=0.2.0,<1.0; python_version<'3.13'",
"tokenizers>=0.20.3; python_version>='3.13'", # transformers -> tokenizers
"torch>=2.3.1,<3.0; python_version<'3.13'",
From 08b390dc7ba7d9c0eb3a9170e33f1d2141d7d4d5 Mon Sep 17 00:00:00 2001
From: Anthony Wu
Date: Sat, 9 Nov 2024 08:19:02 -0800
Subject: [PATCH 3/3] more details for usage
---
README.md | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/README.md b/README.md
index f1243584..ead593df 100644
--- a/README.md
+++ b/README.md
@@ -57,10 +57,18 @@ to get the `mflux-generate` and related command line executables. You can skip t
For Python 3.13 dev preview
+
+The [T5 encoder](https://huggingface.co/docs/transformers/en/model_doc/t5) is dependent on [sentencepiece](https://pypi.org/project/sentencepiece/), which does not have a installable wheel artifact for Python 3.13 as of Nov 2024. Until Google [publishes a 3.13 wheel](https://pypi.org/project/sentencepiece/), you need to build your own wheel with [official build instructions](https://github.com/google/sentencepiece/blob/master/python/README.md#build-and-install-sentencepiece) or for your convenience use a `.whl` pre-built by contributor @anthonywu. The steps below should work for most developers though your system may vary.
+
```sh
uv venv --python 3.13
python -V # e.g. Python 3.13.0rc2
source .venv/bin/activate
+
+# for your convenience, you can use the contributor wheel
+uv pip install https://github.com/anthonywu/sentencepiece/releases/download/0.2.1-py13dev/sentencepiece-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
+
+# enable the pytorch nightly
uv pip install --pre --extra-index-url https://download.pytorch.org/whl/nightly -e .
```