forked from pypa/pipenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
174 lines (143 loc) · 6.04 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
166
167
168
169
170
171
172
173
174
get_venv_dir:=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'tmpvenv')
venv_dir := $(get_venv_dir)/pipenv_venv
venv_file := $(CURDIR)/.test_venv
get_venv_path =$(file < $(venv_file))
# This is how we will build tag-specific wheels, e.g. py36 or py37
PY_VERSIONS:= 3.7 3.8 3.9 3.10
BACKSLASH = '\\'
# This is how we will build generic wheels, e.g. py2 or py3
INSTALL_TARGETS := $(addprefix install-py,$(PY_VERSIONS))
CLEAN_TARGETS := $(addprefix clean-py,$(PY_VERSIONS))
DATE_STRING := $(shell date +%Y.%m.%d)
THIS_MONTH_DATE := $(shell date +%Y.%m.01)
NEXT_MONTH_DATE := $(shell date -d "+1 month" +%Y.%m.01)
PATCHED_PIP_VERSION := $(shell awk '/__version__/{gsub(/"/,"",$$3); print $$3}' pipenv/patched/pip/__init__.py)
GITDIR_STAMPFILE := $(CURDIR)/.git-checkout-dir
create_git_tmpdir = $(shell mktemp -dt pipenv-vendor-XXXXXXXX 2>/dev/null || mktemp -d 2>/dev/null)
write_git_tmpdir = $(file > $(GITDIR_STAMPFILE),$(create_git_tmpdir))
get_checkout_dir = $(file < $(GITDIR_STAMPFILE))
get_checkout_subdir = $(addprefix $(get_checkout_dir), $(1))
pip-checkout-dir = $(get_checkout_dir)/patch-pip
format:
black pipenv/*.py
.PHONY: install
install:
pip install -e .
install.stamp: install
@touch install.stamp
.PHONY: install-py%
install-py%: install.stamp
@echo building for $(addprefix python, $(subst install-py,,$@))
PIPENV_PYTHON=$(subst install-py,,$@) pipenv install --dev
install-virtualenvs.stamp: ${INSTALL_TARGETS}
@touch install-virtualenvs.stamp
.PHONY: ramdisk
ramdisk: SIZE ?= 4g
ramdisk:
sudo mkdir -p /mnt/ramdisk
sudo mount -t tmpfs -o size=$(SIZE) tmpfs /mnt/ramdisk
sudo chown -R ${USER}:${USER} /mnt/ramdisk
.PHONY: ramdisk-virtualenv
ramdisk-virtualenv: ramdisk
[ ! -e "/mnt/ramdisk/.venv/bin/activate" ] && \
python -m venv /mnt/ramdisk/.venv
echo "/mnt/ramdisk/.venv" > $(venv_file)
.PHONY: virtualenv
virtualenv:
[ ! -e $(venv_dir) ] && rm -rvf $(venv_file) && python -m venv $(venv_dir)
@echo $(venv_dir) > $(venv_file)
.PHONY: test-install
test-install:
test-install: $(if $(RAMDISK), ramdisk-virtualenv virtualenv)
. $(get_venv_path)/bin/activate && \
python -m pip install --upgrade pip -e .[tests,dev] && \
pipenv install --dev
.PHONY: submodules
submodules:
git submodule sync
git submodule update --init --recursive
# Run the tests within ramdisk by setting RAMDISK=1
# e.g make tests RAMDISK=1
.PHONY: tests
tests: parallel ?= -n auto
tests: suite ?=
tests: submodules test-install
source $(get_venv_path)/bin/activate && \
pipenv run pytest -ra $(parallel) -vvv --full-trace --tb=long $(suite)
.PHONY: vendor
vendor: virtualenv
. $(get_venv_path)/bin/activate && \
python -m pip install invoke && \
python -m pip install -e .[dev] && \
python -m invoke vendoring.update
.PHONY: test-specific
test-specific: submodules virtualenv test-install
. $(get_venv_path)/bin/activate && pipenv run pytest -ra -k '$(tests)'
.PHONY: retest
retest: parallel ?= -n auto
retest: virtualenv submodules test-install
. $(get_venv_path)/bin/activate && pipenv run pytest $(parallel) -ra -k 'test_check_unused or test_install_editable_git_tag or test_get_vcs_refs or test_skip_requirements_when_pipfile or test_editable_vcs_install or test_basic_vcs_install or test_git_vcs_install or test_ssh_vcs_install or test_vcs_can_use_markers' -vvv --full-trace --tb=long
.PHONY: build
build: install-virtualenvs.stamp install.stamp
PIPENV_PYTHON=3.7 pipenv run python setup.py sdist bdist_wheel
.PHONY: update-version
update-version:
@sed -i "s/^__version__ = .\+$\/__version__ = \"$(DATE_STRING)\"/g" ./pipenv/__version__.py
.PHONY: update-prerelease-version
update-prerelease-version:
@sed -i "s/^__version__ = .\+$\/__version__ = \"$(THIS_MONTH_DATE).a1\"/g" ./pipenv/__version__.py
.PHONY: pre-bump
pre-bump:
@sed -i "s/^__version__ = .\+$\/__version__ = \"$(NEXT_MONTH_DATE).dev0\"/g" ./pipenv/__version__.py
.PHONY: lint
lint:
flake8 .
man:
$(MAKE) -C docs $@
.PHONY: check
check: build.stamp
pipenv run twine check dist/* && pipenv run check-manifest .
.PHONY: upload-test
upload-test: build
twine upload --repository=testpypi dist/*
.PHONY: clean-py%
clean-py%:
@echo "cleaning environment for $@..."
PIPENV_PYTHON="$(subst clean-py,,$@)" pipenv --rm
.PHONY: cleanbuild
cleanbuild:
@echo "cleaning up existing builds..."
@rm -rf build/ dist/
@rm -rf build.stamp
.PHONY: clean
clean:
rm -rf install.stamp build.stamp install-virtualenvs.stamp .git-checkout-dir
.PHONY: gitclean
gitclean:
@echo "Cleaning up git trees..."
@rm -rf $(file < .git-checkout-dir)
@echo "Cleaning up git checkout stamp"
@rm -rf .git-checkout-dir
.git-checkout-dir:
@echo "Creating git repo temp file"
@echo "Creating git checkout stamp file at .git-checkout-dir"
@echo $(file > $(CURDIR)/.git-checkout-dir,$(shell mktemp -dt pipenv-vendor-XXXXXXXX 2>/dev/null || mktemp -d 2>/dev/null))
.PHONY: clone-pip
clone-pip: .git-checkout-dir
[ -e $(pip-checkout-dir) ] && echo "Pip already exists, moving on!" || git clone https://github.com/pypa/pip.git $(pip-checkout-dir) -b $(PATCHED_PIP_VERSION)
.PHONY: patch-pip
patch-pip: clone-pip
@find $(CURDIR)/tasks/vendoring/patches/patched/ -regex ".*/pip[0-9]+.patch" -exec cp {} $(pip-checkout-dir) \;
@sed -i -r 's:([a-b]\/)pipenv/patched/:\1src/:g' $(pip-checkout-dir)/*.patch
@find $(CURDIR)/tasks/vendoring/patches/patched/ -regex ".*/_post-pip-[^/\.]*.patch" -exec cp {} $(pip-checkout-dir)/ \;
@sed -i -r 's:([a-b]\/)pipenv/patched/not:\1src/:g' $(pip-checkout-dir)/_post-*.patch
@cd $(pip-checkout-dir)/ && git apply --ignore-whitespace --verbose pip*.patch
@echo "Head to $(pip-checkout-dir) to update the pip patches to the latest version"
.PHONY: patches
patches: patch-pip
.PHONY: reimport-pip-patch
reimport-pip-patch:
@sed -i -r 's:([a-b]\/)src/:\1pipenv/patched/not:g' $(pip-checkout-dir)/_post-*.patch
@sed -i -r 's:([a-b]\/)src/:\1pipenv/patched/:g' $(pip-checkout-dir)/pip*.patch
@find $(pip-checkout-dir) -maxdepth 1 -regex ".*/pip[0-9]+.patch" -exec cp {} $(CURDIR)/tasks/vendoring/patches/patched/ \;
@find $(pip-checkout-dir) -maxdepth 1 -regex ".*/_post-pip-[^/\.]*.patch" -exec cp {} $(CURDIR)/tasks/vendoring/patches/patched/ \;