Skip to content

Commit

Permalink
Merge pull request #254 from emnify/development
Browse files Browse the repository at this point in the history
rc
  • Loading branch information
Th3Un1q3 authored Nov 7, 2024
2 parents adae6fb + 63c43fc commit dc30b3f
Show file tree
Hide file tree
Showing 19 changed files with 1,754 additions and 209 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ updates:
include: "scope"
schedule:
interval: "daily"
groups:
python:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
commit-message:
prefix: 'ci'
include: "scope"
schedule:
interval: "daily"
groups:
github-actions:
patterns:
- "*"
ignore:
- dependency-name: "zricethezav/gitleaks-action"
6 changes: 4 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
- uses: actions/checkout@v4

- name: Install dependencies
run: pip install -r req.txt
run: |
pip install pipenv
pipenv install --deploy --ignore-pipfile --dev
- name: Run tests
run: pytest --cov=. --cov-report=xml
run: pipenv run pytest --cov=. --cov-report=xml

- name: Export SonarCloud Result
# Skip dependabot runs because they don't have access to secrets
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ ipython_config.py
# intended to run in multiple environments; otherwise, check them in:
# .python-version

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


# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM python:latest

RUN pip install pipenv

WORKDIR /sdk

COPY req.txt req.txt
COPY req.dev.txt req.dev.txt
COPY Pipfile Pipfile.lock ./

RUN pip install -r req.txt
RUN pip install -r req.dev.txt
RUN pipenv install --deploy --ignore-pipfile --dev

COPY . .

CMD echo "Enter Command(Read DEVELOPMENT.md)"
ENTRYPOINT ["pipenv", "run"]

CMD ["echo", "\"Enter Command(Read DEVELOPMENT.md)\""]
28 changes: 9 additions & 19 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@ verify_ssl = true
name = "pypi"

[packages]
certifi = "==2023.7.22"
charset-normalizer = "==3.1.0"
distlib = "==0.3.6"
filelock = "==3.12.2"
idna = "==3.4"
importlib-metadata = "==6.7.0"
pipenv = "==2023.7.23"
platformdirs = "==3.5.1"
pydantic = "==1.10.9"
requests = "==2.31.0"
six = "==1.16.0"
typing-extensions = "==4.7.1"
urllib3 = "==2.0.4"
virtualenv = "==20.24.1"
virtualenv-clone = "==0.5.7"
zipp = "==3.15.0"
requests = ">=2.27.0,<2.30.0"
pydantic = ">=1.9.0,<2.0"

[dev-packages]

[requires]
python_version = "3.12"
vcrpy = "*"
build = "*"
twine = "*"
bump2version = "*"
pytest-cov = "*"
exceptiongroup = "*"
tomli = "*"
1,104 changes: 1,104 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ Automate your routines with this SDK for Python.

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

### Install from source
### Install from source (requires build)

```shell
git clone https://github.com/emnify/emnify-sdk-python.git
cd emnify-sdk-python
python setup.py install
python -m build --sdist --wheel
```

For local development install with pipenv:
```shell
git clone https://github.com/emnify/emnify-sdk-python.git
cd emnify-sdk-python
brew install pipenv # for macOS
python -m pip install pipenv # for other OS
pipenv sync
```

### Install with pip
Expand Down
8 changes: 5 additions & 3 deletions docs/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ FROM python:alpine

WORKDIR /docs

COPY docs/req.txt req.txt
RUN pip install pipenv

RUN pip install -r req.txt
COPY docs/Pipfile docs/Pipfile.lock ./

RUN pipenv install --deploy --ignore-pipfile

COPY . .

CMD sh ./docs/build.sh
CMD ["sh", "./docs/build.sh"]
10 changes: 10 additions & 0 deletions docs/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
jinja2 = "*"
sphinx = "*"
sphinx-autoapi = "*"
furo = "*"
459 changes: 459 additions & 0 deletions docs/Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sphinx-build -b html docs/sphinx docs/build_sphinx
pipenv run sphinx-build -b html docs/sphinx docs/build_sphinx
10 changes: 0 additions & 10 deletions docs/req.txt

This file was deleted.

3 changes: 3 additions & 0 deletions emnify/api_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def _build_headers(token=''):

emnify_constants.RequestDefaultHeadersKeys.XEmnOriginAppVersion.value:
emnify_constants.RequestDefaultHeadersValues.PYTHONSDK_VERSION.value,

emnify_constants.RequestDefaultHeadersKeys.USER_AGENT.value:
emnify_constants.RequestDefaultHeadersValues.USER_AGENT.value
}

def process_exception(self, response: requests.Response, client, data: dict = None, *args, **kwargs):
Expand Down
13 changes: 12 additions & 1 deletion emnify/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import platform
import requests
from enum import Enum
from emnify.version import EMNIFY_PACKAGE_VERSION

Expand Down Expand Up @@ -39,13 +41,22 @@ class RequestDefaultHeadersKeys(ExtendedEnum):
AUTHORIZATION = 'authorization'
XEmnOriginApp = 'x-emn-origin-app'
XEmnOriginAppVersion = 'x-emn-origin-app-version'
USER_AGENT = 'User-Agent'


class RequestDefaultHeadersValues(ExtendedEnum):
APPLICATION_JSON = 'application/json'
BEARER_TOKEN = 'Bearer {}'
PYTHONSDK_VERSION = EMNIFY_PACKAGE_VERSION
PYTHONSDK = 'PythonSDK'
PYTHONSDK = 'emnifyPythonSDK'

name_and_version = f"{PYTHONSDK}/{PYTHONSDK_VERSION}"
requests_user_agent = f" {requests.utils.default_user_agent()}"
python_version = f"Python {platform.python_version()}"
platform_info = f"{platform.system()}, {platform.release()}"
details = f" ({python_version}, {platform_info})"

USER_AGENT = f"{name_and_version}{requests_user_agent}{details}"


class DeviceStatuses(ExtendedEnum):
Expand Down
3 changes: 0 additions & 3 deletions req.dev.txt

This file was deleted.

44 changes: 0 additions & 44 deletions req.txt

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ['requests', 'pydantic>=1.9.0,<2.0.0']
REQUIRES = ['requests>=2.27.0,<2.30.0', 'pydantic>=1.9.0,<2.0.0']
if __name__ == '__main__':
with open('README.md', "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .test_emnify import *
from .test_emnify import *
Loading

0 comments on commit dc30b3f

Please sign in to comment.