-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathMakefile
94 lines (75 loc) · 2.61 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
# Execute only from the repo root
ifdef GL_DOCKER
REPO=/repo
else
REPO=$(shell git rev-parse --show-toplevel)
endif
DIR=${REPO}/libs/gl-client-py
PYVERSION=$(shell cd libs && cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "gl-client-py") | .version')
PYDIR=${REPO}/libs/gl-client-py
PROTODIR=${REPO}/libs/proto
PYPROTOC_OPTS = \
-I ${PROTODIR} \
--python_out=${PYDIR} \
--grpc_python_out=${PYDIR} \
--mypy_out=${PYDIR} \
--mypy_grpc_out=${PYDIR} \
--experimental_allow_proto3_optional
PYPROTOS = \
${PYDIR}/glclient/greenlight_pb2.py \
${PYDIR}/glclient/greenlight_pb2_grpc.py \
${PYDIR}/glclient/scheduler_pb2.py \
${PYDIR}/glclient/scheduler_pb2_grpc.py
PROTOSRC = \
${PROTODIR}/glclient/scheduler.proto \
${PROTODIR}/glclient/greenlight.proto \
GENALL += ${PYPROTOS}
${PYPROTOS}: pygrpc
pygrpc: ${PROTOSRC}
cp ${PYDIR}/../proto/glclient/scheduler.proto ${PYDIR}/glclient/
cp ${PYDIR}/../proto/glclient/greenlight.proto ${PYDIR}/glclient/
cd ${PYDIR}; poetry install
cd ${PYDIR}; poetry run python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/scheduler.proto
cd ${PYDIR}; poetry run python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/greenlight.proto
check-py:
#uv run --all-packages mypy ${PYDIR}/glclient
uv run --all-packages pytest tests -n $(shell nproc) ${PYDIR}/tests
clean-py:
rm -f ${PYPROTOS} ${PYDIR}/build ${PYDIR}/dist
test: build
virtualenv .tmpenv --python=$(which python3) --download --always-copy --clear
.tmpenv/bin/python3 -m pip install -U pip wheel pytest pytest-timeout
.tmpenv/bin/python3 -m pip install -f ${PYDIR}/../dist gl-client-py ${PYDIR}/../gl-testing
cd .tmpenv && bin/pytest ${PYDIR}/../tests
rm -rf .tmpenv
build-py-macos:
cd ${PYDIR}/; \
maturin build \
--release \
--target aarch64-apple-darwin \
--out=${PYDIR}/dist
cd ${PYDIR}; \
maturin build \
--release \
--target x86_64-apple-darwin \
--out=${PYDIR}/dist
build-py: ${PYDIR}/pyproject.toml build-py-${OS}
# build-py-linux builds the wheels and sdist package in docker and
# drops them into ${REPO}/wheelhouse. The docker build is needed to
# get an old(-ish) glibc, maximizing compatibility.
build-py-linux:
docker buildx build \
--load \
-t gl-client-py-builder \
--build-arg DOCKER_USER=$(shell whoami) \
${PYDIR}
docker run -ti \
-v ${REPO}:/io \
gl-client-py-builder
${PYDIR}/pyproject.toml: ${PYDIR}/Cargo.toml
cd ${PYDIR}; poetry version ${PYVERSION}
# Pickup the wheels in ${REPO}/wheelhouse and send them to PyPI
publish-py: build-py
cd tools/glcli; poetry build --no-interaction
cd ${PYDIR}; poetry publish --skip-existing
package-py: build-py