Unverified Commit c01d7fbe authored by Christoph Jabs's avatar Christoph Jabs
Browse files

python3Packages.python-sat: cleanup and convert to pyproject true

- fix pytest import issue
    As described in https://github.com/NixOS/nixpkgs/issues/255262, `python
    -m pytest` adds the local directory to PYTHONPATH, which gives
    precendence to local imports. Remove the local `pysat` directory to only
    import the installed variant.
- convert to pyproject true
- update description
parent 3f2c25ad
Loading
Loading
Loading
Loading
+26 −7
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  buildPythonPackage,
  fetchPypi,
  lib,
  setuptools,
  six,
  pypblib,
  pytestCheckHook,
@@ -9,7 +10,9 @@
buildPythonPackage rec {
  pname = "python-sat";
  version = "1.8.dev20";
  format = "setuptools";
  pyproject = true;

  build-system = [ setuptools ];

  src = fetchPypi {
    inherit version;
@@ -17,26 +20,42 @@ buildPythonPackage rec {
    hash = "sha256-8uUi6DtPVh/87EWSgTtGq7UhAs+Glw8KARPkK3ukeMg=";
  };

  # Build SAT solver backends in parallel and fix hard-coded g++ reference for
  # darwin, where stdenv uses clang
  # Fix hard-coded g++ reference for darwin, where stdenv uses clang
  # FIXME: remove once https://github.com/pysathq/pysat/pull/204 is merged and
  # has hit PyPI
  postPatch = ''
    substituteInPlace solvers/prepare.py \
      --replace-fail "&& make &&" "&& make -j$NIX_BUILD_CORES &&"
    substituteInPlace solvers/patches/glucose421.patch \
      --replace-fail "+CXX      := g++" "+CXX      := c++"
  '';

  preBuild = ''
    export MAKEFLAGS="-j$NIX_BUILD_CORES"
  '';

  propagatedBuildInputs = [
    six
    pypblib
  ];

  pythonImportsCheck = [
    "pysat"
    "pysat.examples"
    "pysat.allies"
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  disabledTestPaths = [ "tests/test_unique_mus.py" ];
  # Due to `python -m pytest` appending the local directory to `PYTHONPATH`,
  # importing `pysat.examples` in the tests fails. Removing the `pysat`
  # directory fixes since then only the installed version in `$out` is
  # imported, which has `pysat.examples` correctly installed.
  # See https://github.com/NixOS/nixpkgs/issues/255262
  preCheck = ''
    rm -r pysat
  '';

  meta = with lib; {
    description = "Toolkit to provide interface for various SAT (without optional dependancy py-aiger-cnf)";
    description = "Toolkit for SAT-based prototyping in Python (without optional dependencies)";
    homepage = "https://github.com/pysathq/pysat";
    changelog = "https://pysathq.github.io/updates/";
    license = licenses.mit;