Skip to content

Instantly share code, notes, and snippets.

@boronine
Created June 14, 2022 00:32
Show Gist options
  • Save boronine/61b19fb7d1db5c42d3dfb3215d87d3d0 to your computer and use it in GitHub Desktop.
Save boronine/61b19fb7d1db5c42d3dfb3215d87d3d0 to your computer and use it in GitHub Desktop.
rec {
pkgs = import <nixpkgs> {};
python3 = pkgs.python39.withPackages (ps: with ps; [ setuptools wheel twine ]);
v502 = pkgs.fetchzip {
url = "https://github.com/hsluv/hsluv-python/archive/refs/tags/v5.0.2.zip";
sha256 = "sha256-8uzDL8VWJmoH5Hnj+PZ3I1U1KdD5wyd/veM5LplHHGQ=";
};
v501 = pkgs.fetchzip {
url = "https://github.com/hsluv/hsluv-python/archive/refs/tags/v5.0.1.zip";
sha256 = "sha256-8o+3bv3bVgtINexH0Aj2bbL/wkD4DHLF6A37X/7SRmY=";
};
v500 = pkgs.fetchzip {
url = "https://github.com/hsluv/hsluv-python/archive/refs/tags/v5.0.0.zip";
sha256 = "sha256-F6Yw8v/wgVTJoDQrB6Nj6mon24++GyzbXOign/S6+jw=";
};
pythonBuild = src : pkgs.stdenv.mkDerivation rec {
name = "python-dist";
inherit python3 src;
buildInputs = [python3];
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
export SOURCE_DATE_EPOCH=315532800
cp -R --no-preserve=mode,ownership $src/* .
#sed -i "s/name='hsluv'/name='hsluv-restored'/g" setup.py
sed -i "s/__version__,/__version__+'.post1',/g" setup.py
python3 setup.py sdist bdist_wheel
mkdir $out
cp dist/* $out
'';
};
publishPypi = build : pkgs.writeShellScriptBin "script.sh" ''
${python3}/bin/twine upload --username __token__ --password REDACTED --verbose ${build}/*
'';
v502-pub = publishPypi (pythonBuild v502);
v501-pub = publishPypi (pythonBuild v501);
v500-pub = publishPypi (pythonBuild v500);
pub = pkgs.writeShellScriptBin "script.sh" ''
${v502-pub}/bin/script.sh
${v501-pub}/bin/script.sh
${v500-pub}/bin/script.sh
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment