From fcfa6c4dbf07bd6110dfd0f82ab16396e336e5b7 Mon Sep 17 00:00:00 2001 From: Luca Foppiano Date: Wed, 24 Apr 2024 15:58:32 +0800 Subject: [PATCH] replace setup.py with pyproject.toml, add requirements, and github action builds --- .github/workflows/ci-build.yml | 38 ++++++++++++++++++++++++++++ .github/workflows/ci-release.yml | 43 ++++++++++++++++++++++++++++++++ pyproject.toml | 37 +++++++++++++++++++++++++++ requirements.txt | 1 + setup.py | 18 ------------- 5 files changed, 119 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/ci-build.yml create mode 100644 .github/workflows/ci-release.yml create mode 100644 pyproject.toml create mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000..4e08794 --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,38 @@ +name: Build unstable + +on: [push] + +concurrency: + group: unstable + + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ 3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12' ] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Cleanup more disk space + run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade flake8 pytest pycodestyle pytest-cov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +# - name: Test with pytest +# run: | +# pytest \ No newline at end of file diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml new file mode 100644 index 0000000..e25ac21 --- /dev/null +++ b/.github/workflows/ci-release.yml @@ -0,0 +1,43 @@ +name: Build release + +on: + workflow_dispatch: + push: + tags: + - 'v*' + +concurrency: + group: docker + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + cache: 'pip' + - name: Cleanup more disk space + run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade flake8 pytest pycodestyle + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + # - name: Test with pytest + # run: | + # pytest + + - name: Build and Publish to PyPI + uses: conchylicultor/pypi-build-publish@v1 + with: + pypi-token: ${{ secrets.PYPI_API_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0a97cdc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[tool.bumpversion] +current_version = "0.0.8" +commit = "true" +tag = "true" +tag_name = "v{new_version}" + +[project] +name = "grobid-client-python" +license = { file = "LICENSE" } +authors = [ + { name = "Patrice Lopez", email = "patrice.lopez@science-miner.com" }, +] +maintainers = [ + { name = "Patrice Lopez", email = "patrice.lopez@science-miner.com" }, + { name = "Luca Foppiano", email = "lucanoro@duck.com" } +] +description = "Simple python client for GROBID REST services" +readme = "Readme.md" + +dynamic = ['version', "dependencies"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + +[tool.setuptools_scm] + +[project.urls] +Homepage = "https://github.com/kermitt2/grobid_client_python" +Repository = "https://github.com/kermitt2/grobid_client_python" +Changelog = "https://github.com/kermitt2/grobid_client_python" + +[project.scripts] +hello-world = "grobid_client=grobid_client.grobid_client" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index c29a3e8..0000000 --- a/setup.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup, find_packages - -setup(name='grobid_client_python', - version='0.0.8', - description='Simple python client for GROBID REST services', - author='kermitt2', - long_description=open("Readme.md", encoding='utf-8').read(), - long_description_content_type="text/markdown", - url="https://github.com/kermitt2/grobid_client_python", - packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), - install_requires=['requests'], - entry_points={ - 'console_scripts': ['grobid_client=grobid_client.grobid_client:main'] - }, - license='LICENSE', - )