From 81b8490b10cbb7afe3d219bac85571aa2a76f619 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Thu, 17 Apr 2025 12:51:35 +0200 Subject: [PATCH] python312Packages.unsloth-zoo: init at 2025.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: GaƩtan Lepage <33058747+GaetanLepage@users.noreply.github.com> Co-authored-by: OTABI Tomoya --- .../python-modules/unsloth-zoo/default.nix | 86 +++++++++++++++++++ .../unsloth-zoo/dont-require-unsloth.patch | 18 ++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 106 insertions(+) create mode 100644 pkgs/development/python-modules/unsloth-zoo/default.nix create mode 100644 pkgs/development/python-modules/unsloth-zoo/dont-require-unsloth.patch diff --git a/pkgs/development/python-modules/unsloth-zoo/default.nix b/pkgs/development/python-modules/unsloth-zoo/default.nix new file mode 100644 index 000000000000..163361671cae --- /dev/null +++ b/pkgs/development/python-modules/unsloth-zoo/default.nix @@ -0,0 +1,86 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + + # build-system + setuptools, + setuptools-scm, + + # dependencies + accelerate, + cut-cross-entropy, + datasets, + hf-transfer, + huggingface-hub, + packaging, + peft, + psutil, + sentencepiece, + torch, + tqdm, + transformers, + trl, + tyro, +}: + +buildPythonPackage rec { + pname = "unsloth-zoo"; + version = "2025.4.1"; + pyproject = true; + + # no tags on GitHub + src = fetchPypi { + pname = "unsloth_zoo"; + inherit version; + hash = "sha256-mRs/NMCNJWT52S7mtbQI332IQR6+/IaL29XmtMOz3fE="; + }; + + # pyproject.toml requires an obsolete version of protobuf, + # but it is not used. + # Upstream issue: https://github.com/unslothai/unsloth-zoo/pull/68 + pythonRelaxDeps = [ + "protobuf" + ]; + + patches = [ + # Avoid circular dependency in Nix, since `unsloth` depends on `unsloth-zoo`. + ./dont-require-unsloth.patch + ]; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + accelerate + cut-cross-entropy + datasets + hf-transfer + huggingface-hub + packaging + peft + psutil + sentencepiece + torch + tqdm + transformers + trl + tyro + ]; + + # No tests + doCheck = false; + + pythonImportsCheck = [ + "unsloth_zoo" + ]; + + meta = { + description = "Utils for Unsloth"; + homepage = "https://github.com/unslothai/unsloth_zoo"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ hoh ]; + }; +} diff --git a/pkgs/development/python-modules/unsloth-zoo/dont-require-unsloth.patch b/pkgs/development/python-modules/unsloth-zoo/dont-require-unsloth.patch new file mode 100644 index 000000000000..6c06b8537115 --- /dev/null +++ b/pkgs/development/python-modules/unsloth-zoo/dont-require-unsloth.patch @@ -0,0 +1,18 @@ +diff --git a/unsloth_zoo/__init__.py b/unsloth_zoo/__init__.py +--- a/unsloth_zoo/__init__.py ++++ b/unsloth_zoo/__init__.py +@@ -17,14 +17,10 @@ + __version__ = "2025.3.17" + + from importlib.util import find_spec +-if find_spec("unsloth") is None: +- raise ImportError("Please install Unsloth via `pip install unsloth`!") + pass + del find_spec + + import os +-if not ("UNSLOTH_IS_PRESENT" in os.environ): +- raise ImportError("Please install Unsloth via `pip install unsloth`!") + pass + + try: diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 10acc3e55614..163f241b590f 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18433,6 +18433,8 @@ self: super: with self; { unrpa = callPackage ../development/python-modules/unrpa { }; + unsloth-zoo = callPackage ../development/python-modules/unsloth-zoo { }; + unstructured = callPackage ../development/python-modules/unstructured { }; unstructured-api-tools = callPackage ../development/python-modules/unstructured-api-tools { };