Skip to content

Commit

Permalink
Merge pull request nix-community#1705 from rossng/fix-soundfile-wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Jun 18, 2024
2 parents 53e534a + af46929 commit 48e7ed4
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 6 deletions.
23 changes: 17 additions & 6 deletions overrides/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3472,12 +3472,23 @@ lib.composeManyExtensions [

});

soundfile = prev.soundfile.overridePythonAttrs (_old: {
postPatch = ''
substituteInPlace soundfile.py \
--replace "_find_library('sndfile')" "'${pkgs.libsndfile.out}/lib/libsndfile${sharedLibExt}'"
'';
});
soundfile =
let
patch = ''
substituteInPlace soundfile.py \
--replace "_find_library('sndfile')" "'${pkgs.libsndfile.out}/lib/libsndfile${sharedLibExt}'"
'';
in
prev.soundfile.overridePythonAttrs (old: {
postInstall = pkgs.lib.optionalString (old.src.isWheel or false) ''
pushd "$out/${final.python.sitePackages}"
${patch}
popd
'';
postPatch = pkgs.lib.optionalString (!(old.src.isWheel or false)) ''
${patch}
'';
});

sqlmodel = prev.sqlmodel.overridePythonAttrs (old: {
# sqlmodel's pyproject.toml lists version = "0" that it changes during a build phase
Expand Down
2 changes: 2 additions & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ in
ckzg = callTest ./ckzg { };
thrift = callTest ./thrift { };
scikit-learn = callTest ./scikit-learn { };
soundfile-wheel = callTest ./soundfile-wheel { };
soundfile = callTest ./soundfile { };
} // lib.optionalAttrs (!stdenv.isDarwin) {
# Editable tests fails on Darwin because of sandbox paths
pep600 = callTest ./pep600 { };
Expand Down
15 changes: 15 additions & 0 deletions tests/soundfile-wheel/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ poetry2nix, python3, runCommand }:
let
env = poetry2nix.mkPoetryEnv {
python = python3;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
preferWheels = true;
};
py = env.python;
pkg = py.pkgs.soundfile;
isSoundfileWheel = pkg.src.isWheel;
in
assert isSoundfileWheel; runCommand "soundfile-wheel" { } ''
${env}/bin/python -c 'import soundfile; print(soundfile.__version__)' > $out
''
104 changes: 104 additions & 0 deletions tests/soundfile-wheel/poetry.lock

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

13 changes: 13 additions & 0 deletions tests/soundfile-wheel/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
name = "test-soundfile-wheel"
version = "0.1.0"
description = "Test of wheel for soundfile"
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.9"
soundfile = "^0.12.1"

[build-system]
requires = ["poetry-core>=1"]
build-backend = "poetry.core.masonry.api"
9 changes: 9 additions & 0 deletions tests/soundfile/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ poetry2nix, runCommand }:
let
env = poetry2nix.mkPoetryEnv {
projectDir = ./.;
};
in
runCommand "soundfile" { } ''
${env}/bin/python -c 'import soundfile; print(soundfile.__version__)' > $out
''
Loading

0 comments on commit 48e7ed4

Please sign in to comment.