New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python-packages.pyswip: init at 0.2.9 #72803
Conversation
set -o pipefail -o errexit | ||
path="$(python -c 'import pyswip.core; print(pyswip.core._path)')" | ||
home_dir="$(python -c 'import pyswip.core; print(pyswip.core.SWI_HOME_DIR)')" | ||
find $out -name core.py | xargs -n 1 sed -i "s:(_path, SWI_HOME_DIR) = _findSwipl():(_path, SWI_HOME_DIR) = ('$path', '$home_dir'):" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mind do this as part of the patchPhase? like:
postPatch = ''
substituteInplace pyswip/core.py \
--replace "(_path, SWI_HOME_DIR) = _findSwipl()" "_path, SWI_HOME_DIR) = ('${swiProlog}/bin', '${swiProlog}')"
'';
I'm assuming this interacts with the swiprolog package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alas, it's not quite so simple. When built in Nix (and I assume on most systems), _findSwipl outputs ("/nix/store/hash-swi-prolog-8.1.4/lib/swipl/lib/x86_64-linux/libswipl", "/nix/store/hash-swi-prolog-8.1.4/lib/swipl"). I'm not sure how to get these paths without actually running the (quite complex) Python code making up _findSwipl().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking through their logic, _path -> libswipl.so and SWI_HOME_DIR -> PLBASE key of swipl --dump-runtime-variables
. This is how i would write the expression, it seems to work:
{ lib
, buildPythonPackage
, fetchPypi
, pytestcov
, pytest
, swiProlog
}:
buildPythonPackage rec {
pname = "pyswip";
version = "0.2.9";
src = fetchPypi {
inherit pname version;
sha256 = "4591414006340ad8f033f9f0ee4c4c9151cd5a309ed19741a9c79b9ffce8b58e";
};
checkInputs = [ pytest pytestcov ];
postPatch = ''
substituteInPlace pyswip/core.py \
--replace "(_path, SWI_HOME_DIR) = _findSwipl()" "(_path, SWI_HOME_DIR) = ('${swiProlog}/lib/libswipl.so', '${swiProlog}/lib/swipl/')"
'';
meta = with lib; {
description = "PySwip enables querying SWI-Prolog in your Python programs";
homepage = https://github.com/yuce/pyswip;
license = licenses.mit;
maintainers = [ maintainers.catern ];
};
}
but please also add tests (they aren't on pypi, use github)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nix-shell:~/.cache/nix-review/pr-72803]$ nix-shell -p "with import ./nixpkgs {}; python37Packages.pyswip"
$ python
>>> from pyswip import Functor, Variable, Query, call
>>>
>>> assertz = Functor("assertz", 1)
>>> father = Functor("father", 2)
>>> call(assertz(father("michael","john")))
1
>>> call(assertz(father("michael","gina")))
1
>>> X = Variable()
>>>
>>> q = Query(father("michael",X))
>>> while q.nextSolution():
... print("Hello,", X.value)
...
Hello, john
Hello, gina
>>> q.closeQuery()
Thank you for your contributions.
|
I marked this as stale due to inactivity. → More info |
Closing due to inactivity from author. |
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @