2020-09-25 12:33:25 +02:00
#!/usr/bin/make
2020-08-28 17:17:07 +02:00
.PHONY : bdist sdist release check check -source check -flake 8 check -mypy
2020-09-25 12:33:25 +02:00
PKG = testing
VERSION = $( shell python3 -c 'from pyln import ${PKG};print(${PKG}.__version__)' )
2020-08-28 17:17:07 +02:00
2020-09-25 12:33:25 +02:00
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = docs
BUILDDIR = build
SDIST_FILE = " dist/pyln- ${ PKG } - $( VERSION) .tar.gz "
BDIST_FILE = " dist/pyln_ ${ PKG } - $( VERSION) -py3-none-any.whl "
2020-08-28 17:17:07 +02:00
ARTEFACTS = $( BDIST_FILE) $( SDIST_FILE)
2020-09-25 12:33:25 +02:00
check : check -source check -pytest
2020-08-28 17:17:07 +02:00
check-source : check -flake 8 check -mypy
check-flake8 :
2022-07-11 18:11:47 +02:00
flake8 --ignore= E501,E731,W503,E741 --exclude '*_pb2*.py,grpc2py.py' pyln tests
2020-08-28 17:17:07 +02:00
2020-09-25 12:33:25 +02:00
check-pytest :
pytest tests
2020-08-28 17:17:07 +02:00
check-mypy :
2022-04-25 14:38:41 +02:00
# MYPYPATH=$(PYTHONPATH) mypy --namespace-packages --follow-imports=skip tests pyln
2020-08-28 17:17:07 +02:00
2022-04-25 14:38:41 +02:00
pyproject.toml : pyln /${PKG }/__init__ .py
poetry version ${ VERSION }
2020-08-28 17:17:07 +02:00
2022-04-25 14:38:41 +02:00
$(SDIST_FILE) $(BDIST_FILE) : pyproject .toml
poetry build
2020-08-28 17:17:07 +02:00
2022-04-25 14:38:41 +02:00
test-release : check $( ARTEFACTS ) pyproject .toml
# No way of saying "it's ok if files exist" yet
poetry publish --repository testpypi || /bin/true
echo Sleeping for PyPI index to update
sleep 10
# Generate a requirements.txt file, needed for us to download requirements from the prod pypi instead of the test pypi, since some packages are not published to test pypi.
poetry export -f requirements.txt --output requirements.txt --without-hashes
2020-08-28 17:17:07 +02:00
# Create a test virtualenv, install from the testpypi and run the
# tests against it (make sure not to use any virtualenv that may have
2020-09-25 12:33:25 +02:00
# pyln-${PKG} already installed).
2020-08-28 17:17:07 +02:00
virtualenv testpypi --python= /usr/bin/python3 --download --always-copy --clear
2022-06-26 06:26:01 +02:00
testpypi/bin/python3 -m pip install -r requirements.txt pytest-timeout
2022-04-25 14:38:41 +02:00
testpypi/bin/python3 -m pip install -I --index-url https://test.pypi.org/simple/ --no-deps pyln-${ PKG } = = ${ VERSION }
2020-09-25 12:33:25 +02:00
testpypi/bin/python3 -c " from pyln import ${ PKG } ;assert( ${ PKG } .__version__ == ' $( VERSION) ') "
2020-08-28 17:17:07 +02:00
testpypi/bin/pytest tests
rm -rf testpypi
prod-release : test -release $( ARTEFACTS )
python3 -m twine upload $( ARTEFACTS)
clean :
rm -rf testpypi