Skip to content

Commit 68d0a83

Browse files
committed
chore: initialize and modernize NetLicensing Python client library
0 parents  commit 68d0a83

43 files changed

Lines changed: 4818 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Python Client - Publish to PyPI
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload dist/*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Python Client - Publish to TestPyPI
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload -r testpypi dist/*
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python Client - CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.6, 3.7, 3.8]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 pytest
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
- name: Test with pytest
38+
run: |
39+
pytest
40+
- name: Upload Codecov
41+
run: |
42+
bash <(curl -s https://codecov.io/bash)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Python Client - Dependency Test
2+
3+
on:
4+
schedule:
5+
- cron: '*/59 * * * *'
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: [3.6, 3.7, 3.8]
14+
15+
steps:
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install netlicensing-client

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ── Python ────────────────────────────────────────────────────────────────────
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*$py.class
6+
*.so
7+
8+
# ── Build & packaging ─────────────────────────────────────────────────────────
9+
build/
10+
dist/
11+
*.egg-info/
12+
*.egg
13+
14+
# ── Virtual environments ──────────────────────────────────────────────────────
15+
.env
16+
.venv/
17+
venv/
18+
19+
# ── Testing & coverage ────────────────────────────────────────────────────────
20+
.coverage
21+
.coverage.*
22+
coverage.xml
23+
htmlcov/
24+
.pytest_cache/
25+
.tox/
26+
.nox/
27+
28+
# ── Type checkers ─────────────────────────────────────────────────────────────
29+
.mypy_cache/
30+
.dmypy.json
31+
.pyre/
32+
33+
# ── IDE / editor ──────────────────────────────────────────────────────────────
34+
.idea/
35+
.vscode/
36+
37+
# ── OS artefacts ──────────────────────────────────────────────────────────────
38+
.DS_Store
39+
Thumbs.db

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Rebuilt the package around a `src/` layout and `pyproject.toml` packaging.
6+
- Added `httpx`-based `NetLicensingClient` with API-key and username/password authentication.
7+
- Added typed Pydantic models for core NetLicensing entities.
8+
- Added services for products, product modules, licensees, license templates, licenses, tokens, transactions, payment methods, bundles, notifications, utility data, and validation.
9+
- Added deterministic pytest coverage using `httpx.MockTransport`.
10+
- Added demo CLI for validation and shop-token flows.

CONTRIBUTING.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Contributing
2+
3+
## Add features or fix bugs
4+
5+
* Fork the repo
6+
* Check out a feature or bug branch
7+
* Add your changes
8+
* Update README when needed
9+
* Submit a pull request to upstream repo
10+
* Add description of your changes
11+
* Ensure tests are passing
12+
* Ensure branch is mergeable
13+
14+
## Setup
15+
16+
```bash
17+
pip install -e ".[dev]"
18+
```
19+
20+
## Test
21+
22+
Testing is set up using [pytest](http://pytest.org) and coverage is handled with the pytest-cov plugin.
23+
24+
Run your tests with:
25+
26+
```bash
27+
pytest
28+
```
29+
30+
Coverage is reported in the terminal after each run.
31+
To view a detailed HTML report open `htmlcov/index.html` after running the tests.
32+
33+
To run the optional live integration tests against the NetLicensing demo account:
34+
35+
```bash
36+
NETLICENSING_LIVE_DEMO=1 pytest tests/test_live_demo.py -q
37+
```
38+
39+
## Type checking
40+
41+
```bash
42+
mypy src/netlicensing
43+
```
44+
45+
## Release
46+
47+
Create a source distribution and wheel:
48+
49+
```bash
50+
python -m build
51+
```
52+
53+
Verify the distribution before uploading:
54+
55+
```bash
56+
twine check dist/*
57+
```
58+
59+
Upload to TestPyPI first, then PyPI:
60+
61+
```bash
62+
# Test PyPI
63+
twine upload -r testpypi dist/*
64+
# PyPI
65+
twine upload dist/*
66+
```

0 commit comments

Comments
 (0)