forked from openai/tiktoken
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (41 loc) · 1.67 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
PROJECT := tiktoken
.PHONY: default
default: editable_install
.PHONY: install_rust
install_rust:
which cargo >/dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.62
.PHONY: clean
clean:
cargo clean
pip uninstall -y $(PROJECT)
find . | grep -E '__pycache__|\.pyc' | xargs rm -rf
find . | grep -E '\.so' | xargs rm -rf
rm -rf dist/ build/
rm -rf $(PROJECT).egg-info/
.PHONY: format
format:
@ which black >/dev/null || python3 -m pip install black
@ which isort >/dev/null || python3 -m pip install isort
cargo fmt -- --config group_imports=StdExternalCrate
black --line-length 100 --skip-magic-trailing-comma --quiet .
isort --line-length 100 --profile black --quiet .
.PHONY: format_check
format_check:
@ which black >/dev/null || python3 -m pip install black
@ which isort >/dev/null || python3 -m pip install isort
cargo fmt --check -- --config group_imports=StdExternalCrate
black --check --line-length 100 --skip-magic-trailing-comma --quiet .
isort --check --line-length 100 --profile black --quiet .
.PHONY: lint
lint:
cargo clippy --all -- -D warnings
@ which flake8 >/dev/null || python3 -m pip install flake8==5 flake8-bugbear==22.9.11
flake8 --ignore=E203,E501,W503,E731 --per-file-ignores="$(PROJECT)/__init__.py:F401 setup.py:E402" --exclude=build .
.PHONY: editable_install
editable_install:
@ if [ -f $(PROJECT).egg-info ]; then \
pip install --disable-pip-version-check --progress-bar=off setuptools wheel setuptools-rust ; \
pip install --disable-pip-version-check --no-build-isolation -e . ; \
else \
pip install --disable-pip-version-check --no-deps --no-build-isolation --ignore-installed -e . ; \
fi