Skip to content
Open
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
59 changes: 59 additions & 0 deletions pkgs/by-name/fi/fixVersioneerSourcesHook/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
lib,
makeSetupHook,
fetchFromGitHub,
fetchzip,
fixVersioneerSourcesHook,
runCommand,
}:
makeSetupHook {
name = "fixVersioneerSourcesHook";

passthru.tests.test =
let
# An example of a project that uses versioneer
src = fetchFromGitHub {
owner = "jcrist";
repo = "msgspec";
tag = "0.19.0";
hash = "sha256-CajdPNAkssriY/sie5gR+4k31b3Wd7WzqcsFmrlSoPY=";
};
# Make a clean tarball out of the source to be fetched by fetchzip later
srcClean = runCommand "source-clean.tar.gz" { } ''
tar -cf $out -C ${src} .
'';
# Patch tarball adding a common error produced in GitHub source archives
srcDirty = runCommand "source-dirty.tar.gz" { } ''
unpackFile ${src}
chmod -R u+w source
cd source
sed -i 's/git_refnames = " (\(.*\))"/git_refnames = " (HEAD -> main, \1)"/' msgspec/_version.py
tar -cf $out .
'';
# Make the result of fetchzip not fixed output to run it with and without hook
doFetch =
name: src: withHook:
(fetchzip {
inherit name;
url = "file://${src}";
stripRoot = false;
nativeBuildInputs = lib.optionals withHook [ fixVersioneerSourcesHook ];
}).overrideAttrs
{
outputHashAlgo = null;
outputHash = null;
};
in
# Now verify that all these produce the result equal to the clean one
runCommand "test-fixVersioneerSourcesHook"
{
clean = doFetch "clean" srcClean false;
cleanWithHook = doFetch "cleanWithHook" srcClean true;
dirtyWithHook = doFetch "dirtyWithHook" srcDirty true;
}
''
diff -ru $clean $cleanWithHook
diff -ru $clean $dirtyWithHook
touch $out
'';
} ./setup-hook.sh
18 changes: 18 additions & 0 deletions pkgs/by-name/fi/fixVersioneerSourcesHook/setup-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
appendToVar postFetchHooks fixVersioneerSource

fixVersioneerSource() {
local versionfile
# try pyproject.toml
versionfile="$([ -f "$out/pyproject.toml" ] && awk 'match($0, /^versionfile_source ?= ?['"'"'"](.*)['"'"'"]/, m) { print m[1] }' "$out/pyproject.toml" || true)"
if [ -z "$versionfile" ]; then
echo "'versionfile_source' not found in 'pyproject.toml', trying 'setup.cfg'"
# try setup.cfg
versionfile="$([ -f "$out/pyproject.toml" ] && awk 'match($0, /^versionfile_source ?= ?(.*)/, m) { print m[1] }' "$out/setup.cfg" || true)"
if [ -z "$versionfile" ]; then
echo "'versionfile_source' not found in 'setup.cfg'"
return
fi
fi
echo "found versionfile_source = $versionfile"
sed -i 's/git_refnames = " (.*\(tag:[^,)]*\).*)"/git_refnames = " (\1)"/' "$out/$versionfile"
}
4 changes: 3 additions & 1 deletion pkgs/development/python-modules/ancp-bids/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
setuptools,
numpy,
pandas,
fixVersioneerSourcesHook,
}:

buildPythonPackage rec {
Expand All @@ -21,7 +22,8 @@ buildPythonPackage rec {
owner = "ANCPLabOldenburg";
repo = "ancp-bids";
tag = version;
hash = "sha256-n8QfQ2PGdAO6kTfkbFpj3f2gYa3vwuYg+vPpZlGNpb0=";
hash = "sha256-dfk7AILVWXCvA12l6RrrUIR93A8nT0kn/tZT/cN63ZU=";
nativeBuildInputs = [ fixVersioneerSourcesHook ];
};

build-system = [ setuptools ];
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/python-modules/bayespy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
h5py,
truncnorm,
pytestCheckHook,
fixVersioneerSourcesHook,
}:

buildPythonPackage rec {
Expand All @@ -19,7 +20,8 @@ buildPythonPackage rec {
owner = "bayespy";
repo = "bayespy";
tag = version;
hash = "sha256-X7CwJBrKHlU1jqMkt/7XEzaiwul1Yzkb/V64lXG4Aqo=";
hash = "sha256-kx87XY4GCL1PQIeZyovEbrPyCC/EVA6Hdvt+3P/D6VI=";
nativeBuildInputs = [ fixVersioneerSourcesHook ];
};

postPatch = ''
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/python-modules/birch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
pytestCheckHook,
pytest-cov-stub,
pyyaml,
fixVersioneerSourcesHook,
}:

buildPythonPackage rec {
Expand All @@ -18,8 +19,9 @@ buildPythonPackage rec {
src = fetchFromGitHub {
owner = "shaypal5";
repo = "birch";
rev = "v${version}";
tag = "v${version}";
hash = "sha256-KdQZzQJvJ+logpcLQfaqqEEZJ/9VmNTQX/a4v0oBC98=";
nativeBuildInputs = [ fixVersioneerSourcesHook ];
};

patches = [
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/python-modules/coredis/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
redis,
typing-extensions,
wrapt,
fixVersioneerSourcesHook,
}:

buildPythonPackage rec {
Expand All @@ -26,6 +27,7 @@ buildPythonPackage rec {
repo = "coredis";
tag = version;
hash = "sha256-5Ho9X2VCOwKo079M2ReJ93jqEpG2ZV6vKM5/qrgzjxM=";
nativeBuildInputs = [ fixVersioneerSourcesHook ];
};

postPatch = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/python-modules/dask-jobqueue/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
stdenv,
buildPythonPackage,
fetchFromGitHub,
fixVersioneerSourcesHook,

# build-system
setuptools,
Expand All @@ -27,6 +28,7 @@ buildPythonPackage rec {
repo = "dask-jobqueue";
tag = version;
hash = "sha256-YujfhjOJzl4xsjjsyrQkEu/CBR04RwJ79c1iSTcMIgw=";
nativeBuildInputs = [ fixVersioneerSourcesHook ];
};

build-system = [ setuptools ];
Expand Down
Loading