From 5fd9a72de895aaaddbc11828c8bec0cb2ee5c2b0 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 2 Jun 2022 20:29:54 +0100 Subject: [PATCH] Convert helpers to Poetry to make them easier to package for NixOS --- .woodpecker/build.yml | 2 +- datman-helper-mysql/poetry.lock | 8 ++ datman-helper-mysql/pyproject.toml | 19 ++++ datman-helper-mysql/setup.py | 119 -------------------------- datman-helper-postgres/poetry.lock | 8 ++ datman-helper-postgres/pyproject.toml | 19 ++++ datman-helper-postgres/setup.py | 119 -------------------------- 7 files changed, 55 insertions(+), 239 deletions(-) create mode 100644 datman-helper-mysql/poetry.lock create mode 100644 datman-helper-mysql/pyproject.toml delete mode 100644 datman-helper-mysql/setup.py create mode 100644 datman-helper-postgres/poetry.lock create mode 100644 datman-helper-postgres/pyproject.toml delete mode 100644 datman-helper-postgres/setup.py diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 51498d8..02df615 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -39,7 +39,7 @@ pipeline: - cargo install -q --path yama - cargo install -q --path datman - python3.9 -m venv testsuite/.venv - - ./testsuite/.venv/bin/pip install -e testsuite -e datman-helper-postgres -e datman-helper-mysql + - ./testsuite/.venv/bin/pip install ./testsuite ./datman-helper-postgres ./datman-helper-mysql - cd testsuite && . .venv/bin/activate && TEST_POSTGRES=$(hostname),testsuitedb,root TEST_MYSQL=$(hostname),testsuitemydb,root green - sccache --show-stats environment: diff --git a/datman-helper-mysql/poetry.lock b/datman-helper-mysql/poetry.lock new file mode 100644 index 0000000..f41588b --- /dev/null +++ b/datman-helper-mysql/poetry.lock @@ -0,0 +1,8 @@ +package = [] + +[metadata] +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "fafb334cb038533f851c23d0b63254223abf72ce4f02987e7064b0c95566699a" + +[metadata.files] diff --git a/datman-helper-mysql/pyproject.toml b/datman-helper-mysql/pyproject.toml new file mode 100644 index 0000000..cb2ff3e --- /dev/null +++ b/datman-helper-mysql/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "datman-helper-mysql" +version = "0.1.0" +description = "MySQL integration for Datman" +authors = ["Olivier 'reivilibre' "] +license = "GPL-3.0-or-later" + +[tool.poetry.dependencies] +python = "^3.8" + +[tool.poetry.dev-dependencies] + +[tool.poetry.scripts] +datman-helper-mysql-backup="datman_helper_mysql.backup:cli" +datman-helper-mysql-restore="datman_helper_mysql.restore:cli" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/datman-helper-mysql/setup.py b/datman-helper-mysql/setup.py deleted file mode 100644 index 1317e06..0000000 --- a/datman-helper-mysql/setup.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import io -import os -import sys -from shutil import rmtree - -from setuptools import Command, find_packages, setup - -# Package meta-data. -NAME = "datman_helper_mysql" -DESCRIPTION = "MySQL integration for Datman" -URL = "https://bics.ga/reivilibre/yama" -EMAIL = "reivi@librepush.net" -AUTHOR = "Olivier 'reivilibre'" -REQUIRES_PYTHON = ">=3.7.0" -VERSION = "0.1.0" - -# What packages are required for this module to be executed? -REQUIRED = [] - - -# What packages are optional? -EXTRAS = {} - -# The rest you shouldn't have to touch too much :) -# ------------------------------------------------ -# Except, perhaps the License and Trove Classifiers! -# If you do change the License, remember to change the Trove Classifier for that! - -here = os.path.abspath(os.path.dirname(__file__)) - -# Import the README and use it as the long-description. -# Note: this will only work if 'README.md' is present in your MANIFEST.in file! -try: - with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f: - long_description = "\n" + f.read() -except FileNotFoundError: - long_description = DESCRIPTION - -# Load the package's __version__.py module as a dictionary. -about = {} -if not VERSION: - project_slug = NAME.lower().replace("-", "_").replace(" ", "_") - with open(os.path.join(here, project_slug, "__version__.py")) as f: - exec(f.read(), about) -else: - about["__version__"] = VERSION - - -class UploadCommand(Command): - """Support setup.py upload.""" - - description = "Build and publish the package." - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print("\033[1m{0}\033[0m".format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - self.status("Removing previous builds…") - rmtree(os.path.join(here, "dist")) - except OSError: - pass - - self.status("Building Source and Wheel (universal) distribution…") - os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable)) - - self.status("Uploading the package to PyPI via Twine…") - os.system("twine upload dist/*") - - self.status("Pushing git tags…") - os.system("git tag v{0}".format(about["__version__"])) - os.system("git push --tags") - - sys.exit() - - -# Where the magic happens: -setup( - name=NAME, - version=about["__version__"], - description=DESCRIPTION, - long_description=long_description, - long_description_content_type="text/markdown", - author=AUTHOR, - author_email=EMAIL, - python_requires=REQUIRES_PYTHON, - url=URL, - packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), - # If your package is a single module, use this instead of 'packages': - # py_modules=['mypackage'], - entry_points={ - "console_scripts": [ - "datman-helper-mysql-backup=datman_helper_mysql.backup:cli", - "datman-helper-mysql-restore=datman_helper_mysql.restore:cli", - ], - }, - install_requires=REQUIRED, - extras_require=EXTRAS, - include_package_data=True, - # TODO license='GPL3', - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - "Programming Language :: Python", - "Programming Language :: Python :: 3", - ], -) diff --git a/datman-helper-postgres/poetry.lock b/datman-helper-postgres/poetry.lock new file mode 100644 index 0000000..f41588b --- /dev/null +++ b/datman-helper-postgres/poetry.lock @@ -0,0 +1,8 @@ +package = [] + +[metadata] +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "fafb334cb038533f851c23d0b63254223abf72ce4f02987e7064b0c95566699a" + +[metadata.files] diff --git a/datman-helper-postgres/pyproject.toml b/datman-helper-postgres/pyproject.toml new file mode 100644 index 0000000..a828a35 --- /dev/null +++ b/datman-helper-postgres/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "datman-helper-postgres" +version = "0.1.0" +description = "Postgres integration for Datman" +authors = ["Olivier 'reivilibre' "] +license = "GPL-3.0-or-later" + +[tool.poetry.dependencies] +python = "^3.8" + +[tool.poetry.dev-dependencies] + +[tool.poetry.scripts] +datman-helper-postgres-backup="datman_helper_postgres.backup:cli" +datman-helper-postgres-restore="datman_helper_postgres.restore:cli" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/datman-helper-postgres/setup.py b/datman-helper-postgres/setup.py deleted file mode 100644 index 833fcd8..0000000 --- a/datman-helper-postgres/setup.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import io -import os -import sys -from shutil import rmtree - -from setuptools import Command, find_packages, setup - -# Package meta-data. -NAME = "datman_helper_postgres" -DESCRIPTION = "Postgres integration for Datman" -URL = "https://bics.ga/reivilibre/yama" -EMAIL = "reivi@librepush.net" -AUTHOR = "Olivier 'reivilibre'" -REQUIRES_PYTHON = ">=3.7.0" -VERSION = "0.1.0" - -# What packages are required for this module to be executed? -REQUIRED = [] - - -# What packages are optional? -EXTRAS = {} - -# The rest you shouldn't have to touch too much :) -# ------------------------------------------------ -# Except, perhaps the License and Trove Classifiers! -# If you do change the License, remember to change the Trove Classifier for that! - -here = os.path.abspath(os.path.dirname(__file__)) - -# Import the README and use it as the long-description. -# Note: this will only work if 'README.md' is present in your MANIFEST.in file! -try: - with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f: - long_description = "\n" + f.read() -except FileNotFoundError: - long_description = DESCRIPTION - -# Load the package's __version__.py module as a dictionary. -about = {} -if not VERSION: - project_slug = NAME.lower().replace("-", "_").replace(" ", "_") - with open(os.path.join(here, project_slug, "__version__.py")) as f: - exec(f.read(), about) -else: - about["__version__"] = VERSION - - -class UploadCommand(Command): - """Support setup.py upload.""" - - description = "Build and publish the package." - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print("\033[1m{0}\033[0m".format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - self.status("Removing previous builds…") - rmtree(os.path.join(here, "dist")) - except OSError: - pass - - self.status("Building Source and Wheel (universal) distribution…") - os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable)) - - self.status("Uploading the package to PyPI via Twine…") - os.system("twine upload dist/*") - - self.status("Pushing git tags…") - os.system("git tag v{0}".format(about["__version__"])) - os.system("git push --tags") - - sys.exit() - - -# Where the magic happens: -setup( - name=NAME, - version=about["__version__"], - description=DESCRIPTION, - long_description=long_description, - long_description_content_type="text/markdown", - author=AUTHOR, - author_email=EMAIL, - python_requires=REQUIRES_PYTHON, - url=URL, - packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), - # If your package is a single module, use this instead of 'packages': - # py_modules=['mypackage'], - entry_points={ - "console_scripts": [ - "datman-helper-postgres-backup=datman_helper_postgres.backup:cli", - "datman-helper-postgres-restore=datman_helper_postgres.restore:cli", - ], - }, - install_requires=REQUIRED, - extras_require=EXTRAS, - include_package_data=True, - # TODO license='GPL3', - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - "Programming Language :: Python", - "Programming Language :: Python :: 3", - ], -)