From 87f3b36855ff69612e703f21945224df9e4f6774 Mon Sep 17 00:00:00 2001 From: lemonsaurus Date: Mon, 5 Jul 2021 14:50:23 +0200 Subject: [PATCH 1/5] Just get rid of setup.py. We don't need editable installs. Instead, we can just use `poetry run blackbox` to test. --- setup.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 1abbd06..0000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -import setuptools - -if __name__ == "__main__": - setuptools.setup() From 8fb06a67fdb8f0b61e71da72e5529eeccfb644c3 Mon Sep 17 00:00:00 2001 From: lemonsaurus Date: Mon, 5 Jul 2021 14:52:13 +0200 Subject: [PATCH 2/5] poe tests instead of poe test. --- .github/workflows/tests.yaml | 2 +- pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 436de86..90fdad3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -33,4 +33,4 @@ jobs: run: poe lint - name: Testing - run: poe test \ No newline at end of file + run: poe tests \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ff3414b..8a187b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,8 +54,9 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] blackbox = "blackbox.cli:cli" +# Use 'poetry run poe ' to run these. [tool.poe.tasks] -test = "pytest --cov blackbox -vv --cov-report=term-missing ." +tests = "pytest --cov blackbox -vv --cov-report=term-missing ." lint = "flake8 ." isort = "isort ." html = "pytest --cov blackbox --cov-report=html ." From da49068ccfbd627d61ab5b6adc315883a783fbd0 Mon Sep 17 00:00:00 2001 From: lemonsaurus Date: Mon, 5 Jul 2021 14:53:17 +0200 Subject: [PATCH 3/5] Use single-source to fetch version for --version. --- blackbox/__init__.py | 4 ++++ blackbox/cli.py | 12 +++++++++--- pyproject.toml | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/blackbox/__init__.py b/blackbox/__init__.py index e69de29..93274ea 100644 --- a/blackbox/__init__.py +++ b/blackbox/__init__.py @@ -0,0 +1,4 @@ +from pathlib import Path +from single_source import get_version + +__version__ = get_version(__name__, Path(__file__).parent.parent) \ No newline at end of file diff --git a/blackbox/cli.py b/blackbox/cli.py index 2a6e0b2..c6494ee 100644 --- a/blackbox/cli.py +++ b/blackbox/cli.py @@ -105,14 +105,20 @@ def run() -> bool: @click.command() -@click.option('--config', help="Path to blackbox.yaml file") -@click.option('--init', is_flag=True, help="Generate blackbox.yaml file and exit") -def cli(config, init): +@click.option('--config', help="Path to blackbox.yaml file.") +@click.option('--init', is_flag=True, help="Generate blackbox.yaml file and exit.") +@click.option('--version', is_flag=True, help="Show version and exit.") +def cli(config, init, version): """ BLACKBOX Backup database to external storage system """ # noqa + if version: + from blackbox import __version__ + print(f"Blackbox {__version__}") + exit() + if init: config_file = Path("blackbox.yaml") if not config_file.exists(): diff --git a/pyproject.toml b/pyproject.toml index 8a187b6..95227d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "blackbox-cli" packages = [ { include = "blackbox" } ] -version = "0" # This is not in use. The version is fetched from the most recent git tag. +version = "2.1.5" description = "Tool for automatic backups of databases" authors = ["Leon Sandøy "] license = "MIT" @@ -31,7 +31,8 @@ jinja2 = "^2.11.2" click = "^7.1.2" dropbox = "^11.0.0" pytelegrambotapi = "^3.7.7" -pytest-testdox = "^2.0.1" +single-source = "^0.2.0" +stone = "^3.2.1" [tool.poetry.dev-dependencies] pytest = "*" From 58bfac84116649faa600c475bd7bdc59927463e4 Mon Sep 17 00:00:00 2001 From: lemonsaurus Date: Mon, 5 Jul 2021 14:53:35 +0200 Subject: [PATCH 4/5] Clean up dependencies. --- poetry.lock | 35 +++++++++++++++++++++++------------ pyproject.toml | 12 +++++------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/poetry.lock b/poetry.lock index 932cb62..d730f17 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,7 +2,7 @@ name = "atomicwrites" version = "1.4.0" description = "Atomic file writes." -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -10,7 +10,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "attrs" version = "20.3.0" description = "Classes Without Boilerplate" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -103,7 +103,6 @@ python-versions = "*" [package.dependencies] requests = ">=2.16.2" six = ">=1.12.0" -stone = ">=2" [[package]] name = "flake8" @@ -146,7 +145,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "iniconfig" version = "1.1.1" description = "iniconfig: brain-dead simple config-ini parsing" -category = "main" +category = "dev" optional = false python-versions = "*" @@ -220,7 +219,7 @@ python-versions = "*" name = "packaging" version = "20.9" description = "Core utilities for Python packages" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -239,7 +238,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "pluggy" version = "0.13.1" description = "plugin and hook calling mechanisms for python" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -270,7 +269,7 @@ tomlkit = ">=0.6.0,<1.0.0" name = "py" version = "1.10.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -294,7 +293,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "pyparsing" version = "2.4.7" description = "Python parsing module" -category = "main" +category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" @@ -317,7 +316,7 @@ redis = ["redis (>=3.4.1)"] name = "pytest" version = "6.2.3" description = "pytest: simple powerful testing with Python" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -383,7 +382,7 @@ test = ["pytest (>=4.0)", "coverage", "docutils (>=0.12)", "Pygments (>=2.0)", " name = "pytest-testdox" version = "2.0.1" description = "A testdox format reporter for pytest" -category = "main" +category = "dev" optional = false python-versions = ">=3.5" @@ -454,6 +453,14 @@ python-versions = "*" [package.dependencies] botocore = ">=1.12.36,<2.0a.0" +[[package]] +name = "single-source" +version = "0.2.0" +description = "Access to the project version in Python code for PEP 621-style projects" +category = "main" +optional = false +python-versions = ">=3.6,<4.0" + [[package]] name = "six" version = "1.15.0" @@ -491,7 +498,7 @@ test = ["pytest (>=3.6)", "pytest-cov", "pytest-django", "zope.component", "sybi name = "toml" version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" -category = "main" +category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" @@ -530,7 +537,7 @@ dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"] [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "26c498368d51234dd1570157df3b76a230f3c4f68cde5caaf79d7c56bd128b52" +content-hash = "485a8e27e709b9f83aab9e160a306186f884f6c84744fef07eb49faa5ca93b29" [metadata.files] atomicwrites = [ @@ -820,6 +827,10 @@ s3transfer = [ {file = "s3transfer-0.3.6-py2.py3-none-any.whl", hash = "sha256:5d48b1fd2232141a9d5fb279709117aaba506cacea7f86f11bc392f06bfa8fc2"}, {file = "s3transfer-0.3.6.tar.gz", hash = "sha256:c5dadf598762899d8cfaecf68eba649cd25b0ce93b6c954b156aaa3eed160547"}, ] +single-source = [ + {file = "single-source-0.2.0.tar.gz", hash = "sha256:f40f94c7f2e72c854b9c0c6f7d6b545d74ada9ebd454f9f07f8fb743b22bccf5"}, + {file = "single_source-0.2.0-py3-none-any.whl", hash = "sha256:82c55b00515a30c8f7c262b986a399ca023911ebb6a86f0953d4c50448c36b16"}, +] six = [ {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, diff --git a/pyproject.toml b/pyproject.toml index 95227d0..a58868d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,21 +35,19 @@ single-source = "^0.2.0" stone = "^3.2.1" [tool.poetry.dev-dependencies] +flake8 = "^3.9.0" +flake8-isort = "^4.0.0" pytest = "*" pytest-cov = "^2.11.1" pytest-mock = "^3.5.1" -flake8 = "^3.9.0" -flake8-isort = "^4.0.0" pytest-subprocess = "^1.0.1" +pytest-testdox = "^2.0.1" +poethepoet = "^0.10.0" requests-mock = "^1.8.0" win32-setctime = "^1.0.3" -poethepoet = "^0.10.0" - -[tool.poetry-version-plugin] -source = "git-tag" [build-system] -requires = ["poetry-core>=1.1.0"] +requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] From 197d6dcb8689aee84fb12084fdd40daae1692f2b Mon Sep 17 00:00:00 2001 From: lemonsaurus Date: Mon, 5 Jul 2021 14:53:48 +0200 Subject: [PATCH 5/5] Bump the version on release. --- .github/workflows/publish.yaml | 41 +++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ebe15a6..a231beb 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,12 +5,38 @@ on: types: [ published ] jobs: + bump-pyproject-version: + name: Bump pyproject version + runs-on: ubuntu-latest + + steps: + - name: Checkout the repo + uses: actions/checkout@v2 + + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: "3.9" + + - name: Install Poetry + run: pip install poetry + + - name: Bump the version + run: poetry version ${{ github.event.release.tag_name }} + + - name: Commit the changes + run: | + git add pyproject.toml + git commit -m "Bump version to ${{ github.event.release.tag_name }}" + git push origin main + publish-to-pipy: - name: publish to pypi.org + name: Publish to pypi.org runs-on: ubuntu-latest + needs: bump-pyproject-version steps: - - name: Checkout the repo and the submodules. + - name: Checkout the repo. uses: actions/checkout@v2 - name: Set up Python @@ -18,24 +44,19 @@ jobs: with: python-version: "3.9" - - name: Install Poetry >= 1.2.0a - run: | - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -O && - python install-poetry.py --preview + - name: Install poetry + run: pip install poetry - name: Install dependencies run: poetry install - - name: Install poetry-version-plugin - run: poetry plugin add poetry-version-plugin - - name: Build and publish to pypi run: | poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} && poetry publish --build build-and-push-on-release: - name: Build and push + name: Build and push to DockerHub runs-on: ubuntu-latest needs: publish-to-pipy