This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
165 lines (136 loc) · 3.64 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Prefix to use when running python code.
PY_RUN ?= pipenv run
# Triggers the --release flag on or off when setup.py is building the rust
# extension module.
RUSTCSV_BUILD_DEBUG ?= True
RUSTCSV_BUILD_NATIVE ?= True
RUSTCSV_RUST_VERSION ?= nightly
MANYLINUX_IMAGE ?= quay.io/pypa/manylinux1_x86_64
WHEEL_PYTHON_VERSIONS ?= cp36 cp37
WHEELHOUSE = wheelhouse
.PHONY: default
default:
# Do nothing and fail if no target specified
false
# Development
# ===========
.PHONY: black
black:
# Format python code
$(PY_RUN) black ./rustcsv
.PHONY: isort
isort:
# Sort imports in python code
$(PY_RUN) isort -y
.PHONY: develop
develop:
$(PY_RUN) python setup.py develop
.PHONY: develop-debug
develop-debug:
make \
RUSTCSV_BUILD_DEBUG=True \
develop
.PHONY: develop-release
develop-release:
make \
RUSTCSV_BUILD_DEBUG=False \
RUSTCSV_BUILD_NATIVE=True \
develop
.PHONY: clean
clean: | setuptools-clean
.PHONY: setuptools-clean
setuptools-clean:
$(PY_RUN) python setup.py clean
# Testing
# =======
# pytest options
PYTEST_OPTS ?= -vv --showlocals
# additional pytest options when running tests
PYTEST_TEST_OPTS ?=
# additional pytest options when running benchmarks
PYTEST_BENCHMARK_OPTS ?=
PYTEST_BENCHMARK_TIMER ?= time.process_time
PYTEST_BENCHMARK_SORT ?= fullname
.PHONY: test
test:
# Run python tests
$(PY_RUN) pytest \
$(PYTEST_OPTS) \
--benchmark-skip \
$(PYTEST_TEST_OPTS)
.PHONY: test-example-scripts
test-example-scripts:
$(PY_RUN) python examples/reader_from_path.py
$(PY_RUN) python examples/reader_from_file_object.py
# Run heavy benchmarks, 1 = True, 0 = False
BENCHMARK_FULL ?= 0
.PHONY: benchmark
benchmark: | develop-release
# Run benchmarks
$(PY_RUN) pytest \
$(PYTEST_OPTS) \
--benchmark-only \
--benchmark-timer $(PYTEST_BENCHMARK_TIMER) \
--benchmark-sort $(PYTEST_BENCHMARK_SORT) \
--benchmark-autosave
.PHONY: benchmark-full
benchmark-full:
make BENCHMARK_FULL=1 benchmark
# Docs
# ====
.PHONY: docs
docs:
make -C doc html
.PHONY: docs-apidoc
docs-apidoc:
sphinx-apidoc -o doc/source/api/ -H "API" rustcsv 'test_*'
.PHONY: docs-autobuild
docs-autobuild:
sphinx-autobuild -p 8001 doc/source/ doc/build/html/
# Release management
# ==================
.PHONY: build-release-sdist
build-release-sdist:
$(PY_RUN) env \
RUSTCSV_BUILD_DEBUG=False \
RUSTCSV_BUILD_NATIVE=True \
python setup.py \
sdist
.PHONY: reqirements-files
requirements-files:
# Generate reqirements file
$(PY_RUN) pipenv lock --requirements > requirements.txt
# Generate dev reqirements file
$(PY_RUN) pipenv lock --requirements --dev > dev-requirements.txt
.PHONY: build-wheels-manylinux
build-wheels-manylinux: | requirements-files
docker run --rm -it \
-v $(shell pwd):/io \
--env RUSTCSV_BUILD_DEBUG=$(RUSTCSV_BUILD_DEBUG) \
--env RUSTCSV_BUILD_NATIVE=$(RUSTCSV_BUILD_NATIVE) \
--env RUSTCSV_RUST_VERSION=$(RUSTCSV_RUST_VERSION) \
--env WHEELHOUSE=/io/$(WHEELHOUSE) \
$(MANYLINUX_IMAGE) \
/io/travis/build-wheels-manylinux.sh $(WHEEL_PYTHON_VERSIONS)
.PHONY: build-sdist
build-sdist:
$(PY_RUN) python setup.py sdist --dist-dir $(WHEELHOUSE)
.PHONY: build-wheels-osx
build-wheels-osx: | reqirements-files
$(PY_RUN) env \
WHEELHOUSE=$(WHEELHOUSE) \
bash travis/build-wheels-osx.sh $(WHEEL_PYTHON_VERSIONS)
.PHONY: publish-wheelhouse
publish-wheelhouse:
# Publish files in $(WHEELHOUSE) to PyPI
$(PY_RUN) twine upload \
--username rustcsv \
$(WHEELHOUSE)/*
.PHONY: publish-wheelhouse-test
publish-wheelhouse-test:
# Publish files in $(WHEELHOUSE) to Test PyPI:
# https://packaging.python.org/guides/using-testpypi/
$(PY_RUN) twine upload \
--repository-url https://test.pypi.org/legacy/ \
--username testrustcsv \
$(WHEELHOUSE)/*