Commit 0de1ae02 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files
parent f7f0434d
Loading
Loading
Loading
Loading
+36 −45
Original line number Diff line number Diff line
@@ -2,14 +2,11 @@
  lib,
  stdenv,
  buildPythonPackage,
  fetchPypi,
  fetchFromGitHub,
  fetchpatch,
  pythonOlder,
  writeShellScriptBin,
  gradio,

  # pyproject
  # build-system
  hatchling,
  hatch-requirements-txt,
  hatch-fancy-pypi-readme,
@@ -19,7 +16,7 @@
  nodejs,
  pnpm_9,

  # runtime
  # dependencies
  setuptools,
  aiofiles,
  anyio,
@@ -27,6 +24,7 @@
  fastapi,
  ffmpy,
  gradio-client,
  groovy,
  httpx,
  huggingface-hub,
  importlib-resources,
@@ -53,7 +51,7 @@
  authlib,
  itsdangerous,

  # check
  # tests
  pytestCheckHook,
  hypothesis,
  altair,
@@ -68,42 +66,32 @@
  tqdm,
  transformers,
  vega-datasets,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage rec {
  pname = "gradio";
  version = "5.11.0";
  version = "5.20.0";
  pyproject = true;

  disabled = pythonOlder "3.7";

  # unfortunately no fetchPypi due to https://github.com/gradio-app/gradio/pull/9778
  src = fetchFromGitHub {
    owner = "gradio-app";
    repo = "gradio";
    tag = "gradio@${version}";
    hash = "sha256-HW0J7oSkCo4DIHpU4LUoBZ2jmmrv5Xd64floA4uyo5A=";
    hash = "sha256-gAAyhsnc1LUcAvlUC5hftsWN1kSiRWqcQ4iKGpSIL+U=";
  };

  pnpmDeps = pnpm_9.fetchDeps {
    inherit pname version src;
    hash = "sha256-9fAkP2zV3OfyROdtvmS94ujpkGmlB0wGOaWS13LgJTM=";
    hash = "sha256-y0Bdupn19gEtwatc6Q3KD7aekXDk0xrq04LaG7gxMFI=";
  };

  # fix packaging.ParserSyntaxError, which can't handle comments
  postPatch = ''
    sed -i -e "s/ #.*$//g" requirements*.txt
  '';

  pythonRelaxDeps = [
    "tomlkit"
    "aiofiles"
    "markupsafe"
    "pillow"
  ];

  pythonRemoveDeps = [
    # our package is presented as a binary, not a python lib - and
    # this isn't a real runtime dependency
    "ruff"
  ];
@@ -128,6 +116,7 @@ buildPythonPackage rec {
    fastapi
    ffmpy
    gradio-client
    groovy
    httpx
    huggingface-hub
    importlib-resources
@@ -156,7 +145,8 @@ buildPythonPackage rec {
    itsdangerous
  ];

  nativeCheckInputs = [
  nativeCheckInputs =
    [
      pytestCheckHook
      hypothesis
      altair
@@ -175,7 +165,10 @@ buildPythonPackage rec {

      # mock calls to `shutil.which(...)`
      (writeShellScriptBin "npm" "false")
  ] ++ optional-dependencies.oauth ++ pydantic.optional-dependencies.email;
      writableTmpDirAsHomeHook
    ]
    ++ optional-dependencies.oauth
    ++ pydantic.optional-dependencies.email;

  preBuild = ''
    pnpm build
@@ -191,11 +184,10 @@ buildPythonPackage rec {
  # We additionally xfail FileNotFoundError, since the gradio devs often fail to upload test assets to pypi.
  preCheck =
    ''
      export HOME=$TMPDIR
      cat ${./conftest-skip-network-errors.py} >> test/conftest.py
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
    # OSError: [Errno 24] Too many open files
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      ulimit -n 4096
    '';

@@ -326,8 +318,7 @@ buildPythonPackage rec {
  ];

  # check the binary works outside the build env
  doInstallCheck = true;
  postInstallCheck = ''
  postCheck = ''
    env --ignore-environment $out/bin/gradio environment >/dev/null
  '';