keygen-py 0.0.1.dev4__tar.gz → 0.0.1.dev5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ name: PR checks
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ types: [opened, synchronize, reopened]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build:
14
+ name: ${{ matrix.platform.runner }} ${{ matrix.platform.target }} ${{ matrix.platform.manylinux }}
15
+ runs-on: ${{ matrix.platform.runner }}
16
+ strategy:
17
+ fail-fast: true
18
+ matrix:
19
+ platform:
20
+ - runner: ubuntu-latest
21
+ target: x86_64
22
+ before: 'yum install --assumeyes perl-core'
23
+ manylinux: 'auto'
24
+ - runner: ubuntu-latest
25
+ target: x86_64
26
+ before: 'apt update && apt install -y libssl-dev'
27
+ manylinux: 'musllinux_1_2'
28
+ - runner: ubuntu-latest
29
+ target: x64
30
+ before: 'yum install --assumeyes perl-core'
31
+ manylinux: 'auto'
32
+ - runner: ubuntu-latest
33
+ target: x86
34
+ before: 'apt update && apt install -y libssl-dev'
35
+ manylinux: 'musllinux_1_2'
36
+ - runner: ubuntu-latest
37
+ target: aarch64
38
+ before: 'apt update && apt install -y libssl-dev'
39
+ - runner: ubuntu-latest
40
+ target: aarch64
41
+ before: 'apt update && apt install -y libssl-dev'
42
+ manylinux: 'auto'
43
+ - runner: ubuntu-latest
44
+ target: aarch64
45
+ before: 'apt update && apt install -y libssl-dev'
46
+ manylinux: 'musllinux_1_2'
47
+ - runner: ubuntu-latest
48
+ target: armv7
49
+ before: 'apt update && apt install -y libssl-dev'
50
+ manylinux: 'auto'
51
+ - runner: ubuntu-latest
52
+ target: armv7
53
+ before: 'apt update && apt install -y libssl-dev'
54
+ manylinux: 'musllinux_1_2'
55
+ - runner: windows-latest
56
+ target: x64
57
+ - runner: windows-latest
58
+ target: x86
59
+ - runner: macos-latest
60
+ target: x86_64
61
+ - runner: macos-latest
62
+ target: aarch64
63
+ steps:
64
+ - uses: actions/checkout@v4
65
+ - uses: actions/setup-python@v5
66
+ if: runner.os == 'Windows'
67
+ with:
68
+ python-version: 3.*
69
+ architecture: ${{ matrix.platform.target }}
70
+ - uses: actions/setup-python@v5
71
+ if: runner.os != 'Windows'
72
+ with:
73
+ python-version: 3.*
74
+ - name: Build wheels
75
+ uses: PyO3/maturin-action@v1
76
+ with:
77
+ target: ${{ matrix.platform.target }}
78
+ args: --release --out dist --find-interpreter
79
+ sccache: 'true'
80
+ manylinux: ${{ matrix.platform.manylinux }}
81
+ before-script-linux: ${{ matrix.platform.before }}
82
+
83
+ sdist:
84
+ runs-on: ubuntu-latest
85
+ steps:
86
+ - uses: actions/checkout@v4
87
+ - name: Build sdist
88
+ uses: PyO3/maturin-action@v1
89
+ with:
90
+ command: sdist
91
+ args: --out dist
@@ -9,7 +9,8 @@ permissions:
9
9
  contents: read
10
10
 
11
11
  jobs:
12
- linux:
12
+ build:
13
+ name: ${{ matrix.platform.runner }} ${{ matrix.platform.target }} ${{ matrix.platform.manylinux }}
13
14
  runs-on: ${{ matrix.platform.runner }}
14
15
  strategy:
15
16
  fail-fast: true
@@ -18,105 +19,42 @@ jobs:
18
19
  - runner: ubuntu-latest
19
20
  target: x86_64
20
21
  before: 'yum install --assumeyes perl-core'
22
+ manylinux: 'auto'
23
+ - runner: ubuntu-latest
24
+ target: x86_64
25
+ before: 'apt update && apt install -y libssl-dev'
26
+ manylinux: 'musllinux_1_2'
21
27
  - runner: ubuntu-latest
22
28
  target: x64
23
29
  before: 'yum install --assumeyes perl-core'
30
+ manylinux: 'auto'
24
31
  - runner: ubuntu-latest
25
- target: aarch64
32
+ target: x86
26
33
  before: 'apt update && apt install -y libssl-dev'
34
+ manylinux: 'musllinux_1_2'
27
35
  - runner: ubuntu-latest
28
- target: armv7
36
+ target: aarch64
29
37
  before: 'apt update && apt install -y libssl-dev'
30
- steps:
31
- - uses: actions/checkout@v4
32
- - uses: actions/setup-python@v5
33
- with:
34
- python-version: 3.*
35
- - name: Build wheels
36
- uses: PyO3/maturin-action@v1
37
- with:
38
- target: ${{ matrix.platform.target }}
39
- args: --release --out dist --find-interpreter
40
- sccache: 'true'
41
- manylinux: 'auto'
42
- before-script-linux: ${{ matrix.platform.before }}
43
- - name: Upload wheels
44
- uses: actions/upload-artifact@v4
45
- with:
46
- name: wheels-linux-${{ matrix.platform.target }}
47
- path: dist
48
-
49
- musllinux:
50
- runs-on: ${{ matrix.platform.runner }}
51
- strategy:
52
- fail-fast: true
53
- matrix:
54
- platform:
55
38
  - runner: ubuntu-latest
56
- target: x86_64
39
+ target: aarch64
57
40
  before: 'apt update && apt install -y libssl-dev'
41
+ manylinux: 'auto'
58
42
  - runner: ubuntu-latest
59
- target: x86
43
+ target: aarch64
60
44
  before: 'apt update && apt install -y libssl-dev'
45
+ manylinux: 'musllinux_1_2'
61
46
  - runner: ubuntu-latest
62
- target: aarch64
47
+ target: armv7
63
48
  before: 'apt update && apt install -y libssl-dev'
49
+ manylinux: 'auto'
64
50
  - runner: ubuntu-latest
65
51
  target: armv7
66
52
  before: 'apt update && apt install -y libssl-dev'
67
- steps:
68
- - uses: actions/checkout@v4
69
- - uses: actions/setup-python@v5
70
- with:
71
- python-version: 3.*
72
- - name: Build wheels
73
- uses: PyO3/maturin-action@v1
74
- with:
75
- target: ${{ matrix.platform.target }}
76
- args: --release --out dist --find-interpreter
77
- sccache: 'true'
78
- manylinux: musllinux_1_2
79
- before-script-linux: ${{ matrix.platform.before }}
80
- - name: Upload wheels
81
- uses: actions/upload-artifact@v4
82
- with:
83
- name: wheels-musllinux-${{ matrix.platform.target }}
84
- path: dist
85
-
86
- windows:
87
- runs-on: ${{ matrix.platform.runner }}
88
- strategy:
89
- fail-fast: true
90
- matrix:
91
- platform:
53
+ manylinux: 'musllinux_1_2'
92
54
  - runner: windows-latest
93
55
  target: x64
94
56
  - runner: windows-latest
95
57
  target: x86
96
- steps:
97
- - uses: actions/checkout@v4
98
- - uses: actions/setup-python@v5
99
- with:
100
- python-version: 3.*
101
- architecture: ${{ matrix.platform.target }}
102
- - name: Build wheels
103
- uses: PyO3/maturin-action@v1
104
- with:
105
- target: ${{ matrix.platform.target }}
106
- args: --release --out dist --find-interpreter
107
- sccache: 'true'
108
- - name: Upload wheels
109
- uses: actions/upload-artifact@v4
110
- with:
111
- name: wheels-windows-${{ matrix.platform.target }}
112
- path: dist
113
-
114
- macos:
115
- runs-on: ${{ matrix.platform.runner }}
116
- strategy:
117
- fail-fast: true
118
- matrix:
119
- platform:
120
58
  - runner: macos-latest
121
59
  target: x86_64
122
60
  - runner: macos-latest
@@ -124,6 +62,12 @@ jobs:
124
62
  steps:
125
63
  - uses: actions/checkout@v4
126
64
  - uses: actions/setup-python@v5
65
+ if: runner.os == 'Windows'
66
+ with:
67
+ python-version: 3.*
68
+ architecture: ${{ matrix.platform.target }}
69
+ - uses: actions/setup-python@v5
70
+ if: runner.os != 'Windows'
127
71
  with:
128
72
  python-version: 3.*
129
73
  - name: Build wheels
@@ -132,10 +76,12 @@ jobs:
132
76
  target: ${{ matrix.platform.target }}
133
77
  args: --release --out dist --find-interpreter
134
78
  sccache: 'true'
79
+ manylinux: ${{ matrix.platform.manylinux }}
80
+ before-script-linux: ${{ matrix.platform.before }}
135
81
  - name: Upload wheels
136
82
  uses: actions/upload-artifact@v4
137
83
  with:
138
- name: wheels-macos-${{ matrix.platform.target }}
84
+ name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.manylinux }}-${{ matrix.platform.target }}
139
85
  path: dist
140
86
 
141
87
  sdist:
@@ -156,14 +102,10 @@ jobs:
156
102
  release:
157
103
  name: Release
158
104
  runs-on: ubuntu-latest
159
- if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
160
- needs: [linux, musllinux, windows, macos, sdist]
105
+ needs: [build, sdist]
161
106
  permissions:
162
- # Use to sign the release artifacts
163
107
  id-token: write
164
- # Used to upload release artifacts
165
108
  contents: write
166
- # Used to generate artifact attestation
167
109
  attestations: write
168
110
  steps:
169
111
  - uses: actions/checkout@v4
@@ -208,4 +150,4 @@ jobs:
208
150
  uses: softprops/action-gh-release@v2
209
151
  with:
210
152
  body: ${{ steps.build_changelog.outputs.changelog }}
211
- tag_name: ${{ steps.pyproject_version.outputs.version }}
153
+ tag_name: ${{ steps.pyproject_version.outputs.version }}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: keygen-py
3
- Version: 0.0.1.dev4
3
+ Version: 0.0.1.dev5
4
4
  License-File: LICENSE
5
5
  Summary: Unofficial Keygen SDK for Python. Integrate license activation and offline licensing. Wrapper around keygen-rs rust crate
6
6
  Author-email: Terra Quantum AG <info@terraquantum.swiss>, Cedric Kring <ck@terraquantum.swiss>, Steven Beckers <sb@terraquantum.swiss>
@@ -0,0 +1,23 @@
1
+ import os
2
+
3
+ from keygen_sh import KeygenConfig, set_config, verify, SchemeCode
4
+
5
+ set_config(
6
+ KeygenConfig(
7
+ api_url="https://api.keygen.sh",
8
+ api_prefix="v1",
9
+ api_version="v1.7",
10
+ account=os.getenv("KEYGEN_ACCOUNT_ID"),
11
+ product=os.getenv("KEYGEN_PRODUCT_ID"),
12
+ license_key=os.getenv("KEYGEN_LICENSE_KEY"),
13
+ public_key=os.getenv("KEYGEN_PUBLIC_KEY"),
14
+ )
15
+ )
16
+
17
+ _LICENSE_KEY = os.getenv("OFFLINE_LICENSE_KEY")
18
+
19
+ try:
20
+ data = verify(SchemeCode.Ed25519Sign, signed_key=_LICENSE_KEY)
21
+ print(f"License is valid and contains the following data {data}")
22
+ except RuntimeError:
23
+ print("License could not be verified.")
@@ -0,0 +1,34 @@
1
+ import asyncio
2
+ import os
3
+ import uuid
4
+
5
+ from keygen_sh import set_config, validate, KeygenConfig
6
+
7
+ set_config(
8
+ KeygenConfig(
9
+ api_url="https://api.keygen.sh",
10
+ api_prefix="v1",
11
+ api_version="v1.7",
12
+ account=os.getenv("KEYGEN_ACCOUNT_ID"),
13
+ product=os.getenv("KEYGEN_PRODUCT_ID"),
14
+ license_key=os.getenv("KEYGEN_LICENSE_KEY"),
15
+ public_key=os.getenv("KEYGEN_PUBLIC_KEY"),
16
+ )
17
+ )
18
+
19
+
20
+ async def amain():
21
+ fingerprint = str(uuid.getnode())
22
+
23
+ try:
24
+ license = await validate(fingerprints=[fingerprint])
25
+ # or if the license is not bound to a specific machine identity
26
+ license = await validate()
27
+
28
+ print(f"License {license.id}:{license.name} is valid")
29
+ except RuntimeError:
30
+ print("License is not valid")
31
+
32
+
33
+ if __name__ == "__main__":
34
+ asyncio.run(amain())
@@ -32,18 +32,20 @@ class License:
32
32
  status: Optional[str]
33
33
  policy: Optional[str]
34
34
 
35
- def verify(scheme: SchemeCode, key: str) -> str:
35
+ def verify(scheme: SchemeCode, signed_key: str) -> str:
36
36
  """
37
37
  Verify an offline key.
38
38
 
39
39
  :param scheme: the scheme code
40
- :param key: the key to verify
40
+ :param signed_key: the key to verify
41
41
  :return: the data in the key
42
- :raises: ValueError if the key is invalid
42
+ :raises: RuntimeError if the key is invalid
43
43
  """
44
44
  ...
45
45
 
46
- async def validate(fingerprints: Optional[list[str]] = None, entitlements: Optional[list[str]] = None) -> License:
46
+ async def validate(
47
+ fingerprints: Optional[list[str]] = None, entitlements: Optional[list[str]] = None
48
+ ) -> License:
47
49
  """
48
50
  Validate a license.
49
51
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "keygen-py"
3
- version = "0.0.1.dev4"
3
+ version = "0.0.1.dev5"
4
4
  license = "MIT"
5
5
  description = "Unofficial Keygen SDK for Python. Integrate license activation and offline licensing. Wrapper around keygen-rs rust crate"
6
6
  requires-python = ">=3.9"
@@ -1,38 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- pull_request:
5
- branches: [ main ]
6
-
7
- jobs:
8
- build:
9
- runs-on: ${{ matrix.os }}
10
- strategy:
11
- matrix:
12
- os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
13
- python-version: [ '3.9', '3.10', '3.11', '3.12' ]
14
-
15
- steps:
16
- - uses: actions/checkout@v4
17
-
18
- - name: Set up Rust
19
- uses: actions-rust-lang/setup-rust-toolchain@v1
20
-
21
- - name: Set up Python ${{ matrix.python-version }}
22
- uses: actions/setup-python@v5
23
- with:
24
- python-version: ${{ matrix.python-version }}
25
-
26
- - name: Install and configure Poetry
27
- uses: snok/install-poetry@v1
28
- with:
29
- version: '1.8.3'
30
-
31
- - name: Install dependencies
32
- run: poetry install
33
- shell: bash
34
-
35
- - name: Build wheel for lib
36
- run: poetry run maturin build
37
- shell: bash
38
-
File without changes
File without changes