Skip to content

Commit

Permalink
Update makefile with repatching scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan.ryan@canonical.com>
  • Loading branch information
techalchemy committed Jun 1, 2020
1 parent aacc638 commit e065e3c
Showing 1 changed file with 67 additions and 12 deletions.
79 changes: 67 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ 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:= 2.7 3.5 3.6 3.7 3.8
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/notpip/__init__.py)
PATCHED_PIPTOOLS_VERSION := $(shell awk -F "=" '/pip-tools/ {print $$3}' pipenv/patched/patched.txt)
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
piptools-checkout-dir = $(get_checkout_dir)/patch-piptools

format:
black pipenv/*.py
Expand All @@ -19,10 +28,9 @@ test:

.PHONY: install
install:
pip install -e . && pipenv install --dev
pip install -e .

install.stamp:
[ ! -e install.stamp ] && $(MAKE) install
install.stamp: install
@touch install.stamp

.PHONY: install-py%
Expand Down Expand Up @@ -75,12 +83,8 @@ retest: virtualenv submodules test-install
. $(get_venv_path)/bin/activate && pipenv run pytest -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.stamp
pipenv run python setup.py sdist bdist_wheel

build.stamp:
[ ! -e build.stamp ] && $(MAKE) build
@touch build.stamp
build: install-virtualenvs.stamp install.stamp
PIPENV_PYTHON=3.7 pipenv run python setup.py sdist bdist_wheel

.PHONY: update-version
update-version:
Expand Down Expand Up @@ -121,5 +125,56 @@ cleanbuild:
@rm -rf build.stamp

.PHONY: clean
clean: cleanbuild
rm -rf install.stamp build.stamp install-virtualenvs.stamp
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: clone-piptools
clone-piptools: .git-checkout-dir
[ -e $(piptools-checkout-dir) ] && echo "Piptools already exists, moving on!" || git clone https://github.com/jazzband/pip-tools.git $(piptools-checkout-dir) -b $(PATCHED_PIPTOOLS_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: patch-piptools
patch-piptools: clone-piptools
@find $(CURDIR)/tasks/vendoring/patches/patched/ -regex ".*/piptools[^/\.]*.patch" -exec cp {} $(piptools-checkout-dir)/ \;
@sed -i -r 's:([a-b]\/)pipenv/patched/:\1/:g' $(piptools-checkout-dir)/*.patch
@cd $(piptools-checkout-dir)/ && git apply --ignore-whitespace --verbose piptools*.patch
@echo "Head to $(piptools-checkout-dir) to update the piptools patches to the latest version"

.PHONY: patches
patches: patch-pip patch-piptools

.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/ \;

.PHONY: reimport-piptools-patch
reimport-piptools-patch:
@sed -i -r 's:([a-b]\/):\1pipenv/patched/:g' $(piptools-checkout-dir)/*.patch
@find $(piptools-checkout-dir)/ -maxdepth 1 -regex ".*/piptools[^/\.]*.patch" -exec cp {} $(CURDIR)/tasks/vendoring/patches/patched/ \;

0 comments on commit e065e3c

Please sign in to comment.