Skip to content

Commit ae6afe7

Browse files
build: manage the python env locally
1 parent 3086a24 commit ae6afe7

19 files changed

Lines changed: 55 additions & 8 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
*.pdf binary
55
*.zip binary
6+
*.whl binary

Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,26 @@ NAME = my_torch_analyzer
99

1010
all: $(NAME)
1111

12-
$(NAME):
13-
echo '#!/usr/bin/env python3' > $(NAME)
14-
echo 'from src.main import main' >> $(NAME)
15-
echo 'if __name__ == "__main__": main()' >> $(NAME)
16-
chmod +x $(NAME)
12+
venv:
13+
python -m venv venv || ./bootstrap-docker-venv.sh
14+
venv/bin/pip install -e . --no-build-isolation
15+
16+
$(NAME): venv
17+
ln -s venv/bin/$@ $@
1718

1819
.PHONY: all $(NAME)
1920

2021
clean:
21-
rm -rf .venv
22-
rm -f $(NAME)
22+
$(RM) $(NAME)
2323

2424
fclean: clean
2525
find . -type f -name '*.pyc' -delete
2626
find . -type d -name '__pycache__' -delete
27-
.PHONY: clean fclean
27+
28+
mrproper: clean
29+
$(RM) -r venv
30+
31+
.PHONY: clean fclean mrproper
2832

2933
re: fclean all
3034
.NOTPARALLEL: re

bootstrap-docker-venv.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
if [ ! -f /.dockerenv ]; then
5+
printf "\e[31mNOT DOCKER.\e[0m\n" >&2
6+
exit 1
7+
fi
8+
9+
rm -rf venv
10+
11+
pushd pip-cache
12+
pushd bootstrapping-pip
13+
14+
python3 \
15+
pip-25.3-py3-none-any.whl/pip \
16+
install \
17+
--no-index \
18+
--break-system-packages \
19+
--root-user-action ignore \
20+
\
21+
pip-25.3-py3-none-any.whl
22+
23+
popd
24+
pushd virtualenv
25+
26+
pip \
27+
install \
28+
--no-index \
29+
--break-system-packages \
30+
--no-build-isolation \
31+
--root-user-action ignore \
32+
\
33+
*.whl
34+
35+
popd
36+
popd
37+
38+
virtualenv venv
39+
venv/bin/pip \
40+
install \
41+
--no-build-isolation \
42+
pip-cache/*.whl
1.7 MB
Binary file not shown.
Binary file not shown.
8.13 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)