Unverified Commit 4245e466 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

python3Packages.ty: init at 0.0.20 (#495909)

parents 0efdea81 f06a9f3e
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
{
  buildPythonPackage,
  hatchling,
  lib,
  ty,
}:

buildPythonPackage {
  inherit (ty)
    pname
    version
    src
    meta
    ;
  pyproject = true;

  build-system = [ hatchling ];

  postPatch =
    # Add the path to the ty binary as a fallback after other path search methods have been exhausted
    ''
      substituteInPlace python/ty/_find_ty.py \
        --replace-fail \
        'sysconfig.get_path("scripts", scheme=_user_scheme()),' \
        'sysconfig.get_path("scripts", scheme=_user_scheme()), "${baseNameOf (lib.getExe ty)}",'
    ''
    # Sidestep the maturin build system in favour of reusing the binary already built by nixpkgs,
    # to avoid rebuilding the ty binary for every active python package set.
    + ''
      substituteInPlace pyproject.toml \
        --replace-fail 'requires = ["maturin>=1.0,<2.0"]' 'requires = ["hatchling"]' \
        --replace-fail 'build-backend = "maturin"' 'build-backend = "hatchling.build"'

      cat >> pyproject.toml <<EOF
      [tool.hatch.build]
      packages = ['python/ty']

      EOF
    '';

  postInstall = ''
    mkdir -p $out/bin && ln -s ${lib.getExe ty} $out/bin/ty
  '';

  pythonImportsCheck = [ "ty" ];
}
+2 −0
Original line number Diff line number Diff line
@@ -19685,6 +19685,8 @@ self: super: with self; {
  txzmq = callPackage ../development/python-modules/txzmq { };
  ty = callPackage ../development/python-modules/ty { inherit (pkgs) ty; };
  type-infer = callPackage ../development/python-modules/type-infer { };
  typechecks = callPackage ../development/python-modules/typechecks { };