From b01ba6c43a36ab5ba9508e2cb0fdf74499f55d4e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 12 Feb 2022 17:43:12 +0800 Subject: [PATCH] build ARTIQ conda package --- flake.nix | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 6611a7a..4db25a3 100644 --- a/flake.nix +++ b/flake.nix @@ -40,14 +40,106 @@ name = "conda-builder-env"; targetPkgs = pkgs: condaDeps ++ [ condaInstalled ]; }; + makeCondaRecipe = (constituent: + '' + # conda build breaks if write permissions aren't set on source files. + cp --no-preserve=mode,ownership -R ${constituent.src} workaround-conda + cd workaround-conda + tar cf ../${constituent.name}.tar . + cd .. + rm -rf workaround-conda + + mkdir -p conda/${constituent.name} + + cat << EOF > conda/${constituent.name}/meta.yaml + package: + name: ${constituent.name} + version: ${constituent.version} + + source: + url: ../../${constituent.name}.tar + + {% set data = load_setup_py_data() %} + + build: + noarch: python + entry_points: + # NOTE: conda-build cannot distinguish between console and gui scripts + {% for entry_point_type, entry_points in data.get("entry_points", dict()).items() -%} + {% for entry_point in entry_points -%} + - {{ entry_point }} + {% endfor %} + {% endfor %} + ignore_prefix_files: True + + requirements: + run: + ${pkgs.lib.concatStringsSep "\n" (map (s: " - ${s}") constituent.dependencies)} + EOF + + cat << EOF > conda/${constituent.name}/build.sh + #!/bin/bash + set -e + python setup.py install \ + --prefix=\$PREFIX \ + --single-version-externally-managed \ + --record=record.txt \ + --no-compile + EOF + chmod 755 conda/${constituent.name}/build.sh + '' + ); + makeCondaChannel = constituents: pkgs.stdenvNoCC.mkDerivation { + name = "conda-channel"; + buildInputs = [ condaBuilderEnv ]; + phases = [ "buildPhase" "installPhase" ]; + buildPhase = pkgs.lib.concatStringsSep "\n" (map makeCondaRecipe constituents); + installPhase = + '' + HOME=`pwd` + mkdir $out + conda-builder-env -c " + ${pkgs.lib.concatStringsSep "\n" + (map (constituent: "conda build --no-anaconda-upload --no-test --output-folder $out conda/${constituent.name}") constituents)} + " + + mkdir $out/nix-support + for package in $out/*/*.tar.bz2; do + echo file conda $package >> $out/nix-support/hydra-build-products + done + ''; + }; in rec { packages.x86_64-linux = { - inherit condaBuilderEnv; + condaChannel = makeCondaChannel [ + { + name = "artiq"; + version = artiq.packages.x86_64-linux.artiq.version; + src = artiq.packages.x86_64-linux.artiq.src; + dependencies = [ + "pythonparser" + "scipy" + "numpy" + "prettytable" + "h5py" + "python-dateutil" + "pyqt" + "qasync" + "pyqtgraph" + "pygit2" + "python-levenshtein" + "sipyco" + "llvmlite" + "llvm-tools" + "lld" + ]; + } + ]; }; hydraJobs = { - inherit (packages.x86_64-linux) condaBuilderEnv; + inherit (packages.x86_64-linux) condaChannel; }; }; }