make fakeCondaSource reusable

This commit is contained in:
Sebastien Bourdeauducq 2019-04-19 20:11:05 +08:00
parent a0ffa136d8
commit 84d09db90e
2 changed files with 59 additions and 59 deletions

View File

@ -1,66 +1,13 @@
{ pkgs }: { pkgs }:
with pkgs;
let let
artiqSrc = import ./pkgs/artiq-src.nix { inherit fetchgit; };
version = import ./pkgs/artiq-version.nix; version = import ./pkgs/artiq-version.nix;
fakeCondaSource = runCommand "fake-condasrc-artiq" { } fakeCondaSource = import ./conda-fake-source.nix { inherit pkgs; } {
'' name = "artiq";
mkdir -p $out/fake-conda; inherit version;
src = import ./pkgs/artiq-src.nix { fetchgit = pkgs.fetchgit; };
# work around yet more idiotic conda behavior - build breaks if write permissions aren't set on source files. dependencies = import ./conda-artiq-deps.nix;
cp --no-preserve=mode,ownership -R ${artiqSrc} workaround-conda };
pushd workaround-conda
tar cf $out/src.tar .
popd
rm -rf workaround-conda
cat << EOF > $out/fake-conda/meta.yaml
package:
name: artiq
version: ${version}
source:
url: ../src.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:
${lib.concatStringsSep "\n" (map (s: " - ${s}") (import ./conda-artiq-deps.nix))}
about:
home: https://m-labs.hk/artiq
license: LGPL
summary: 'A leading-edge control system for quantum information experiments'
EOF
cat << EOF > $out/fake-conda/build.sh
#!/bin/bash
set -e
export VERSIONEER_OVERRIDE=${version}
python setup.py install \
--prefix=\$PREFIX \
--single-version-externally-managed \
--record=record.txt \
--no-compile
EOF
chmod 755 $out/fake-conda/build.sh
'';
conda-artiq = import ./conda-build.nix { inherit pkgs; } { conda-artiq = import ./conda-build.nix { inherit pkgs; } {
name = "conda-artiq"; name = "conda-artiq";
src = fakeCondaSource; src = fakeCondaSource;

View File

@ -0,0 +1,53 @@
{ pkgs }:
{ name, version, src, dependencies }:
pkgs.runCommand "conda-fake-source-${name}" { }
''
mkdir -p $out/fake-conda;
# work around yet more idiotic conda behavior - build breaks if write permissions aren't set on source files.
cp --no-preserve=mode,ownership -R ${src} workaround-conda
pushd workaround-conda
tar cf $out/src.tar .
popd
rm -rf workaround-conda
cat << EOF > $out/fake-conda/meta.yaml
package:
name: ${name}
version: ${version}
source:
url: ../src.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}") dependencies)}
EOF
cat << EOF > $out/fake-conda/build.sh
#!/bin/bash
set -e
export VERSIONEER_OVERRIDE=${version}
python setup.py install \
--prefix=\$PREFIX \
--single-version-externally-managed \
--record=record.txt \
--no-compile
EOF
chmod 755 $out/fake-conda/build.sh
''