Skip to content

Commit dc30b3f

Browse files
authored
Merge pull request #254 from emnify/development
rc
2 parents adae6fb + 63c43fc commit dc30b3f

19 files changed

+1754
-209
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ updates:
1010
include: "scope"
1111
schedule:
1212
interval: "daily"
13+
groups:
14+
python:
15+
patterns:
16+
- "*"
1317
- package-ecosystem: "github-actions"
1418
directory: "/"
1519
commit-message:
1620
prefix: 'ci'
1721
include: "scope"
1822
schedule:
1923
interval: "daily"
24+
groups:
25+
github-actions:
26+
patterns:
27+
- "*"
2028
ignore:
2129
- dependency-name: "zricethezav/gitleaks-action"

.github/workflows/unit-tests.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ jobs:
2121
- uses: actions/checkout@v4
2222

2323
- name: Install dependencies
24-
run: pip install -r req.txt
24+
run: |
25+
pip install pipenv
26+
pipenv install --deploy --ignore-pipfile --dev
2527
2628
- name: Run tests
27-
run: pytest --cov=. --cov-report=xml
29+
run: pipenv run pytest --cov=. --cov-report=xml
2830

2931
- name: Export SonarCloud Result
3032
# Skip dependabot runs because they don't have access to secrets

.gitignore

-7
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ ipython_config.py
8383
# intended to run in multiple environments; otherwise, check them in:
8484
# .python-version
8585

86-
# pipenv
87-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
89-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
90-
# install all needed dependencies.
91-
Pipfile.lock
92-
9386

9487
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
9588
__pypackages__/

Dockerfile.dev

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
FROM python:latest
22

3+
RUN pip install pipenv
4+
35
WORKDIR /sdk
46

5-
COPY req.txt req.txt
6-
COPY req.dev.txt req.dev.txt
7+
COPY Pipfile Pipfile.lock ./
78

8-
RUN pip install -r req.txt
9-
RUN pip install -r req.dev.txt
9+
RUN pipenv install --deploy --ignore-pipfile --dev
1010

1111
COPY . .
1212

13-
CMD echo "Enter Command(Read DEVELOPMENT.md)"
13+
ENTRYPOINT ["pipenv", "run"]
14+
15+
CMD ["echo", "\"Enter Command(Read DEVELOPMENT.md)\""]

Pipfile

+9-19
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,14 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
certifi = "==2023.7.22"
8-
charset-normalizer = "==3.1.0"
9-
distlib = "==0.3.6"
10-
filelock = "==3.12.2"
11-
idna = "==3.4"
12-
importlib-metadata = "==6.7.0"
13-
pipenv = "==2023.7.23"
14-
platformdirs = "==3.5.1"
15-
pydantic = "==1.10.9"
16-
requests = "==2.31.0"
17-
six = "==1.16.0"
18-
typing-extensions = "==4.7.1"
19-
urllib3 = "==2.0.4"
20-
virtualenv = "==20.24.1"
21-
virtualenv-clone = "==0.5.7"
22-
zipp = "==3.15.0"
7+
requests = ">=2.27.0,<2.30.0"
8+
pydantic = ">=1.9.0,<2.0"
239

2410
[dev-packages]
25-
26-
[requires]
27-
python_version = "3.12"
11+
vcrpy = "*"
12+
build = "*"
13+
twine = "*"
14+
bump2version = "*"
15+
pytest-cov = "*"
16+
exceptiongroup = "*"
17+
tomli = "*"

Pipfile.lock

+1,104
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,21 @@ Automate your routines with this SDK for Python.
1515

1616
- Python ([version 3.6.0](https://www.python.org/downloads/release/python-360/) or higher)
1717

18-
### Install from source
18+
### Install from source (requires build)
1919

2020
```shell
2121
git clone https://github.com/emnify/emnify-sdk-python.git
2222
cd emnify-sdk-python
23-
python setup.py install
23+
python -m build --sdist --wheel
24+
```
25+
26+
For local development install with pipenv:
27+
```shell
28+
git clone https://github.com/emnify/emnify-sdk-python.git
29+
cd emnify-sdk-python
30+
brew install pipenv # for macOS
31+
python -m pip install pipenv # for other OS
32+
pipenv sync
2433
```
2534

2635
### Install with pip

docs/Dockerfile.dev

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ FROM python:alpine
22

33
WORKDIR /docs
44

5-
COPY docs/req.txt req.txt
5+
RUN pip install pipenv
66

7-
RUN pip install -r req.txt
7+
COPY docs/Pipfile docs/Pipfile.lock ./
8+
9+
RUN pipenv install --deploy --ignore-pipfile
810

911
COPY . .
1012

11-
CMD sh ./docs/build.sh
13+
CMD ["sh", "./docs/build.sh"]

docs/Pipfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
jinja2 = "*"
8+
sphinx = "*"
9+
sphinx-autoapi = "*"
10+
furo = "*"

docs/Pipfile.lock

+459
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sphinx-build -b html docs/sphinx docs/build_sphinx
1+
pipenv run sphinx-build -b html docs/sphinx docs/build_sphinx

docs/req.txt

-10
This file was deleted.

emnify/api_manager.py

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def _build_headers(token=''):
4444

4545
emnify_constants.RequestDefaultHeadersKeys.XEmnOriginAppVersion.value:
4646
emnify_constants.RequestDefaultHeadersValues.PYTHONSDK_VERSION.value,
47+
48+
emnify_constants.RequestDefaultHeadersKeys.USER_AGENT.value:
49+
emnify_constants.RequestDefaultHeadersValues.USER_AGENT.value
4750
}
4851

4952
def process_exception(self, response: requests.Response, client, data: dict = None, *args, **kwargs):

emnify/constants.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import platform
2+
import requests
13
from enum import Enum
24
from emnify.version import EMNIFY_PACKAGE_VERSION
35

@@ -39,13 +41,22 @@ class RequestDefaultHeadersKeys(ExtendedEnum):
3941
AUTHORIZATION = 'authorization'
4042
XEmnOriginApp = 'x-emn-origin-app'
4143
XEmnOriginAppVersion = 'x-emn-origin-app-version'
44+
USER_AGENT = 'User-Agent'
4245

4346

4447
class RequestDefaultHeadersValues(ExtendedEnum):
4548
APPLICATION_JSON = 'application/json'
4649
BEARER_TOKEN = 'Bearer {}'
4750
PYTHONSDK_VERSION = EMNIFY_PACKAGE_VERSION
48-
PYTHONSDK = 'PythonSDK'
51+
PYTHONSDK = 'emnifyPythonSDK'
52+
53+
name_and_version = f"{PYTHONSDK}/{PYTHONSDK_VERSION}"
54+
requests_user_agent = f" {requests.utils.default_user_agent()}"
55+
python_version = f"Python {platform.python_version()}"
56+
platform_info = f"{platform.system()}, {platform.release()}"
57+
details = f" ({python_version}, {platform_info})"
58+
59+
USER_AGENT = f"{name_and_version}{requests_user_agent}{details}"
4960

5061

5162
class DeviceStatuses(ExtendedEnum):

req.dev.txt

-3
This file was deleted.

req.txt

-44
This file was deleted.

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# prerequisite: setuptools
1212
# http://pypi.python.org/pypi/setuptools
1313

14-
REQUIRES = ['requests', 'pydantic>=1.9.0,<2.0.0']
14+
REQUIRES = ['requests>=2.27.0,<2.30.0', 'pydantic>=1.9.0,<2.0.0']
1515
if __name__ == '__main__':
1616
with open('README.md', "r", encoding="utf-8") as fh:
1717
long_description = fh.read()

tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .test_emnify import *
1+
from .test_emnify import *

0 commit comments

Comments
 (0)