Skip to content

Commit 95e815e

Browse files
ianardeefharper
andauthored
chg: 📌 use pip-tools and setup.py to pin all dependencies (#38)
* chg: 📌 use pip-tools and setup.py to pin all dependencies * remove trailing spaces * add link to API Key creation doc Co-authored-by: Frédéric Harper <hi@fred.dev>
1 parent 4827964 commit 95e815e

File tree

8 files changed

+71
-46
lines changed

8 files changed

+71
-46
lines changed

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
# We install the full dev requirements to make sure everything installs OK
2020
run: |
2121
python -m pip install pip
22-
pip install --requirement ./requirements.dev.txt
22+
pip install -e .[dev]
2323
- name: Analysing the code with Black
2424
run: |
2525
black --check .

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ jobs:
3535
- name: Install dependencies
3636
run: |
3737
python -m pip install pip
38-
pip install pytest~=6.1.2 pytest-cov~=2.11.1 wheel
39-
pip install --requirement ./requirements.txt
38+
pip install -e .[test]
4039
4140
- name: Testing the code with pytest
4241
run: |

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Receipt, passport and invoice OCR python helper for Mindee API
1+
# Mindee API helper library for Python
22

33
The full documentation is available [here](https://developers.mindee.com/docs/getting-started)
44

@@ -13,21 +13,20 @@ Install from PyPi using pip, a package manager for Python.
1313
```shell script
1414
pip install mindee
1515
```
16-
16+
1717
Don't have pip installed? Try installing it, by running this from the command line:
1818

1919
```shell script
2020
$ curl https://bootstrap.pypa.io/get-pip.py | python
2121
```
2222

23-
Getting started with the Mindee API couldn't be easier. Create a Client and you're ready to go.
24-
23+
Getting started with the Mindee API couldn't be easier.
24+
Create a Client and you're ready to go.
2525

2626
## Create your Client
2727

28-
The mindee.Client needs your API credentials. You can either pass these directly to the constructor (see the code below) or via environment variables.
29-
30-
28+
The mindee.Client needs your [API credentials](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key).
29+
You can either pass these directly to the constructor (see the code below) or via environment variables.
3130

3231
Depending on what type of document you want to parse, you need to add specifics auth token for each endpoint.
3332

@@ -43,7 +42,8 @@ mindee_client = Client(
4342
)
4443
```
4544

46-
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.
45+
We suggest storing your credentials as environment variables.
46+
Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public.
4747

4848

4949
## Parsing methods
@@ -71,11 +71,10 @@ parsed_data = mindee_client.parse_license_plate("/path/to/file")
7171

7272
You can pass your input file in three ways:
7373

74-
7574
From file path
7675
```python
7776
receipt_data = mindee_client.parse_receipt('/path/to/file', input_type="path")
78-
```
77+
```
7978

8079
From a file object
8180
```python
@@ -87,4 +86,3 @@ From a base64
8786
```python
8887
receipt_data = mindee_client.parse_receipt(base64_string, input_type="base64")
8988
```
90-

mindee/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.2.3

mindee/versions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import os
12
import sys
23

3-
__version__ = "1.2.3"
4+
5+
dir_path = os.path.dirname(os.path.realpath(__file__))
6+
with open(os.path.join(dir_path, "version"), "r") as version_file:
7+
__version__ = version_file.read().strip()
48

59
python_version = "%s.%s" % (sys.version_info[0], sys.version_info[1])
610

requirements.dev.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

requirements.txt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1-
requests~=2.23.0
2-
pytz~=2021.1
3-
PyMuPDF~=1.18.17
1+
#
2+
# This file is autogenerated by pip-compile with python 3.8
3+
# To update, run:
4+
#
5+
# pip-compile
6+
#
7+
certifi==2021.10.8
8+
# via requests
9+
chardet==4.0.0
10+
# via requests
11+
idna==2.10
12+
# via requests
13+
pymupdf==1.18.17
14+
# via mindee (setup.py)
15+
pytz==2021.3
16+
# via mindee (setup.py)
17+
requests==2.25.1
18+
# via mindee (setup.py)
19+
urllib3==1.26.8
20+
# via requests

setup.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import os
12
import re
23
from setuptools import find_packages, setup
3-
from mindee.versions import __version__
44

5+
dir_path = os.path.dirname(os.path.realpath(__file__))
6+
with open(os.path.join(dir_path, "mindee", "version"), "r") as version_file:
7+
__version__ = version_file.read().strip()
58

69
with open("README.md", "r", newline="", encoding="utf-8") as fh:
710
long_description = fh.read()
@@ -12,35 +15,46 @@
1215
GIT_URL = "https://github.com/publicMindee/mindee-api-python"
1316

1417

15-
def make_requirements_list(file="requirements.txt", only_regular=True):
16-
"""
17-
Make a list of package requirements from a requirements.txt file
18-
:param file: path to txt file
19-
:param only_regular: remove rows with /, #, space or empty
20-
:return:
21-
"""
22-
with open(file) as f:
23-
lines = f.read().splitlines()
24-
if only_regular:
25-
regex = (
26-
"\/$|^#|^$$|^git\+" # remove line with /, starting by # or space or empty
27-
)
28-
return [line for line in lines if not re.findall(regex, line)]
29-
else:
30-
return lines
18+
requirements = [
19+
"requests==2.25.1",
20+
"pytz==2021.3",
21+
"PyMuPDF==1.18.17",
22+
]
3123

24+
test_requirements = [
25+
"pytest==6.1.2",
26+
"pytest-cov==2.11.1",
27+
]
28+
29+
dev_requirements = [
30+
"black==21.12b0",
31+
"setuptools==49.2.0",
32+
"pip-tools==6.4.0",
33+
]
3234

3335
setup(
3436
python_requires=">=3.6",
35-
name=f"{PACKAGE_NAME}",
36-
description="Mindee API helper library for python",
37+
name=PACKAGE_NAME,
38+
description="Mindee API helper library for Python",
3739
version=__version__,
3840
long_description=long_description,
3941
long_description_content_type="text/markdown",
4042
url=GIT_URL,
4143
packages=find_packages(),
4244
author="Mindee",
4345
author_email="devrel@mindee.com",
44-
install_requires=make_requirements_list(),
46+
install_requires=requirements,
47+
extras_require={
48+
"dev": dev_requirements,
49+
"test": test_requirements,
50+
},
4551
include_package_data=True,
52+
package_data={"mindee": ["version"]},
53+
classifiers=[
54+
"Programming Language :: Python :: 3",
55+
"Operating System :: OS Independent",
56+
"Development Status :: 5 - Production/Stable",
57+
"Intended Audience :: Developers",
58+
"Topic :: Software Development :: Libraries",
59+
],
4660
)

0 commit comments

Comments
 (0)