forked from robots-from-jupyter/robotkernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (69 loc) · 2.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
REF_NIXPKGS = branches nixos-20.03
PYTHON ?= python39
ROBOTFRAMEWORK ?= rf40
NIX_OPTIONS ?= --argstr python $(PYTHON) --argstr robotframework $(ROBOTFRAMEWORK)
.PHONY: all
all: test
cachix:
nix-store --query --references $$(nix-instantiate shell.nix)|xargs nix-store --realise|xargs nix-store --query --requisites|cachix push robots-from-jupyter
nix-%:
nix-shell $(NIX_OPTIONS) setup.nix -A develop --run "$(MAKE) $*"
.PHONY: shell
shell: requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix
nix-shell $(NIX_OPTIONS) setup.nix -A develop
env: requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix
nix-build $(NIX_OPTIONS) setup.nix -A env -o env
.PHONY: test
test: check
PYTHONPATH=$(PYTHONPATH):$(PWD)/src pytest tests
# pytest --cov=robotkernel tests
.PHONY: check
check:
black -t py37 --check src
pylama src tests
build: result
result: requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix
nix-build $(NIX_OPTIONS) setup.nix -A bdist_wheel
.PHONY: clean
clean:
rm -rf .cache env result
.PHONY: coverage
coverage: htmlcov
.PHONY: format
format:
black -t py37 src tests
isort src tests
###
.coverage: test
htmlcov: .coverage
coverage html
requirements: requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix
requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix: requirements-$(PYTHON)-$(ROBOTFRAMEWORK).txt
nix-shell setup.nix $(NIX_OPTIONS) -A pip2nix --run "pip2nix generate -r requirements-$(PYTHON)-$(ROBOTFRAMEWORK).txt --no-binary jupyter --output=requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix"
requirements-$(PYTHON)-$(ROBOTFRAMEWORK).txt: requirements-$(ROBOTFRAMEWORK).txt
nix-shell setup.nix $(NIX_OPTIONS) -A pip2nix --run "pip2nix generate -r requirements-$(ROBOTFRAMEWORK).txt --output=requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix"
@grep "pname =\|version =" requirements-$(PYTHON)-$(ROBOTFRAMEWORK).nix|awk "ORS=NR%2?FS:RS"|sed 's|.*"\(.*\)";.*version = "\(.*\)".*|\1==\2|' > requirements-$(PYTHON)-$(ROBOTFRAMEWORK).txt
.PHONY: upgrade
upgrade:
nix-shell --pure -p cacert curl gnumake jq nix --run "make setup.nix"
.PHONY: setup.nix
setup.nix:
@set -e pipefail; \
echo "Updating nixpkgs @ setup.nix using $(REF_NIXPKGS)"; \
rev=$$(curl https://api.github.com/repos/NixOS/nixpkgs-channels/$(firstword $(REF_NIXPKGS)) \
| jq -er '.[]|select(.name == "$(lastword $(REF_NIXPKGS))").commit.sha'); \
echo "Latest commit sha: $$rev"; \
sha=$$(nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs-channels/archive/$$rev.tar.gz); \
sed -i \
-e "2s|.*| # $(REF_NIXPKGS)|" \
-e "3s|.*| url = \"https://github.com/NixOS/nixpkgs-channels/archive/$$rev.tar.gz\";|" \
-e "4s|.*| sha256 = \"$$sha\";|" \
setup.nix
examples/JupyterLab.html: examples/JupyterLab.ipynb
jupyter nbconvert \
--to html \
--TemplateExporter.exclude_input=True \
--TemplateExporter.exclude_input_prompt=True \
--TemplateExporter.exclude_output_prompt=True \
--TemplateExporter.template_file=docs/nbconvert.tpl \
"examples/JupyterLab.ipynb"