-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds loom, distributions, and some additional dependencies (parsable, tcmalloc, goftests) which aren't currently available on Nixpkgs. Currently some of the loom tests aren't Python3 compatible and so running `make test` in the checkPhase will always fail, for the time being pythonImportsCheck is used to check they can at least be imported.
- Loading branch information
Showing
11 changed files
with
515 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
result | ||
result-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
fetchFromGitHub, | ||
callPackage, | ||
fetchPypi, | ||
eigen, | ||
parsable, | ||
goftests, | ||
protobuf3_20, | ||
python3Packages, | ||
}: | ||
let | ||
version = "2.2.1"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "posterior"; | ||
repo = "distributions"; | ||
rev = "43c11618b0f229682fb916612ba2437c5f22a753"; # there is no tag | ||
sha256 = "sha256-DiJ6Ljwc5K1CrzzexAQ53g86sKqaroYRhmXuxAHAOq4="; | ||
}; | ||
|
||
distributions-shared = callPackage ./distributions-shared.nix { inherit version src; }; | ||
|
||
imageio = python3Packages.buildPythonPackage rec { | ||
pname = "imageio"; | ||
version = "2.6.1"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
hash = "sha256-9E6yMbnfSFh08v/SLf0MPHEefeB2UWuTdO3qXGW8Z64="; | ||
}; | ||
|
||
doCheck = false; | ||
|
||
nativeBuildInputs = with python3Packages; [ | ||
pytest | ||
]; | ||
|
||
propagatedBuildInputs = with python3Packages; [ | ||
pillow | ||
]; | ||
|
||
buildInputs = with python3Packages; [ | ||
enum34 | ||
numpy | ||
]; | ||
}; | ||
in | ||
python3Packages.buildPythonPackage { | ||
pname = "distributions"; | ||
|
||
inherit version src; | ||
|
||
nativeBuildInputs = [ | ||
protobuf3_20 | ||
python3Packages.pyflakes | ||
]; | ||
|
||
buildInputs = [ | ||
eigen | ||
# TODO: we're not sure if this is even needed | ||
distributions-shared | ||
protobuf3_20 | ||
]; | ||
|
||
propagatedBuildInputs = with python3Packages; [ | ||
protobuf3_20 | ||
protobuf | ||
cython | ||
numpy | ||
parsable | ||
scipy | ||
simplejson | ||
]; | ||
|
||
# TODO: be more precise. Some tests seem to be still in Python 2. | ||
doCheck = false; | ||
nativeCheckInputs = with python3Packages; [ | ||
imageio | ||
nose | ||
goftests | ||
pytest | ||
]; | ||
|
||
preBuild = '' | ||
make protobuf | ||
''; | ||
|
||
patches = [ | ||
./use-imread-instead-of-scipy.patch | ||
]; | ||
|
||
env.DISTRIBUTIONS_USE_PROTOBUF = 1; | ||
|
||
# https://github.com/numba/numba/issues/8698#issuecomment-1584888063 | ||
env.NUMPY_EXPERIMENTAL_DTYPE_API = 1; | ||
|
||
pythonImportsCheck = [ | ||
"distributions" | ||
"distributions.io" | ||
"distributions.io.stream" | ||
]; | ||
|
||
passthru = { | ||
# TODO: we're not sure if this is even needed | ||
inherit distributions-shared; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
stdenv, | ||
cmake, | ||
eigen, | ||
protobuf3_20, | ||
src, version | ||
}: | ||
stdenv.mkDerivation { | ||
pname = "distributions-shared"; | ||
|
||
inherit version src; | ||
|
||
nativeBuildInputs = [ cmake ]; | ||
buildInputs = [eigen protobuf3_20 ]; | ||
|
||
env.DISTRIBUTIONS_USE_PROTOBUF = 1; | ||
|
||
preConfigure = '' | ||
make protobuf | ||
''; | ||
|
||
fixupPhase = '' | ||
ln -sv $out/lib/libdistributions_shared_release.so $out/lib/libdistributions_shared.so | ||
ln -sv $out/lib/libdistributions_shared_release.so $out/lib/libdistributions_shared_debug.so | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- a/examples/mixture/main.py | ||
+++ b/examples/mixture/main.py | ||
@@ -30,6 +30,7 @@ | ||
import numpy | ||
import scipy | ||
import scipy.misc | ||
+import imageio | ||
import scipy.ndimage | ||
from distributions.dbg.random import sample_discrete, sample_discrete_log | ||
from distributions.lp.models import nich | ||
@@ -45,7 +46,7 @@ | ||
DATA = os.path.join(ROOT, 'data') | ||
RESULTS = os.path.join(ROOT, 'results') | ||
SAMPLES = os.path.join(DATA, 'samples.json.gz') | ||
-IMAGE = scipy.misc.imread(os.path.join(ROOT, 'fox.png')) | ||
+IMAGE = imageio.imread(os.path.join(ROOT, 'fox.png')) | ||
SAMPLE_COUNT = 10000 | ||
PASSES = 10 | ||
EMPTY_GROUP_COUNT = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
fetchPypi, | ||
python3Packages, | ||
}: | ||
python3Packages.buildPythonPackage rec { | ||
pname = "goftests"; | ||
version = "0.2.7"; | ||
format = "setuptools"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
hash = "sha256-5s0NugSus2TuZIInesCNJNAtxEHnZLQIjn0pxGgwL/o="; | ||
}; | ||
|
||
buildInputs = with python3Packages; [ numpy scipy ]; | ||
|
||
doCheck = false; | ||
|
||
# https://github.com/numba/numba/issues/8698#issuecomment-1584888063 | ||
env.NUMPY_EXPERIMENTAL_DTYPE_API = 1; | ||
|
||
patchPhase = '' | ||
mkdir -p dist | ||
''; | ||
} |
Oops, something went wrong.