diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index c0d5c8ac..f09c11d0 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,7 +19,7 @@ jobs: # We install the full dev requirements to make sure everything installs OK run: | python -m pip install pip - pip install --requirement ./requirements.dev.txt + pip install -e .[dev] - name: Analysing the code with Black run: | black --check . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c3112be..eb0c60fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,8 +35,7 @@ jobs: - name: Install dependencies run: | python -m pip install pip - pip install pytest~=6.1.2 pytest-cov~=2.11.1 wheel - pip install --requirement ./requirements.txt + pip install -e .[test] - name: Testing the code with pytest run: | diff --git a/README.md b/README.md index 5135f5cd..c5b2b20e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Receipt, passport and invoice OCR python helper for Mindee API +# Mindee API helper library for Python The full documentation is available [here](https://developers.mindee.com/docs/getting-started) @@ -13,21 +13,20 @@ Install from PyPi using pip, a package manager for Python. ```shell script pip install mindee ``` - + Don't have pip installed? Try installing it, by running this from the command line: ```shell script $ curl https://bootstrap.pypa.io/get-pip.py | python ``` -Getting started with the Mindee API couldn't be easier. Create a Client and you're ready to go. - +Getting started with the Mindee API couldn't be easier. +Create a Client and you're ready to go. ## Create your Client -The mindee.Client needs your API credentials. You can either pass these directly to the constructor (see the code below) or via environment variables. - - +The mindee.Client needs your [API credentials](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key). +You can either pass these directly to the constructor (see the code below) or via environment variables. Depending on what type of document you want to parse, you need to add specifics auth token for each endpoint. @@ -43,7 +42,8 @@ mindee_client = Client( ) ``` -We suggest storing your credentials as environment variables. Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public. +We suggest storing your credentials as environment variables. +Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public. ## Parsing methods @@ -71,11 +71,10 @@ parsed_data = mindee_client.parse_license_plate("/path/to/file") You can pass your input file in three ways: - From file path ```python receipt_data = mindee_client.parse_receipt('/path/to/file', input_type="path") -``` +``` From a file object ```python @@ -87,4 +86,3 @@ From a base64 ```python receipt_data = mindee_client.parse_receipt(base64_string, input_type="base64") ``` - diff --git a/mindee/version b/mindee/version new file mode 100644 index 00000000..0495c4a8 --- /dev/null +++ b/mindee/version @@ -0,0 +1 @@ +1.2.3 diff --git a/mindee/versions.py b/mindee/versions.py index 762d935b..43f45f82 100644 --- a/mindee/versions.py +++ b/mindee/versions.py @@ -1,6 +1,10 @@ +import os import sys -__version__ = "1.2.3" + +dir_path = os.path.dirname(os.path.realpath(__file__)) +with open(os.path.join(dir_path, "version"), "r") as version_file: + __version__ = version_file.read().strip() python_version = "%s.%s" % (sys.version_info[0], sys.version_info[1]) diff --git a/requirements.dev.txt b/requirements.dev.txt deleted file mode 100644 index 78031e23..00000000 --- a/requirements.dev.txt +++ /dev/null @@ -1,8 +0,0 @@ -black==21.12b0 -requests~=2.23.0 -pytest~=6.1.2 -python-magic~=0.4.18 -pytz~=2020.1 -setuptools~=49.2.0 -PyMuPDF~=1.18.19 -pytest-cov~=2.11.1 diff --git a/requirements.txt b/requirements.txt index 422f332a..c76f16ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,20 @@ -requests~=2.23.0 -pytz~=2021.1 -PyMuPDF~=1.18.17 +# +# This file is autogenerated by pip-compile with python 3.8 +# To update, run: +# +# pip-compile +# +certifi==2021.10.8 + # via requests +chardet==4.0.0 + # via requests +idna==2.10 + # via requests +pymupdf==1.18.17 + # via mindee (setup.py) +pytz==2021.3 + # via mindee (setup.py) +requests==2.25.1 + # via mindee (setup.py) +urllib3==1.26.8 + # via requests diff --git a/setup.py b/setup.py index 2ed6ce43..3671290d 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,10 @@ +import os import re from setuptools import find_packages, setup -from mindee.versions import __version__ +dir_path = os.path.dirname(os.path.realpath(__file__)) +with open(os.path.join(dir_path, "mindee", "version"), "r") as version_file: + __version__ = version_file.read().strip() with open("README.md", "r", newline="", encoding="utf-8") as fh: long_description = fh.read() @@ -12,28 +15,27 @@ GIT_URL = "https://github.com/publicMindee/mindee-api-python" -def make_requirements_list(file="requirements.txt", only_regular=True): - """ - Make a list of package requirements from a requirements.txt file - :param file: path to txt file - :param only_regular: remove rows with /, #, space or empty - :return: - """ - with open(file) as f: - lines = f.read().splitlines() - if only_regular: - regex = ( - "\/$|^#|^$$|^git\+" # remove line with /, starting by # or space or empty - ) - return [line for line in lines if not re.findall(regex, line)] - else: - return lines +requirements = [ + "requests==2.25.1", + "pytz==2021.3", + "PyMuPDF==1.18.17", +] +test_requirements = [ + "pytest==6.1.2", + "pytest-cov==2.11.1", +] + +dev_requirements = [ + "black==21.12b0", + "setuptools==49.2.0", + "pip-tools==6.4.0", +] setup( python_requires=">=3.6", - name=f"{PACKAGE_NAME}", - description="Mindee API helper library for python", + name=PACKAGE_NAME, + description="Mindee API helper library for Python", version=__version__, long_description=long_description, long_description_content_type="text/markdown", @@ -41,6 +43,18 @@ def make_requirements_list(file="requirements.txt", only_regular=True): packages=find_packages(), author="Mindee", author_email="devrel@mindee.com", - install_requires=make_requirements_list(), + install_requires=requirements, + extras_require={ + "dev": dev_requirements, + "test": test_requirements, + }, include_package_data=True, + package_data={"mindee": ["version"]}, + classifiers=[ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + ], )