nix-scripts/artiq-fast/conda/fake-source.nix

58 lines
1.5 KiB
Nix
Raw Permalink Normal View History

2019-04-19 20:11:05 +08:00
{ pkgs }:
2020-06-09 15:43:18 +08:00
{ name, version, src, extraSrcCommands ? "", dependencies ? [], extraYaml ? ""}:
2019-04-19 20:11:05 +08:00
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
2020-06-09 15:43:18 +08:00
${extraSrcCommands}
2019-04-19 20:11:05 +08:00
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)}
2019-11-09 18:58:21 +08:00
${extraYaml}
2019-04-19 20:11:05 +08:00
EOF
cat << EOF > $out/fake-conda/build.sh
#!/bin/bash
set -e
export VERSIONEER_OVERRIDE=${version}
export LD_LIBRARY_PATH=/lib
2019-04-19 20:11:05 +08:00
python setup.py install \
--prefix=\$PREFIX \
--single-version-externally-managed \
--record=record.txt \
--no-compile
EOF
chmod 755 $out/fake-conda/build.sh
''