Unverified Commit 4806d202 authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

Merge pull request #333014 from philiptaron/pr-319173/fix-eval

parents 15ae9a17 06d2eb33
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
{
  callPackage,
  lib,
  stdenv,
  fetchFromGitHub,
@@ -9,6 +8,7 @@
  testers,
  nix-update-script,
  maturin,
  python3,
}:

rustPlatform.buildRustPackage rec {
@@ -35,7 +35,16 @@ rustPlatform.buildRustPackage rec {
  passthru = {
    tests = {
      version = testers.testVersion { package = maturin; };
      pyo3 = callPackage ./pyo3-test { };
      pyo3 = python3.pkgs.callPackage ./pyo3-test {
        format = "pyproject";
        buildAndTestSubdir = "examples/word-count";
        preConfigure = "";

        nativeBuildInputs = with rustPlatform; [
          cargoSetupHook
          maturinBuildHook
        ];
      };
    };

    updateScript = nix-update-script { };
+43 −7
Original line number Diff line number Diff line
{ python3, rustPlatform }:
{
  lib,
  fetchFromGitHub,
  buildPythonPackage,
  rustPlatform,

python3.pkgs.callPackage ./generic.nix {
  buildAndTestSubdir = "examples/word-count";
  # These are always passed as an override or as a callPackage option.
  nativeBuildInputs,
  buildAndTestSubdir,
  format,
  preConfigure,
}:

  nativeBuildInputs = with rustPlatform; [
    cargoSetupHook
    maturinBuildHook
  ];
buildPythonPackage rec {
  pname = "word-count";
  version = "0.13.2";

  src = fetchFromGitHub {
    owner = "PyO3";
    repo = "pyo3";
    rev = "v${version}";
    hash = "sha256-NOMrrfo8WjlPhtGxWUOPJS/UDDdbLQRCXR++Zd6JmIA=";
  };

  cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };

  postPatch = ''
    ln -s ${./Cargo.lock} Cargo.lock
  '';

  inherit
    buildAndTestSubdir
    format
    nativeBuildInputs
    preConfigure
    ;

  pythonImportsCheck = [ "word_count" ];

  meta = {
    description = "PyO3 word count example";
    homepage = "https://github.com/PyO3/pyo3";
    license = lib.licenses.asl20;
    maintainers = [ ];
  };
}
+0 −49
Original line number Diff line number Diff line
# Derivation prototype, used by maturin and setuptools-rust
# passthrough tests.

{
  lib,
  fetchFromGitHub,
  python,
  rustPlatform,

  nativeBuildInputs,

  buildAndTestSubdir ? null,
  format ? "pyproject",
  preConfigure ? "",
}:

python.pkgs.buildPythonPackage rec {
  pname = "word-count";
  version = "0.13.2";

  src = fetchFromGitHub {
    owner = "PyO3";
    repo = "pyo3";
    rev = "v${version}";
    hash = "sha256-NOMrrfo8WjlPhtGxWUOPJS/UDDdbLQRCXR++Zd6JmIA=";
  };

  cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };

  postPatch = ''
    ln -s ${./Cargo.lock} Cargo.lock
  '';

  inherit
    buildAndTestSubdir
    format
    nativeBuildInputs
    preConfigure
    ;

  pythonImportsCheck = [ "word_count" ];

  meta = {
    description = "PyO3 word count example";
    homepage = "https://github.com/PyO3/pyo3";
    license = lib.licenses.asl20;
    maintainers = [ ];
  };
}
+25 −2
Original line number Diff line number Diff line
{
  callPackage,
  lib,
  buildPythonPackage,
  fetchPypi,
  maturin,
  pythonOlder,
  rustPlatform,
  rustc,
  cargo,
  semantic-version,
  setuptools,
  setuptools-rust,
  setuptools-scm,
  tomli,
  typing-extensions,
@@ -38,7 +42,26 @@ buildPythonPackage rec {

  doCheck = false;

  passthru.tests.pyo3 = callPackage ./pyo3-test { };
  passthru.tests = {
    pyo3 = maturin.tests.pyo3.override {
      format = "setuptools";
      buildAndTestSubdir = null;

      nativeBuildInputs =
        [ setuptools-rust ]
        ++ [
          rustPlatform.cargoSetupHook
          cargo
          rustc
        ];

      preConfigure = ''
        # sourceRoot puts Cargo.lock in the wrong place due to the
        # example setup.
        cd examples/word-count
      '';
    };
  };

  meta = with lib; {
    description = "Setuptools plugin for Rust support";
+0 −30
Original line number Diff line number Diff line
{
  callPackage,
  cargo,
  rustPlatform,
  rustc,
  setuptools-rust,
}:

callPackage ../../../tools/rust/maturin/pyo3-test/generic.nix {
  # Isolated builds break for this package, because PyO3 is not
  # in the build root of the Python Package:
  #
  # https://github.com/pypa/pip/issues/6276
  #
  format = "setuptools";

  nativeBuildInputs =
    [ setuptools-rust ]
    ++ [
      rustPlatform.cargoSetupHook
      cargo
      rustc
    ];

  preConfigure = ''
    # sourceRoot puts Cargo.lock in the wrong place due to the
    # example setup.
    cd examples/word-count
  '';
}