From 3321cc4b8de5a7584f6ca0bf644b192dd508fb9d Mon Sep 17 00:00:00 2001 From: Arvind Rajan Date: Tue, 19 Mar 2024 19:19:29 +1100 Subject: [PATCH 1/2] Addressing installation issue with Windows --- .github/workflows/merge.yaml | 5 +--- .github/workflows/merge_macos.yaml | 39 +++++++++++++++++++++++++++ .github/workflows/merge_raspbian.yaml | 39 +++++++++++++++++++++++++++ .github/workflows/merge_windows.yaml | 39 +++++++++++++++++++++++++++ README.md | 3 +++ setup.py | 14 +++++++--- tests/test_fastanpr.py | 1 - 7 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/merge_macos.yaml create mode 100644 .github/workflows/merge_raspbian.yaml create mode 100644 .github/workflows/merge_windows.yaml diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index 497f10e..519b9b6 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -14,11 +14,8 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest, macos-latest, raspberrypi] + os: [ubuntu-latest] python-version: [ "3.8", "3.9", "3.10", "3.11" ] - exclude: - - os: windows-latest - python-version: "3.11" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/merge_macos.yaml b/.github/workflows/merge_macos.yaml new file mode 100644 index 0000000..f03904e --- /dev/null +++ b/.github/workflows/merge_macos.yaml @@ -0,0 +1,39 @@ +name: main-macos + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + if_merged: + name: Run unit tests on different python versions and check build + if: github.event.pull_request.merged == true + strategy: + fail-fast: false + matrix: + os: [macos-latest] + python-version: [ "3.8", "3.9", "3.10", "3.11" ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[dev] + - name: Lint with flake8 + uses: py-actions/flake8@v2 + with: + max-line-length: "120" + - name: Test with pytest + run: pytest --exitfirst --verbose --failed-first + - name: Build package + run: python setup.py sdist bdist_wheel + - name: Checking build + run: twine check dist/* diff --git a/.github/workflows/merge_raspbian.yaml b/.github/workflows/merge_raspbian.yaml new file mode 100644 index 0000000..8be6df9 --- /dev/null +++ b/.github/workflows/merge_raspbian.yaml @@ -0,0 +1,39 @@ +name: main-raspbian + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + if_merged: + name: Run unit tests on different python versions and check build + if: github.event.pull_request.merged == true + strategy: + fail-fast: false + matrix: + os: [raspberrypi] + python-version: [ "3.8", "3.9", "3.10", "3.11" ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[dev] + - name: Lint with flake8 + uses: py-actions/flake8@v2 + with: + max-line-length: "120" + - name: Test with pytest + run: pytest --exitfirst --verbose --failed-first + - name: Build package + run: python setup.py sdist bdist_wheel + - name: Checking build + run: twine check dist/* diff --git a/.github/workflows/merge_windows.yaml b/.github/workflows/merge_windows.yaml new file mode 100644 index 0000000..7031639 --- /dev/null +++ b/.github/workflows/merge_windows.yaml @@ -0,0 +1,39 @@ +name: main-windows + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + if_merged: + name: Run unit tests on different python versions and check build + if: github.event.pull_request.merged == true + strategy: + fail-fast: false + matrix: + os: [windows-latest] + python-version: [ "3.8", "3.9", "3.10" ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[dev] + - name: Lint with flake8 + uses: py-actions/flake8@v2 + with: + max-line-length: "120" + - name: Test with pytest + run: pytest --exitfirst --verbose --failed-first + - name: Build package + run: python setup.py sdist bdist_wheel + - name: Checking build + run: twine check dist/* diff --git a/README.md b/README.md index 3c9172a..6110049 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ FastANPR logo [![Build Status](https://github.com/arvindrajan92/fastanpr/actions/workflows/merge.yaml/badge.svg)](https://github.com/arvindrajan92/fastanpr/actions) +[![Build Status](https://github.com/arvindrajan92/fastanpr/actions/workflows/merge_macos.yaml/badge.svg)](https://github.com/arvindrajan92/fastanpr/actions) +[![Build Status](https://github.com/arvindrajan92/fastanpr/actions/workflows/merge_raspbian.yaml/badge.svg)](https://github.com/arvindrajan92/fastanpr/actions) +[![Build Status](https://github.com/arvindrajan92/fastanpr/actions/workflows/merge_windows.yaml/badge.svg)](https://github.com/arvindrajan92/fastanpr/actions) [![Build Status](https://github.com/arvindrajan92/fastanpr/actions/workflows/push.yaml/badge.svg)](https://github.com/arvindrajan92/fastanpr/actions) [![Build Status](https://github.com/arvindrajan92/fastanpr/actions/workflows/publish.yaml/badge.svg)](https://github.com/arvindrajan92/fastanpr/actions) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/arvindrajan92/fastanpr)](https://github.com/arvindrajan92/fastanpr/releases) diff --git a/setup.py b/setup.py index be2b783..811fbbf 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,9 @@ import os +import sys import subprocess from setuptools import setup, find_packages +# Getting build version try: VERSION = ( subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE) @@ -25,7 +27,13 @@ with open("fastanpr/version.py", "r", encoding="utf-8") as fh: VERSION = fh.read().strip().lstrip("__version__ = \"").rstrip("\"") -DESCRIPTION = 'A fast automatic number-plate recognition (ANPR) library' +# Set Python version requirements based on the operating system +if sys.platform.startswith('win'): + PYTHON_REQUIRES = '>=3.8, <3.11' +else: + PYTHON_REQUIRES = '>=3.8, <3.12' + +# Getting long description from README with open("README.md", "r") as fh: LONG_DESCRIPTION = fh.read() @@ -34,14 +42,14 @@ version=VERSION, author="arvindrajan92 (Arvind Rajan)", author_email="", - description=DESCRIPTION, + description='A fast automatic number-plate recognition (ANPR) library', long_description_content_type="text/markdown", long_description=LONG_DESCRIPTION, packages=find_packages(), package_data={'': ['*.pt'], 'fastanpr': ['*.pt']}, include_package_data=True, install_requires=['ultralytics>=8.1.26', 'paddlepaddle>=2.6.0', 'paddleocr>=2.7.0.3'], - python_requires='>=3.8', + python_requires=PYTHON_REQUIRES, extras_require={ 'dev': ['pytest', 'pytest-asyncio', 'twine', 'python-Levenshtein', 'setuptools', 'wheel', 'twine', 'flake8'] }, diff --git a/tests/test_fastanpr.py b/tests/test_fastanpr.py index fbfb0f9..965afa9 100644 --- a/tests/test_fastanpr.py +++ b/tests/test_fastanpr.py @@ -1,5 +1,4 @@ import cv2 -import time import pytest import Levenshtein import numpy as np From 8e807411f7fbd533d56d6a90b6ffda42ab710614 Mon Sep 17 00:00:00 2001 From: Arvind Rajan Date: Tue, 19 Mar 2024 19:28:55 +1100 Subject: [PATCH 2/2] Updating README.md with installation requirements --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6110049..69f427b 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,15 @@ A fast *automatic number-plate recognition* (ANPR) library. This package employs ![Example outputs](misc/sample.png) ## Installation +You can install the package using pip: ```bash pip install fastanpr ``` +### Requirements +- Windows: + - Python >=3.9, <3.11 +- Ubuntu, macOS, Raspbian: + - Python >=3.9, <3.12 ## Usage ```python