-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
141 lines (117 loc) · 5.96 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
clean:
rm -rf *.egg-info
clear-poetry-cache: # clear poetry/pypi cache. for user to do explicitly, never automatic
poetry cache clear pypi --all
configure: # does any pre-requisite installs
pip install poetry==1.8.4
lint:
flake8 submitr
build: # builds
make configure
poetry install
test:
pytest -m "not integration"
test-integration:
# pytest -vv submitr/tests/test_rclone_support.py
pytest -m integration
retest: # runs only failed tests from the last test run. (if no failures, it seems to run all?? -kmp 17-Dec-2020)
pytest -vv --last-failed
update: # updates dependencies
poetry update
tag-and-push: # tags the branch and pushes it
@scripts/tag-and-push
preview-locally: doc-view
doc:
sphinx-build -b html docs/source docs/html
doc-view: doc
open docs/html/index.html
doc-gen docgen gendoc:
# python docs/scripts/gendoc.py --env smaht-local
python docs/scripts/gendoc.py --env smaht-data
make doc
publish:
# New Python based publish script in dcicutils (2023-04-25).
poetry run publish-to-pypi
publish-for-ga:
# New Python based publish script in dcicutils (2023-04-25).
poetry run publish-to-pypi --noconfirm
# This exe stuff is experimental. The pyinstaller utility allows the creation of a self-contained
# executable which can be run without Python or anything like that being installed. Have separate
# executables for MacOS and x86_64 and arm64 architectures of Linux (via docker). We do the builds
# locally; the MacOS version using native MacOS (M1) which ASSUMES we using for local builds; and
# we use docker to do x86_64 and arm64 Linux build; and note that we use docker RedHat/CentOS
# flavors of Linux, as binaries built here run on Debian/Ubuntu flavors, but not vice versa.
#
# Builds for this need to be run locally, where local means MacOS M1+, and not in GitHub Actions,
# because we obviously need to build the MacOS version on MacOS, and GitHub Actions runs on Linux;
# supposedly GitHub Actions can also do MacOS but couldn't get it totally working. And for Linux,
# we CAN use GitHub Actions for the docker based x86_64 build, but could not get it working for
# the arm64 version (exec format error). So for simplicity just build all binary versions locally.
# Binaries are written to (and checked into) the binaries directory; with a symbolic from a
# version-named file to the unversion-named file; do it like this so we don't end up with
# a ton of binaries checked in for different binary versions which haven't actually changed.
#
# There is a GitHub Actions workflow (main-binaries-release.yml) to "release" the binaries.
# This workflow ONLY runs when a NON-beta tag is created. And it makes sure that the binaries
# which are checked in (to the binaries directory) are for this version; if not then the
# release build will fail.
#
# To install (on MacOS or Linux x86_64 or Linux arm64):
# curl https://raw.githubusercontent.com/smaht-dac/submitr/master/install.sh | /bin/bash
#
# Could also create a MacOS (pkg) installer (see exe-macos-installer in commit 42ec17dc),
# but won't easily work without signing via Apple Developer's License; so nevermind that.
#
# TODO: Figure out if we need a separate build/executable for non-M1 MacOS.
exe: exe-macos exe-linux
exe-macos:
if [ "`arch`" = "arm64" ]; then \
MACOS_ARCH='-arm' make exe-macos-arch ; \
else \
MACOS_ARCH='-x86' make exe-macos-arch ; \
fi;
exe-macos-arch:
# Download/use with:
# curl https://raw.githubusercontent.com/smaht-dac/submitr/master/install.sh | /bin/bash
pip install poetry
poetry install
pip install pyinstaller
pyinstaller --onefile --name submitr ./submitr/scripts/submitr.py
mkdir -p ./binaries
cp ./dist/submitr ./binaries/submitr-macos
cp ./dist/submitr ./binaries/submitr-macos${MACOS_ARCH}
chmod a+x ./binaries/submitr-macos${MACOS_ARCH}
rm -rf ./build ./dist
exe-linux: exe-linux-x86 exe-linux-arm
exe-linux-x86:
# Download/use with:
# curl https://raw.githubusercontent.com/smaht-dac/submitr/master/install.sh | /bin/bash
# N.B. Turns out binaries built on RedHat (CentOS) work on Debian (Ubuntu); but not vice versa.
# TODO: Remind myself why we at one point seemed to need to use docker buildx.
# docker buildx build -t pyinstaller-linux-x86-build -f Dockerfile-for-pyinstaller-x86 .
docker build -t pyinstaller-linux-x86-build -f Dockerfile-for-pyinstaller-x86 .
mkdir -p ./binaries
docker run --rm -v ./binaries:/output pyinstaller-linux-x86-build sh -c "cp /app/dist/submitr /output/submitr-linux-x86"
exe-linux-arm:
# Download/use with:
# curl https://raw.githubusercontent.com/smaht-dac/submitr/master/install.sh | /bin/bash
# N.B. Turns out binaries built on RedHat (CentOS) work on Debian (Ubuntu); but not vice versa.
# TODO: Remind myself why we at one point seemed to need to use docker buildx.
# docker buildx create --use
# docker buildx build --platform linux/arm64 --load -t pyinstaller-linux-arm-build -f Dockerfile-for-pyinstaller-arm .
docker build --platform linux/arm64 --load -t pyinstaller-linux-arm-build -f Dockerfile-for-pyinstaller-arm .
mkdir -p ./binaries
docker run --platform linux/arm64 --rm -v ./binaries:/output pyinstaller-linux-arm-build sh -c "cp /app/dist/submitr /output/submitr-linux-arm"
help:
@make info
info:
@: $(info Here are some 'make' options:)
$(info - Use 'make configure' to install poetry, though 'make build' will do it automatically.)
$(info - Use 'make lint' to check style with flake8.)
$(info - Use 'make build' to install dependencies using poetry.)
$(info - Use 'make preview-locally' to build and a local doc tree and open it for preview.)
$(info - Use 'make publish' to publish this library, but only if auto-publishing has failed.)
$(info - Use 'make retest' to run failing tests from the previous test run.)
$(info - Use 'make test' to run tests with the normal options we use for CI/CD like GA.)
$(info - Use 'make update' to update dependencies (and the lock file))
$(info - Use 'make clear-poetry-cache' to clear the poetry pypi cache if in a bad state. (Safe, but later recaching can be slow.))