Skip to content

Commit d89e8fb

Browse files
authored
Merge pull request pyscript#231 from pyscript/fpliger/69_add_makefile
Add initial dev setup automation
2 parents 53044cb + 88e15f8 commit d89e8fb

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is the configuration for pre-commit, a local framework for managing pre-commit hooks
2+
# Check out the docs at: https://pre-commit.com/
3+
4+
repos: []

pyscriptjs/Makefile

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
tag := latest
2+
git_hash ?= $(shell git log -1 --pretty=format:%h)
3+
4+
base_dir ?= $(shell git rev-parse --show-toplevel)
5+
src_dir ?= $(base_dir)/src
6+
examples ?= $(base_dir)/examples
7+
app_dir ?= $(shell git rev-parse --show-prefix)
8+
9+
CONDA_ENV ?= ./env
10+
env := $(CONDA_ENV)
11+
conda_run := conda run -p $(env)
12+
13+
.PHONY: setup
14+
setup:
15+
@if [ -z "$${CONDA_SHLVL:+x}" ]; then echo "Conda is not installed." && exit 1; fi
16+
$(CONDA_EXE) env $(shell [ -d $(env) ] && echo update || echo create) -p $(env) --file environment.yml
17+
18+
.PHONY: clean
19+
clean:
20+
find . -name \*.py[cod] -delete
21+
rm -rf .pytest_cache .coverage coverage.xml
22+
23+
clean-all: clean
24+
rm -rf $(env) *.egg-info
25+
26+
.PHONY: shell
27+
shell:
28+
@export CONDA_ENV_PROMPT='<{name}>'
29+
@echo 'conda activate $(env)'
30+
31+
.PHONY: dev
32+
dev:
33+
npm run dev
34+
35+
.PHONY: build
36+
build:
37+
npm run build
38+
39+
.PHONY: test
40+
test:
41+
@echo "Tests are coming :( this is a placeholder and it's meant to fail!"
42+
$(conda_run) pytest -vv $(ARGS) tests/ --log-cli-level=warning
43+
44+
.PHONY: test-py
45+
test-py:
46+
@echo "Tests are coming :( this is a placeholder and it's meant to fail!"
47+
$(conda_run) pytest -vv $(ARGS) tests/ --log-cli-level=warning
48+
49+
.PHONY: test-ts
50+
test-ts:
51+
@echo "Tests are coming :( this is a placeholder and it's meant to fail!"
52+
npm run tests
53+
54+
.PHONY: fmt
55+
fmt: fmt-py fmt-ts
56+
@echo "Format completed"
57+
58+
.PHONY: fmt-check
59+
fmt-check: fmt-ts-check fmt-py
60+
@echo "Format check completed"
61+
62+
.PHONY: fmt-ts
63+
fmt-ts:
64+
npm run format
65+
66+
.PHONY: fmt-ts-check
67+
fmt-ts-check:
68+
npm run format:check
69+
70+
.PHONY: fmt-py
71+
fmt-py:
72+
$(conda_run) black -l 88 .
73+
74+
.PHONY: fmt-py-check
75+
fmt-py-check:
76+
$(conda_run) black -l 88 --check .
77+
78+
.PHONY: lint
79+
lint: lint-ts
80+
@echo "Format check completed"
81+
82+
.PHONY: lint-ts
83+
lint-ts:
84+
$(conda_run) npm run lint

pyscriptjs/environment.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
channels:
2+
- defaults
3+
- conda-forge
4+
dependencies:
5+
- python=3.9
6+
- pip=20.2.2
7+
- pytest=7
8+
- nodejs=16
9+
- black
10+
- isort
11+
- codespell

0 commit comments

Comments
 (0)