2018-07-12 21:16:16 +02:00
|
|
|
###############################################################################
|
2021-09-06 17:36:13 +02:00
|
|
|
# See ./CONTRIBUTING.md
|
2018-07-12 21:16:16 +02:00
|
|
|
###############################################################################
|
2016-01-02 19:07:00 +02:00
|
|
|
|
2020-10-25 21:39:01 +02:00
|
|
|
.PHONY: build
|
|
|
|
|
2019-12-04 18:49:07 +02:00
|
|
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
2014-04-28 14:25:45 +03:00
|
|
|
VERSION=$(shell grep __version__ httpie/__init__.py)
|
2019-12-04 18:49:07 +02:00
|
|
|
H1="\n\n\033[0;32m\#\#\# "
|
|
|
|
H1END=" \#\#\# \033[0m\n"
|
|
|
|
|
|
|
|
|
|
|
|
# Only used to create our venv.
|
|
|
|
SYSTEM_PYTHON=python3
|
|
|
|
|
|
|
|
VENV_ROOT=venv
|
|
|
|
VENV_BIN=$(VENV_ROOT)/bin
|
|
|
|
VENV_PIP=$(VENV_BIN)/pip3
|
2019-12-04 19:34:26 +02:00
|
|
|
VENV_PYTHON=$(VENV_BIN)/python
|
2014-04-28 14:25:45 +03:00
|
|
|
|
2016-01-02 19:28:46 +02:00
|
|
|
|
2019-12-04 19:24:53 +02:00
|
|
|
export PATH := $(VENV_BIN):$(PATH)
|
|
|
|
|
|
|
|
|
2019-09-10 13:10:29 +02:00
|
|
|
all: uninstall-httpie install test
|
2016-01-02 19:28:46 +02:00
|
|
|
|
2014-04-28 14:25:45 +03:00
|
|
|
|
2021-10-05 21:37:40 +02:00
|
|
|
install: venv install-reqs
|
|
|
|
|
|
|
|
|
|
|
|
install-reqs:
|
2021-09-08 16:41:55 +02:00
|
|
|
@echo $(H1)Updating package tools$(H1END)
|
|
|
|
$(VENV_PIP) install --upgrade pip wheel
|
|
|
|
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Installing dev requirements$(H1END)
|
2021-06-11 20:55:26 +02:00
|
|
|
$(VENV_PIP) install --upgrade --editable '.[dev]'
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Installing HTTPie$(H1END)
|
|
|
|
$(VENV_PIP) install --upgrade --editable .
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo
|
|
|
|
|
2021-10-05 21:37:40 +02:00
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
clean:
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Cleaning up$(H1END)
|
|
|
|
rm -rf $(VENV_ROOT)
|
2020-01-12 11:50:57 +02:00
|
|
|
# Remove symlink for virtualenvwrapper, if we’ve created one.
|
2019-12-04 18:49:07 +02:00
|
|
|
[ -n "$(WORKON_HOME)" -a -L "$(WORKON_HOME)/httpie" -a -f "$(WORKON_HOME)/httpie" ] && rm $(WORKON_HOME)/httpie || true
|
2020-06-26 17:22:06 +02:00
|
|
|
rm -rf *.egg dist build .coverage .cache .pytest_cache httpie.egg-info
|
2019-12-04 18:49:07 +02:00
|
|
|
find . -name '__pycache__' -delete -o -name '*.pyc' -delete
|
|
|
|
@echo
|
|
|
|
|
|
|
|
|
|
|
|
venv:
|
|
|
|
@echo $(H1)Creating a Python environment $(VENV_ROOT) $(H1END)
|
|
|
|
|
|
|
|
$(SYSTEM_PYTHON) -m venv --prompt httpie $(VENV_ROOT)
|
|
|
|
|
|
|
|
@echo
|
|
|
|
@echo done.
|
2018-07-12 21:16:16 +02:00
|
|
|
@echo
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo To active it manually, run:
|
|
|
|
@echo
|
|
|
|
@echo " source $(VENV_BIN)/activate"
|
|
|
|
@echo
|
|
|
|
@echo '(learn more: https://docs.python.org/3/library/venv.html)'
|
|
|
|
@echo
|
|
|
|
@if [ -n "$(WORKON_HOME)" ]; then \
|
|
|
|
echo $(ROOT_DIR) > $(VENV_ROOT)/.project; \
|
|
|
|
if [ ! -d $(WORKON_HOME)/httpie -a ! -L $(WORKON_HOME)/httpie ]; then \
|
|
|
|
ln -s $(ROOT_DIR)/$(VENV_ROOT) $(WORKON_HOME)/httpie ; \
|
|
|
|
echo ''; \
|
|
|
|
echo 'Since you use virtualenvwrapper, we created a symlink'; \
|
|
|
|
echo 'so you can also use "workon httpie" to activate the venv.'; \
|
|
|
|
echo ''; \
|
|
|
|
fi; \
|
|
|
|
fi
|
2018-07-12 21:16:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Testing
|
|
|
|
###############################################################################
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2019-09-10 13:10:29 +02:00
|
|
|
test:
|
2019-12-05 00:31:47 +02:00
|
|
|
@echo $(H1)Running tests$(HEADER_EXTRA)$(H1END)
|
2021-09-20 17:36:03 +02:00
|
|
|
$(VENV_BIN)/python -m pytest $(COV)
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2021-09-20 17:36:03 +02:00
|
|
|
test-cover: COV=--cov=httpie --cov=tests
|
2019-12-05 00:31:47 +02:00
|
|
|
test-cover: HEADER_EXTRA=' (with coverage)'
|
2019-12-04 18:49:07 +02:00
|
|
|
test-cover: test
|
|
|
|
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
# test-all is meant to test everything — even this Makefile
|
2021-06-02 11:06:46 +02:00
|
|
|
test-all: clean install test test-dist codestyle
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2014-04-28 14:25:45 +03:00
|
|
|
test-dist: test-sdist test-bdist-wheel
|
|
|
|
@echo
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2019-12-04 19:48:39 +02:00
|
|
|
test-sdist: clean venv
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Testing sdist build an installation$(H1END)
|
|
|
|
$(VENV_PYTHON) setup.py sdist
|
|
|
|
$(VENV_PIP) install --force-reinstall --upgrade dist/*.gz
|
|
|
|
$(VENV_BIN)/http --version
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2019-12-04 19:48:39 +02:00
|
|
|
test-bdist-wheel: clean venv
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Testing wheel build an installation$(H1END)
|
2019-12-04 19:48:39 +02:00
|
|
|
$(VENV_PIP) install wheel
|
2019-12-04 18:49:07 +02:00
|
|
|
$(VENV_PYTHON) setup.py bdist_wheel
|
|
|
|
$(VENV_PIP) install --force-reinstall --upgrade dist/*.whl
|
|
|
|
$(VENV_BIN)/http --version
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2020-10-25 21:39:01 +02:00
|
|
|
twine-check:
|
|
|
|
twine check dist/*
|
|
|
|
|
2021-06-02 11:06:46 +02:00
|
|
|
|
|
|
|
# Kept for convenience, "make codestyle" is preferred though
|
|
|
|
pycodestyle: codestyle
|
|
|
|
|
|
|
|
|
|
|
|
codestyle:
|
|
|
|
@echo $(H1)Running flake8$(H1END)
|
2021-06-11 20:55:26 +02:00
|
|
|
@[ -f $(VENV_BIN)/flake8 ] || $(VENV_PIP) install --upgrade --editable '.[dev]'
|
2021-06-02 11:06:46 +02:00
|
|
|
$(VENV_BIN)/flake8 httpie/ tests/ extras/ *.py
|
2018-07-12 21:16:16 +02:00
|
|
|
@echo
|
|
|
|
|
|
|
|
|
2019-12-04 18:49:07 +02:00
|
|
|
codecov-upload:
|
|
|
|
@echo $(H1)Running codecov$(H1END)
|
|
|
|
@[ -f $(VENV_BIN)/codecov ] || $(VENV_PIP) install codecov
|
2020-01-12 11:57:14 +02:00
|
|
|
# $(VENV_BIN)/codecov --required
|
|
|
|
$(VENV_BIN)/codecov
|
2018-07-12 21:16:16 +02:00
|
|
|
@echo
|
|
|
|
|
|
|
|
|
2021-09-09 15:52:24 +02:00
|
|
|
doc-check:
|
|
|
|
@echo $(H1)Running documentations checks$(H1END)
|
2021-10-06 11:18:27 +02:00
|
|
|
mdl --git-recurse --style docs/markdownlint.rb .
|
|
|
|
|
|
|
|
|
|
|
|
doc-update-install:
|
|
|
|
@echo $(H1)Updating installation instructions in the docs$(H1END)
|
|
|
|
$(VENV_PYTHON) docs/installation/generate.py
|
2021-09-09 15:52:24 +02:00
|
|
|
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
###############################################################################
|
|
|
|
# Publishing to PyPi
|
|
|
|
###############################################################################
|
2014-04-28 14:25:45 +03:00
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
2020-10-25 21:39:01 +02:00
|
|
|
build:
|
|
|
|
rm -rf build/
|
|
|
|
$(VENV_PYTHON) setup.py sdist bdist_wheel
|
|
|
|
|
|
|
|
|
2016-08-13 22:51:42 +02:00
|
|
|
publish: test-all publish-no-test
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
|
2016-08-13 22:51:42 +02:00
|
|
|
publish-no-test:
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Testing wheel build an installation$(H1END)
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo "$(VERSION)"
|
2016-08-13 22:51:42 +02:00
|
|
|
@echo "$(VERSION)" | grep -q "dev" && echo '!!!Not publishing dev version!!!' && exit 1 || echo ok
|
2020-10-25 21:39:01 +02:00
|
|
|
make build
|
|
|
|
make twine-check
|
2021-02-06 12:17:14 +02:00
|
|
|
$(VENV_BIN)/twine upload --repository=httpie dist/*
|
2014-04-28 14:25:45 +03:00
|
|
|
@echo
|
|
|
|
|
2016-01-02 19:33:48 +02:00
|
|
|
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
###############################################################################
|
|
|
|
# Uninstalling
|
|
|
|
###############################################################################
|
2016-01-02 19:33:48 +02:00
|
|
|
|
|
|
|
uninstall-httpie:
|
2019-12-04 18:49:07 +02:00
|
|
|
@echo $(H1)Uninstalling httpie$(H1END)
|
|
|
|
- $(VENV_PIP) uninstall --yes httpie &2>/dev/null
|
2016-01-02 19:33:48 +02:00
|
|
|
|
|
|
|
@echo "Verifying…"
|
2019-12-04 19:09:51 +02:00
|
|
|
cd .. && ! $(VENV_PYTHON) -m httpie --version &2>/dev/null
|
2016-01-02 19:33:48 +02:00
|
|
|
|
|
|
|
@echo "Done"
|
|
|
|
@echo
|
|
|
|
|
|
|
|
|
2018-07-12 21:16:16 +02:00
|
|
|
###############################################################################
|
2019-02-03 16:08:29 +02:00
|
|
|
# Homebrew
|
2018-07-12 21:16:16 +02:00
|
|
|
###############################################################################
|
|
|
|
|
2019-02-03 16:08:29 +02:00
|
|
|
brew-deps:
|
|
|
|
extras/brew-deps.py
|
2019-02-03 15:58:23 +02:00
|
|
|
|
|
|
|
brew-test:
|
2021-09-08 11:01:27 +02:00
|
|
|
@echo $(H1)Uninstalling httpie$(H1END)
|
2019-02-03 15:58:23 +02:00
|
|
|
- brew uninstall httpie
|
2021-09-08 11:01:27 +02:00
|
|
|
|
|
|
|
@echo $(H1)Building from source…$(H1END)
|
|
|
|
- brew install --build-from-source ./extras/httpie.rb
|
|
|
|
|
|
|
|
@echo $(H1)Verifying…$(H1END)
|
2019-02-03 15:58:23 +02:00
|
|
|
brew test httpie
|
2021-09-08 11:01:27 +02:00
|
|
|
|
|
|
|
@echo $(H1)Auditing…$(H1END)
|
2019-02-03 15:58:23 +02:00
|
|
|
brew audit --strict httpie
|