Skip to content
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

update visr, enable visr tests, and update other deps #19

Merged
merged 9 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bear/data_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
import importlib_resources
import os


Expand All @@ -15,12 +15,12 @@ def get_path(file_url):
# try to find the file in a couple of different places
for package, prefix in ("bear", "data/"), ("visr_bear_data", ""):
try:
full_path = pkg_resources.resource_filename(package, prefix + path)
full_path = importlib_resources.files(package) / prefix / path
except ModuleNotFoundError:
continue

if os.path.isfile(full_path):
return full_path
if full_path.is_file():
return str(full_path)
else:
raise Exception(f"resource '{path}' not found")
elif file_url.startswith("file:"):
Expand Down
41 changes: 21 additions & 20 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion nix/bear.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
python.pkgs.buildPythonPackage rec {
name = "bear";
inherit src;
propagatedBuildInputs = with python.pkgs; [ numpy ear setuptools visr_python visr_bear ];
propagatedBuildInputs = with python.pkgs; [ numpy ear importlib-resources visr_python visr_bear ];
nativeBuildInputs = with python.pkgs; [ setuptools ];
nativeCheckInputs = [ python.pkgs.pytest numpy_quaternion ];
checkPhase = lib.optionalString (visr_bear != null) ''
pytest visr_bear/test
Expand Down
7 changes: 5 additions & 2 deletions nix/ear.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{ stdenv, python, fetchFromGitHub, src }:
{ stdenv, python, src }:
python.pkgs.buildPythonPackage rec {
name = "ear";
inherit src;
propagatedBuildInputs = with python.pkgs; [ numpy scipy six attrs multipledispatch lxml pyyaml setuptools ];
propagatedBuildInputs = with python.pkgs; [ numpy scipy six attrs multipledispatch lxml pyyaml importlib-resources ];
nativeBuildInputs = with python.pkgs; [ setuptools ];
pyproject = true;

doCheck = false;
}
15 changes: 14 additions & 1 deletion nix/visr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
stdenv.mkDerivation rec {
name = "VISR";
inherit src;
nativeBuildInputs = [ cmake ninja boost ] ++ lib.optional enable_python python.buildEnv;
nativeBuildInputs = [ cmake ninja boost ] ++ lib.optional enable_python python;
cmakeFlags = [
"-DBUILD_AUDIOINTERFACES_PORTAUDIO=FALSE"
"-DBUILD_USE_SNDFILE_LIBRARY=FALSE"
Expand All @@ -13,4 +13,17 @@ stdenv.mkDerivation rec {
substituteInPlace CMakeLists.txt \
--replace "\''${VISR_TOPLEVEL_INSTALL_DIRECTORY}/python" "$out/${python.sitePackages}"
'';

preCheck = ''
export LD_LIBRARY_PATH=$(pwd)/lib
export DYLD_LIBRARY_PATH=$(pwd)/lib
'';

nativeCheckInputs = lib.optionals enable_python [
python.pkgs.numpy
python.pkgs.scipy
python.pkgs.pytest
];

doCheck = true;
}
2 changes: 1 addition & 1 deletion nix/visr_bear.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
eigen
libear
rapidjson
] ++ (if enable_python then [ python.buildEnv visr_python ] else [ visr ]);
] ++ (if enable_python then [ python visr_python ] else [ visr ]);
cmakeFlags = [
"-DBEAR_UNIT_TESTS=true"
"-DBEAR_DATA_PATH_DEFAULT=${data_files.default.file}"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
version="0.0.1",
install_requires=[
"ear~=2.1",
"importlib_resources",
"numpy",
],
packages=find_packages(),
Expand Down
Loading