supso-project 1.0.0__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.
- supso_project-1.0.0/.github/workflows/ci.yml +42 -0
- supso_project-1.0.0/.github/workflows/release.yml +27 -0
- supso_project-1.0.0/.gitignore +35 -0
- supso_project-1.0.0/LICENSE-APACHE +201 -0
- supso_project-1.0.0/PKG-INFO +110 -0
- supso_project-1.0.0/README.md +87 -0
- supso_project-1.0.0/RELEASING.md +154 -0
- supso_project-1.0.0/pyproject.toml +41 -0
- supso_project-1.0.0/src/supso/__init__.py +363 -0
- supso_project-1.0.0/src/supso/certificate.py +152 -0
- supso_project-1.0.0/src/supso/errors.py +45 -0
- supso_project-1.0.0/src/supso/keys.py +69 -0
- supso_project-1.0.0/src/supso/license.py +128 -0
- supso_project-1.0.0/src/supso/verify.py +259 -0
- supso_project-1.0.0/tests/test_conformance.py +140 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
name: conformance (py ${{ matrix.python-version }})
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout supso-project-python (this repo)
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
path: supso-project-python
|
|
20
|
+
|
|
21
|
+
# The conformance vectors live in their own repo
|
|
22
|
+
# (SupsoOrg/supso-project-spec). Check it out as a sibling so
|
|
23
|
+
# `tests/test_conformance.py` can load it via SUPSO_VECTORS_DIR.
|
|
24
|
+
- name: Checkout conformance vectors
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
with:
|
|
27
|
+
repository: ${{ github.repository_owner }}/supso-project-spec
|
|
28
|
+
path: spec
|
|
29
|
+
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: ${{ matrix.python-version }}
|
|
33
|
+
|
|
34
|
+
- name: Install
|
|
35
|
+
working-directory: supso-project-python
|
|
36
|
+
run: python -m pip install -e ".[dev]"
|
|
37
|
+
|
|
38
|
+
- name: Test (incl. conformance vectors)
|
|
39
|
+
working-directory: supso-project-python
|
|
40
|
+
env:
|
|
41
|
+
SUPSO_VECTORS_DIR: ${{ github.workspace }}/spec
|
|
42
|
+
run: pytest -q
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI when you publish a GitHub Release. Uses PyPI Trusted
|
|
4
|
+
# Publishing (OIDC) — no API token is stored anywhere. See RELEASING.md for the
|
|
5
|
+
# one-time trusted-publisher setup on PyPI.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment: pypi
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # required for trusted publishing (OIDC)
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
|
|
23
|
+
- name: Build wheel + sdist
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Publish to PyPI
|
|
27
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Byte-compiled / build artifacts
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.eggs/
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
.env
|
|
13
|
+
|
|
14
|
+
# Test / tooling caches
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.mypy_cache/
|
|
17
|
+
.ruff_cache/
|
|
18
|
+
.coverage
|
|
19
|
+
htmlcov/
|
|
20
|
+
|
|
21
|
+
# Editor / tooling
|
|
22
|
+
.idea
|
|
23
|
+
.vscode
|
|
24
|
+
.claude
|
|
25
|
+
.gstack
|
|
26
|
+
|
|
27
|
+
# macOS
|
|
28
|
+
.DS_Store
|
|
29
|
+
|
|
30
|
+
# Local scratch / notes
|
|
31
|
+
/thoughts
|
|
32
|
+
thoughts/
|
|
33
|
+
|
|
34
|
+
# License certificates written during local testing
|
|
35
|
+
/.supso/
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work, excluding
|
|
103
|
+
those notices that do not pertain to any part of the Derivative
|
|
104
|
+
Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Supso
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: supso-project
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Offline hybrid (Ed25519 + ML-DSA-44) software-license verification for project maintainers — Supported Source.
|
|
5
|
+
Project-URL: Homepage, https://supso.org
|
|
6
|
+
Project-URL: Repository, https://github.com/SupsoOrg/supso-project-python
|
|
7
|
+
Author: Supso
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE-APACHE
|
|
10
|
+
Keywords: ed25519,license,licensing,ml-dsa,supported-source,verification
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Security :: Cryptography
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: cryptography>=42
|
|
19
|
+
Requires-Dist: dilithium-py>=1.1
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# supso (Python)
|
|
25
|
+
|
|
26
|
+
Supported Source license checks for your project, from [Supported Source](https://supso.org).
|
|
27
|
+
|
|
28
|
+
Use this library to enforce licensing, so you'll know who is using your project, and can
|
|
29
|
+
be sure they're paying for your paid licenses. It's just one call at startup to confirm
|
|
30
|
+
the code running your software holds a valid license. The check is 100% offline, so there's
|
|
31
|
+
no network, no license server to run, nothing phoning home.
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import supso
|
|
35
|
+
|
|
36
|
+
license = supso.require_license("acme-db") # raises if unlicensed
|
|
37
|
+
print(f"licensed to {license.organization.name}, {license.seats()} seats")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pip install supso-project
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The package imports as `supso`:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import supso
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### Hard enforcement (raises when missing license)
|
|
55
|
+
|
|
56
|
+
This is what we suggest you do.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import supso
|
|
60
|
+
supso.require_license("acme-db")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Soft enforcement (does not raise errors)
|
|
64
|
+
|
|
65
|
+
If you would like to handle it yourself, use `is_licensed` and then write your own logic.
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import supso
|
|
69
|
+
|
|
70
|
+
status = supso.check_license("acme-db") # logs a notice on grace/failure
|
|
71
|
+
if supso.is_licensed(status):
|
|
72
|
+
... # valid or within grace — run normally
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`status` is one of `supso.Valid`, `supso.Grace`, or `supso.Unlicensed`
|
|
76
|
+
(distinguish via `status.kind` or `isinstance`).
|
|
77
|
+
|
|
78
|
+
## Where licenses are found
|
|
79
|
+
|
|
80
|
+
When you don't pass a token, the library looks for a `*.cert` file (each holding
|
|
81
|
+
one license) in this order:
|
|
82
|
+
|
|
83
|
+
1. an explicit path — the `certificate_path(...)` option or the
|
|
84
|
+
`SUPSO_LICENSE_PATH` environment variable (authoritative; no fallback);
|
|
85
|
+
2. `~/.supso/license_certificates/`;
|
|
86
|
+
3. `./.supso/license_certificates/`.
|
|
87
|
+
|
|
88
|
+
A current license always wins. If none is current but one lapsed recently, it is
|
|
89
|
+
honored as `Grace` (default window 21 days) so your app keeps running while you
|
|
90
|
+
prompt the user to renew.
|
|
91
|
+
|
|
92
|
+
## Errors
|
|
93
|
+
|
|
94
|
+
Every failure is a `supso.SupsoError` carrying a stable `code` so you can branch
|
|
95
|
+
on the reason: `malformed`, `base64`, `bad_ed25519_signature`,
|
|
96
|
+
`bad_mldsa_signature`, `invalid_json`, `unsupported_schema`, `bad_timestamp`,
|
|
97
|
+
`expired`, `wrong_project`, `requirement_not_met`, `no_certificate`,
|
|
98
|
+
`none_valid`, `bad_trusted_key`.
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
uv venv && source .venv/bin/activate
|
|
104
|
+
uv pip install -e ".[dev]"
|
|
105
|
+
pytest
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
Apache-2.0. See [`LICENSE-APACHE`](./LICENSE-APACHE).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# supso (Python)
|
|
2
|
+
|
|
3
|
+
Supported Source license checks for your project, from [Supported Source](https://supso.org).
|
|
4
|
+
|
|
5
|
+
Use this library to enforce licensing, so you'll know who is using your project, and can
|
|
6
|
+
be sure they're paying for your paid licenses. It's just one call at startup to confirm
|
|
7
|
+
the code running your software holds a valid license. The check is 100% offline, so there's
|
|
8
|
+
no network, no license server to run, nothing phoning home.
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
import supso
|
|
12
|
+
|
|
13
|
+
license = supso.require_license("acme-db") # raises if unlicensed
|
|
14
|
+
print(f"licensed to {license.organization.name}, {license.seats()} seats")
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pip install supso-project
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The package imports as `supso`:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import supso
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Hard enforcement (raises when missing license)
|
|
32
|
+
|
|
33
|
+
This is what we suggest you do.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import supso
|
|
37
|
+
supso.require_license("acme-db")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Soft enforcement (does not raise errors)
|
|
41
|
+
|
|
42
|
+
If you would like to handle it yourself, use `is_licensed` and then write your own logic.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import supso
|
|
46
|
+
|
|
47
|
+
status = supso.check_license("acme-db") # logs a notice on grace/failure
|
|
48
|
+
if supso.is_licensed(status):
|
|
49
|
+
... # valid or within grace — run normally
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`status` is one of `supso.Valid`, `supso.Grace`, or `supso.Unlicensed`
|
|
53
|
+
(distinguish via `status.kind` or `isinstance`).
|
|
54
|
+
|
|
55
|
+
## Where licenses are found
|
|
56
|
+
|
|
57
|
+
When you don't pass a token, the library looks for a `*.cert` file (each holding
|
|
58
|
+
one license) in this order:
|
|
59
|
+
|
|
60
|
+
1. an explicit path — the `certificate_path(...)` option or the
|
|
61
|
+
`SUPSO_LICENSE_PATH` environment variable (authoritative; no fallback);
|
|
62
|
+
2. `~/.supso/license_certificates/`;
|
|
63
|
+
3. `./.supso/license_certificates/`.
|
|
64
|
+
|
|
65
|
+
A current license always wins. If none is current but one lapsed recently, it is
|
|
66
|
+
honored as `Grace` (default window 21 days) so your app keeps running while you
|
|
67
|
+
prompt the user to renew.
|
|
68
|
+
|
|
69
|
+
## Errors
|
|
70
|
+
|
|
71
|
+
Every failure is a `supso.SupsoError` carrying a stable `code` so you can branch
|
|
72
|
+
on the reason: `malformed`, `base64`, `bad_ed25519_signature`,
|
|
73
|
+
`bad_mldsa_signature`, `invalid_json`, `unsupported_schema`, `bad_timestamp`,
|
|
74
|
+
`expired`, `wrong_project`, `requirement_not_met`, `no_certificate`,
|
|
75
|
+
`none_valid`, `bad_trusted_key`.
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
uv venv && source .venv/bin/activate
|
|
81
|
+
uv pip install -e ".[dev]"
|
|
82
|
+
pytest
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
Apache-2.0. See [`LICENSE-APACHE`](./LICENSE-APACHE).
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Releasing `supso-project`
|
|
2
|
+
|
|
3
|
+
This library is published to [PyPI](https://pypi.org/project/supso-project/) so
|
|
4
|
+
maintainers can `pip install supso-project`. Three names are in play:
|
|
5
|
+
|
|
6
|
+
| Thing | Value |
|
|
7
|
+
|---|---|
|
|
8
|
+
| GitHub repo | `SupsoOrg/supso-project-python` |
|
|
9
|
+
| PyPI distribution | `supso-project` (what people `pip install`) |
|
|
10
|
+
| Import package | `supso` (what they `import`) |
|
|
11
|
+
|
|
12
|
+
There are two ways to publish: an **automated** GitHub Actions flow (recommended
|
|
13
|
+
— no credentials stored anywhere) and a **manual** flow from your laptop. Set up
|
|
14
|
+
the automated one once; fall back to manual if you ever need to.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## One-time setup (automated, recommended)
|
|
19
|
+
|
|
20
|
+
PyPI [Trusted Publishing](https://docs.pypi.org/trusted-publishers/) lets GitHub
|
|
21
|
+
Actions upload releases over OIDC, so there is no API token to create, store, or
|
|
22
|
+
leak.
|
|
23
|
+
|
|
24
|
+
1. **Create the PyPI project as a "pending" trusted publisher.** Go to
|
|
25
|
+
<https://pypi.org/manage/account/publishing/> and add a publisher with:
|
|
26
|
+
- PyPI Project Name: `supso-project`
|
|
27
|
+
- Owner: `SupsoOrg`
|
|
28
|
+
- Repository name: `supso-project-python`
|
|
29
|
+
- Workflow name: `release.yml`
|
|
30
|
+
- Environment name: `pypi`
|
|
31
|
+
|
|
32
|
+
(This works *before* the project exists on PyPI — the first successful
|
|
33
|
+
upload creates it and claims the name.)
|
|
34
|
+
|
|
35
|
+
2. **Add the release workflow** at `.github/workflows/release.yml` (see
|
|
36
|
+
[Appendix](#appendix-releaseyml) below). Commit and push it.
|
|
37
|
+
|
|
38
|
+
That's it. From then on, releasing is just a git tag (next section).
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Cutting a release
|
|
43
|
+
|
|
44
|
+
1. **Make sure the suite is green** (against the shared spec vectors):
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pytest
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
2. **Bump the version** in `pyproject.toml`. Use
|
|
51
|
+
[semantic versioning](https://semver.org/): patch for fixes, minor for
|
|
52
|
+
backward-compatible additions, major for breaking API changes. PyPI will
|
|
53
|
+
**reject a re-upload of an existing version**, so every release needs a new
|
|
54
|
+
number.
|
|
55
|
+
|
|
56
|
+
```toml
|
|
57
|
+
# pyproject.toml
|
|
58
|
+
version = "1.0.1"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
3. **Commit and tag.** The tag must be `v` + the version.
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
git commit -am "Release v1.0.1"
|
|
65
|
+
git tag v1.0.1
|
|
66
|
+
git push origin main --tags
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
4. **Publish.**
|
|
70
|
+
- **Automated:** create a GitHub Release for the tag
|
|
71
|
+
(`gh release create v1.0.1 --generate-notes`). The workflow builds and
|
|
72
|
+
uploads to PyPI automatically.
|
|
73
|
+
- **Manual:** see [Manual publishing](#manual-publishing) below.
|
|
74
|
+
|
|
75
|
+
5. **Verify** the upload installs cleanly from PyPI:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
python -m venv /tmp/verify && /tmp/verify/bin/pip install "supso-project==1.0.1"
|
|
79
|
+
/tmp/verify/bin/python -c "import supso; print('ok')"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Manual publishing
|
|
85
|
+
|
|
86
|
+
Use this for the very first upload if you skipped the trusted-publisher setup,
|
|
87
|
+
or any time you need to publish from your machine.
|
|
88
|
+
|
|
89
|
+
1. **Create a PyPI API token** at <https://pypi.org/manage/account/token/>
|
|
90
|
+
(scope it to the `supso-project` project once it exists; use an
|
|
91
|
+
account-wide token for the first upload).
|
|
92
|
+
|
|
93
|
+
2. **Build** a fresh wheel + sdist:
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
rm -rf dist
|
|
97
|
+
uv build
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
3. **Check** the artifacts before uploading:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
uvx twine check dist/*
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
4. **(Optional) dry-run on TestPyPI** to rehearse without touching real PyPI:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
uv publish --publish-url https://test.pypi.org/legacy/ --token <test-pypi-token>
|
|
110
|
+
# then: pip install --index-url https://test.pypi.org/simple/ supso-project
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
5. **Publish to PyPI:**
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
uv publish --token <pypi-token>
|
|
117
|
+
# or set UV_PUBLISH_TOKEN in the environment and run `uv publish`
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
6. **Tag** the release if you haven't already (step 3 of *Cutting a release*).
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Appendix: `release.yml`
|
|
125
|
+
|
|
126
|
+
Drop this at `.github/workflows/release.yml`. It builds on every published
|
|
127
|
+
GitHub Release and uploads to PyPI via the trusted publisher configured above —
|
|
128
|
+
no secrets required.
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
name: Release
|
|
132
|
+
|
|
133
|
+
on:
|
|
134
|
+
release:
|
|
135
|
+
types: [published]
|
|
136
|
+
|
|
137
|
+
jobs:
|
|
138
|
+
publish:
|
|
139
|
+
runs-on: ubuntu-latest
|
|
140
|
+
environment: pypi
|
|
141
|
+
permissions:
|
|
142
|
+
id-token: write # required for trusted publishing (OIDC)
|
|
143
|
+
steps:
|
|
144
|
+
- uses: actions/checkout@v4
|
|
145
|
+
|
|
146
|
+
- name: Install uv
|
|
147
|
+
uses: astral-sh/setup-uv@v5
|
|
148
|
+
|
|
149
|
+
- name: Build
|
|
150
|
+
run: uv build
|
|
151
|
+
|
|
152
|
+
- name: Publish to PyPI
|
|
153
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
154
|
+
```
|