This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
157 lines (130 loc) · 3.98 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
NB_UID := $(shell id -u)
NB_GID := $(shell id -g)
IMAGE := rstudio/rsconnect-jupyter-py
NOTEBOOKS_DIR := /notebooks
PORT := $(shell printenv PORT || echo 9999)
S3_PREFIX := s3://rstudio-connect-downloads/connect/rsconnect-jupyter
VERSION := $(shell python setup.py --version 2>/dev/null || echo 'NOTSET')
BDIST_WHEEL := dist/rsconnect_jupyter-$(VERSION)-py2.py3-none-any.whl
JUPYTER_LOG_LEVEL ?= INFO
# NOTE: See the `dist` target for why this exists.
SOURCE_DATE_EPOCH := $(shell date +%s)
export SOURCE_DATE_EPOCH
PYTHONPATH ?= $(CURDIR)
export PYTHONPATH
.PHONY: prereqs
prereqs:
pip install -U pip
pip install -r requirements-dev.txt
.PHONY: install-latest-rsconnect-python
install-latest-rsconnect-python:
pip install -U https://cdn.rstudio.com/connect/rsconnect-python/latest/rsconnect_python-latest-py2.py3-none-any.whl
.PHONY: clean
clean:
rm -rf build/ dist/ docs/out/ rsconnect_jupyter.egg-info/
.PHONY: all-images
all-images: image3.8 image3.9 image3.10 image3.11
image%:
docker build \
--tag $(IMAGE)$* \
--file Dockerfile \
--build-arg BASE_IMAGE=python:$*-slim \
--build-arg NB_UID=$(NB_UID) \
--build-arg NB_GID=$(NB_GID) \
--build-arg PY_VERSION=$* \
.
test: version-frontend
pytest -vv --cov=rsconnect_jupyter tests/
.PHONY: test-selenium
test-selenium:
$(MAKE) -C selenium clean test-env-up jupyter-up test || EXITCODE=$$? ; \
$(MAKE) -C selenium jupyter-down || true ; \
$(MAKE) -C selenium test-env-down || true ; \
exit $$EXITCODE
# NOTE: Wheels won't get built if _any_ file it tries to touch has a timestamp
# before 1980 (system files) so the $(SOURCE_DATE_EPOCH) current timestamp is
# exported as a point of reference instead.
.PHONY: dist
dist: version-frontend
rm -vf dist/*.whl
python setup.py bdist_wheel
twine check $(BDIST_WHEEL)
rm -vf dist/*.egg
@echo "::set-output name=whl::$(BDIST_WHEEL)"
@echo "::set-output name=whl_basename::$(notdir $(BDIST_WHEEL))"
run: install
jupyter notebook \
-y \
--log-level=$(JUPYTER_LOG_LEVEL) \
--notebook-dir=./notebooks3 \
--ip='0.0.0.0' \
--port=9999 \
--no-browser \
--NotebookApp.token=''
.PHONY: install
install: version-frontend
jupyter nbextension uninstall rsconnect_jupyter || true
jupyter nbextension install --symlink --user --py rsconnect_jupyter
jupyter nbextension enable --py rsconnect_jupyter
jupyter serverextension enable --py rsconnect_jupyter
build/mock-connect/bin/flask:
bash -c '\
mkdir -p build && \
virtualenv build/mock-connect && \
. build/mock-connect/bin/activate && \
pip install flask'
.PHONY: mock-server
mock-server: build/mock-connect/bin/flask
bash -c '\
. build/mock-connect/bin/activate && \
FLASK_APP=mock_connect.py flask run --host=0.0.0.0'
.PHONY: yarn
yarn:
yarn install
.PHONY: lint
lint: lint-js lint-py
.PHONY: lint-js
lint-js:
npm run lint
.PHONY: lint-py
lint-py:
black --check --diff ./rsconnect_jupyter
flake8 ./rsconnect_jupyter
.PHONY: fmt
fmt:
black ./rsconnect_jupyter
## Specify that Docker runs with the calling user's uid/gid to avoid file
## permission issues on Linux dev hosts.
DOCKER_RUN_AS =
ifeq (Linux,$(shell uname))
DOCKER_RUN_AS = -u $(shell id -u):$(shell id -g)
endif
.PHONY: version
version:
@echo $(VERSION)
.PHONY: version-frontend
version-frontend:
printf '{"version":"%s"}\n' $(VERSION) >rsconnect_jupyter/static/version.json
.PHONY: sync-latest-to-s3
sync-latest-to-s3:
aws s3 cp --acl bucket-owner-full-control \
$(BDIST_WHEEL) \
$(S3_PREFIX)/latest/rsconnect_jupyter-latest-py2.py3-none-any.whl
.PHONY: sync-latest-docs-to-s3
sync-latest-docs-to-s3:
aws s3 cp --acl bucket-owner-full-control \
--recursive \
--cache-control max-age=0 \
docs/site/ \
$(S3_PREFIX)/latest/
.PHONY: promote-docs-in-s3
promote-docs-in-s3:
aws s3 cp --acl bucket-owner-full-control \
--recursive \
docs/site/ \
s3://docs.rstudio.com/rsconnect-jupyter/rsconnect_jupyter-$(VERSION)/
aws s3 cp --acl bucket-owner-full-control \
--recursive \
--cache-control max-age=300 \
docs/site/ \
s3://docs.rstudio.com/rsconnect-jupyter/