diff --git a/Makefile b/Makefile index 8f3575d..41d19d9 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ SYSDEPS = \ python3-dev \ python-pip \ python3-pip - TEST_PREFIX = PYTHONWARNINGS=all FULLTEXT_TESTING=1 +PASSWORD ?= test: ## Run tests. ${MAKE} install-git-hooks @@ -47,10 +47,6 @@ sysdeps: ## Install system deps (Ubuntu). sudo apt-get install python sudo pip2 install --pre --upgrade pyhwp -publish: ## Upload package on PYPI. - $(PYTHON) setup.py register - $(PYTHON) setup.py sdist upload - clean: ## Remove all build files. rm -rf `find . -type d -name __pycache__ \ -o -type f -name \*.bak \ @@ -81,3 +77,30 @@ install-git-hooks: ## Install GIT pre-commit hook. help: ## Display callable targets. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + +# --- distribution + +sdist: ## Create a tar.gz distribution. + $(PYTHON) setup.py sdist + $(PYTHON) setup.py --version + +priv-pypi-upload: ## Upload source distribution on private PYPI repo. + # Note: to reference the uploaded distribution, requirements.txt will + # need an entry like this: + # --extra-index-url http://pypi.dev.veristack.com/root/veristack-fulltext/+simple/ + # fulltext==0.8.315.b00117c + ${MAKE} sdist + venv/bin/pip install devpi-client +ifndef PASSWORD + venv/bin/python -m devpi login root +else + venv/bin/python -m devpi login root --password=$(PASSWORD) +endif + # Create index (done once) + # venv/bin/python -m devpi index --create root/veristack-fulltext + venv/bin/python -m devpi use http://pypi.dev.veristack.com/root/veristack-fulltext + venv/bin/python -m devpi upload -v dist/fulltext-`$(PYTHON) setup.py --version`.tar.gz + +publish: ## Upload package on PYPI. + $(PYTHON) setup.py register + $(PYTHON) setup.py sdist upload diff --git a/setup.py b/setup.py index a815a73..322cd67 100755 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ import os import sys +import subprocess from os.path import dirname from os.path import join as pathjoin from setuptools import find_packages @@ -9,7 +10,21 @@ NAME = 'fulltext' -VERSION = '0.7' +if os.path.isdir('.git'): + # Version is "0.X.{num-commits}.{short-git-hash}", + # e.g. "pkg-0.2.102.3de9bd2". + _gitcount = subprocess.check_output( + "git rev-list --count --first-parent HEAD", + shell=True).strip().decode() + _githash = subprocess.check_output( + "git rev-parse --short HEAD", shell=True).strip().decode() + VERSION = "0.8+0.%s.%s" % (_gitcount, _githash) +else: + # This is here mainly for testing the .tar.gz distribution which + # has no .git directory. Distros published on the PYPI repo are + # supposed to use the above versioning notation. + VERSION = "0.8.0" + if os.name == 'nt' and not sys.maxsize > 2 ** 32: # https://github.com/btimby/fulltext/issues/79 raise RuntimeError("Python 32 bit is not supported")