compatibility 2.0.0__tar.gz → 2.2.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.
@@ -1,31 +1,36 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compatibility
3
- Version: 2.0.0
3
+ Version: 2.2.0
4
4
  Summary: A library that checks whether the running version of Python is compatible and tested. Remind the user to check for updates of the library.
5
- License: Apache-2.0
5
+ License-Expression: Apache-2.0
6
6
  License-File: LICENSE
7
- Keywords: compatibility,version-check,python-version,testing
7
+ Keywords: compatibility,version-check,python-version,cross-platform,update-notifier
8
8
  Author: Rüdiger Voigt
9
9
  Author-email: projects@ruediger-voigt.eu
10
- Requires-Python: >=3.10,<4.0
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Environment :: Console
13
- Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: Apache Software License
15
- Classifier: Operating System :: MacOS :: MacOS X
16
- Classifier: Operating System :: Microsoft :: Windows
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Operating System :: POSIX :: Linux
10
+ Requires-Python: >=3.10
19
11
  Classifier: Programming Language :: Python :: 3
20
12
  Classifier: Programming Language :: Python :: 3.10
21
13
  Classifier: Programming Language :: Python :: 3.11
22
14
  Classifier: Programming Language :: Python :: 3.12
23
15
  Classifier: Programming Language :: Python :: 3.13
24
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Operating System :: Microsoft :: Windows
20
+ Classifier: Operating System :: MacOS :: MacOS X
21
+ Classifier: Development Status :: 5 - Production/Stable
22
+ Classifier: Environment :: Console
23
+ Classifier: Intended Audience :: Developers
25
24
  Classifier: Topic :: Software Development
26
25
  Classifier: Topic :: Software Development :: Quality Assurance
27
26
  Classifier: Topic :: Utilities
28
27
  Classifier: Typing :: Typed
28
+ Provides-Extra: dev
29
+ Requires-Dist: coverage[toml] (>=7.14.1,<8) ; extra == "dev"
30
+ Requires-Dist: mypy (>=2.1.0,<3) ; extra == "dev"
31
+ Requires-Dist: pytest (>=9.0.3,<10) ; extra == "dev"
32
+ Requires-Dist: pytest-cov (>=7.1.0,<8) ; extra == "dev"
33
+ Requires-Dist: ruff (>=0.15.16,<0.16) ; extra == "dev"
29
34
  Project-URL: Bug Tracker, https://github.com/RuedigerVoigt/compatibility/issues
30
35
  Project-URL: Changelog, https://github.com/RuedigerVoigt/compatibility/blob/main/CHANGELOG.md
31
36
  Project-URL: Documentation, https://github.com/RuedigerVoigt/compatibility
@@ -36,7 +41,7 @@ Description-Content-Type: text/markdown
36
41
  ![Supported Python Versions](https://img.shields.io/pypi/pyversions/compatibility)
37
42
  ![pypi version](https://img.shields.io/pypi/v/compatibility)
38
43
  ![Last commit](https://img.shields.io/github/last-commit/RuedigerVoigt/compatibility)
39
- [![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen)](https://www.ruediger-voigt.eu/coverage/compatibility/index.html)
44
+ [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://www.ruediger-voigt.eu/coverage/compatibility/index.html)
40
45
  [![Downloads](https://pepy.tech/badge/compatibility/month)](https://pepy.tech/project/compatibility)
41
46
 
42
47
  # Python Compatibility Checker for Package Authors
@@ -49,14 +54,14 @@ Compatibility is a lightweight, zero-dependency library that helps Python packag
49
54
 
50
55
  ## Why Use This Library?
51
56
 
52
- **Prevent cryptic runtime errors** - Catch incompatible Python versions before they cause problems
53
- **Zero dependencies** - Uses only Python's standard library
54
- **Fully typed** - Complete type hints (PEP 484) for better IDE support
55
- **Multilingual** - Built-in English and German messages
56
- **User-friendly warnings** - Inform users about untested Python versions
57
- **OS compatibility checks** - Validate Linux, macOS, and Windows support
58
- **Update reminders** - Gently encourage users to check for package updates
59
- **High test coverage** - 99%+ coverage for reliability
57
+ - **Prevent cryptic runtime errors** - Catch incompatible Python versions before they cause problems
58
+ - **Zero dependencies** - Uses only Python's standard library
59
+ - **Fully typed** - Complete type hints (PEP 484) for better IDE support
60
+ - **Multilingual** - Built-in English and German messages, plus AI-translated French, Dutch, and Spanish
61
+ - **User-friendly warnings** - Inform users about untested Python versions
62
+ - **OS compatibility checks** - Validate Linux, macOS, and Windows support
63
+ - **Update reminders** - Gently encourage users to check for package updates
64
+ - **High test coverage** - 100% coverage (statements and branches) for reliability
60
65
 
61
66
  ## Table of Contents
62
67
 
@@ -84,14 +89,14 @@ Compatibility is a lightweight, zero-dependency library that helps Python packag
84
89
  4. **Privacy-Friendly Update Reminders** - Optionally remind users to check for updates after N days (without phoning home or checking if updates exist).
85
90
  5. **Operating System Compatibility** - Validate whether the OS (Linux, macOS, Windows) is fully supported, partially supported, or incompatible.
86
91
 
87
- All messages are available in English and German, selectable per-instance.
92
+ All messages are available in English and German (plus AI-translated French, Dutch, and Spanish), selectable per-instance. See [Translations](#translations).
88
93
 
89
94
  ## Key Features
90
95
 
91
96
  - **Zero Dependencies**: Pure Python stdlib - no external packages required
92
97
  - **Type Safe**: Full type hints ([PEP 484](https://www.python.org/dev/peps/pep-0484/)) for excellent IDE integration
93
- - **Well Tested**: 97% minimum coverage enforced; typically 98-99%
94
- - **Python 3.10+**: Supports Python 3.10 through 3.14
98
+ - **Well Tested**: 100% coverage (statements and branches), enforced in CI
99
+ - **Python 3.10+**: Supports Python 3.10 through 3.14. Python 3.15 is already tested against its betas and will be officially supported once it is released.
95
100
 
96
101
  ## Installation
97
102
 
@@ -160,7 +165,7 @@ class MyAdvancedPackage:
160
165
  'nag_days_after_release': 90, # Start reminding after 90 days
161
166
  'nag_in_hundred': 25 # Show reminder 25% of the time
162
167
  },
163
- language_messages='en', # or 'de' for German
168
+ language_messages='en', # 'en', 'de', 'fr', 'nl', 'es', or 'auto'
164
169
  system_support={
165
170
  'full': {'Linux', 'MacOS'}, # Fully tested
166
171
  'partial': {'Windows'}, # Should work, less tested
@@ -242,16 +247,20 @@ Salted in that specific version is a relatively young package that will receive
242
247
 
243
248
  * `python_version_support`: requires a dictionary with the three following keys:
244
249
  * `min_version`: a string with the number of the oldest supported version (like `'3.10'`).
245
- * `incompatible_versions`: a list of incompatible versions that will raise the `RuntimeError` exception if they try to run your package.
250
+ * `incompatible_versions`: a list of incompatible versions that, by default, raise the `RuntimeError` exception if they try to run your package (configurable with `on_incompatible`).
246
251
  * `max_tested_version`: the latest version of the interpreter you successfully tested your code with.
247
252
  * `nag_over_update` (optional): requires a dictionary with the two following keys:
248
253
  * `nag_days_after_release`: wait this number of days (`int`) since the release before reminding users to check for an update.
249
254
  * `nag_in_hundred`: Whether to nag over a possible update is random, but this sets the probability in the form how many times (int) out of a hundred starts the message is logged. Accordingly 100 means every time.
250
- * `language_messages` (optional): the language (`en` for English or `de` for German) of the messages logged by this. Defaults to English log messages.
255
+ * `language_messages` (optional): the language of the messages logged by this — `en` (English), `de` (German), `fr` (French), `nl` (Dutch), `es` (Spanish), or `auto`. Defaults to `en`. Any explicit code selects that language; `auto` detects the language from the user's environment locale (`LANGUAGE`/`LC_ALL`/`LC_MESSAGES`/`LANG`) and falls back to English when no matching catalog is available. See [Translations](#translations) for the quality status of each language.
251
256
  * `system_support` (optional): allows you to state the level of compatibility between your code and different Operating System groups. This is purposefully done on a very high level: valid inputs are only 'Linux', 'MacOS', and 'Windows' and not specific versions and distributions. The dictionary allows three keys with a set as value each:
252
257
  * `full`: The set of operating systems that are tested on production level.
253
258
  * `partial`: The set of systems that should work, but are not as rigorously tested as those with full support. A system found running here logs a warning.
254
- * `incompatible`: The set of systems of which you know they will fail to run the code properly. If an OS in this set tries to run the code, this will yield a `RuntimeError` exception.
259
+ * `incompatible`: The set of systems of which you know they will fail to run the code properly. By default, if an OS in this set tries to run the code, this will yield a `RuntimeError` exception (configurable with `on_incompatible`).
260
+ * `on_incompatible` (optional): what to do when the running Python version or operating system is incompatible. One of:
261
+ * `'raise'` (default): raise a `RuntimeError` — the current behaviour.
262
+ * `'warn'`: log a warning and continue.
263
+ * `'ignore'`: continue silently (logged at DEBUG only). You take responsibility for running in an unsupported environment.
255
264
 
256
265
  **System Support Behavior:**
257
266
 
@@ -262,6 +271,8 @@ Salted in that specific version is a relatively young package that will receive
262
271
  | `incompatible` | ERROR | Yes (`RuntimeError`) | Known to fail |
263
272
  | Not listed | INFO | No | Support status unknown |
264
273
 
274
+ The `incompatible` row reflects the default `on_incompatible='raise'`. With `'warn'` it logs a warning and continues; with `'ignore'` it continues silently.
275
+
265
276
  ## Version strings
266
277
 
267
278
  For compatibility checks three elements of the version string are recognized:
@@ -320,6 +331,47 @@ The compatibility package logs at different levels:
320
331
  * **WARNING**: Running newer Python than tested, or partial platform support
321
332
  * **ERROR**: Incompatible Python version or operating system (also raises exceptions)
322
333
 
334
+ ### Example Messages
335
+
336
+ With logging configured, the messages look like the following (the level/name
337
+ prefix comes from your logging setup; here it is Python's `basicConfig` default):
338
+
339
+ ```text
340
+ DEBUG:compatibility:my_package fully supports Linux.
341
+ INFO:compatibility:You are using my_package 1.0.0 (released: 2025-01-01)
342
+ INFO:compatibility:Your version of my_package was released 120 days ago. Please check for updates.
343
+ WARNING:compatibility:my_package has only partial support on Windows.
344
+ WARNING:compatibility:You are running Python 3.15.final, but your version of my_package is only tested up to 3.14. Please check for updates.
345
+ ERROR:compatibility:This version of my_package is incompatible with Windows!
346
+ ```
347
+
348
+ An incompatible Python version (below `min_version`, or listed in
349
+ `incompatible_versions`) is logged the same way and, with the default
350
+ `on_incompatible='raise'`, additionally raises `RuntimeError`:
351
+
352
+ ```text
353
+ ERROR:compatibility:You use Python 3.9.final, but need at least Python 3.10 to run my_package.
354
+ ```
355
+
356
+ The same messages appear translated when you select another language (for
357
+ example `language_messages='de'`).
358
+
359
+ ## Translations
360
+
361
+ Each available language has one of the following quality levels:
362
+
363
+ | Language | Code | Status |
364
+ |----------|------|--------|
365
+ | English | `en` | Default / source language |
366
+ | German | `de` | Reviewed by a native speaker |
367
+ | French | `fr` | Translated by AI (pending native review) |
368
+ | Dutch | `nl` | Translated by AI (pending native review) |
369
+ | Spanish | `es` | Translated by AI (pending native review) |
370
+
371
+ The AI-translated languages are marked as such in the message catalog (`.po`) header until a native speaker has reviewed them. Corrections and reviews from native speakers are very welcome.
372
+
373
+ Set `language_messages='auto'` to follow the user's environment locale (`LANGUAGE`/`LC_ALL`/`LC_MESSAGES`/`LANG`); if no matching catalog is available, messages fall back to English.
374
+
323
375
  ## Exceptions
324
376
 
325
377
  The `compatibility` package may raise the following exceptions:
@@ -327,6 +379,7 @@ The `compatibility` package may raise the following exceptions:
327
379
  * `RuntimeError`: Raised when the Python version or operating system is incompatible with your package.
328
380
  * `ValueError`: Raised when invalid parameters are provided to the `Check` class.
329
381
  * `compatibility.err.BadDate`: Raised when the `release_date` parameter contains an invalid or malformed date.
382
+ * `compatibility.err.BadDateType`: Raised when the `release_date` parameter is neither a `datetime.date` nor a string. Subclasses `TypeError`.
330
383
  * `compatibility.err.ParameterContradiction`: Raised when conflicting parameters are provided (e.g., a system marked as both fully supported and incompatible).
331
384
 
332
385
  ## Use Cases
@@ -341,7 +394,7 @@ Use `incompatible_versions` to block specific Python versions where your package
341
394
  Use `max_tested_version` to warn users when they're running your package on newer Python versions you haven't tested yet. This helps manage expectations and reduces false bug reports.
342
395
 
343
396
  ### When You Drop Support for Old Python Versions
344
- After dropping Python 3.9 support, use this library to give users a clear error message instead of cryptic import errors or runtime failures.
397
+ After dropping (for example) Python 3.9 support, use this library to give users a clear error message instead of cryptic import errors or runtime failures.
345
398
 
346
399
  ### When Your Package Only Works on Certain Operating Systems
347
400
  Use `system_support` to declare which operating systems (Linux, macOS, Windows) are fully supported, partially supported, or incompatible. For example, if your package uses Linux-specific system calls.
@@ -1,7 +1,7 @@
1
1
  ![Supported Python Versions](https://img.shields.io/pypi/pyversions/compatibility)
2
2
  ![pypi version](https://img.shields.io/pypi/v/compatibility)
3
3
  ![Last commit](https://img.shields.io/github/last-commit/RuedigerVoigt/compatibility)
4
- [![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen)](https://www.ruediger-voigt.eu/coverage/compatibility/index.html)
4
+ [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://www.ruediger-voigt.eu/coverage/compatibility/index.html)
5
5
  [![Downloads](https://pepy.tech/badge/compatibility/month)](https://pepy.tech/project/compatibility)
6
6
 
7
7
  # Python Compatibility Checker for Package Authors
@@ -14,14 +14,14 @@ Compatibility is a lightweight, zero-dependency library that helps Python packag
14
14
 
15
15
  ## Why Use This Library?
16
16
 
17
- **Prevent cryptic runtime errors** - Catch incompatible Python versions before they cause problems
18
- **Zero dependencies** - Uses only Python's standard library
19
- **Fully typed** - Complete type hints (PEP 484) for better IDE support
20
- **Multilingual** - Built-in English and German messages
21
- **User-friendly warnings** - Inform users about untested Python versions
22
- **OS compatibility checks** - Validate Linux, macOS, and Windows support
23
- **Update reminders** - Gently encourage users to check for package updates
24
- **High test coverage** - 99%+ coverage for reliability
17
+ - **Prevent cryptic runtime errors** - Catch incompatible Python versions before they cause problems
18
+ - **Zero dependencies** - Uses only Python's standard library
19
+ - **Fully typed** - Complete type hints (PEP 484) for better IDE support
20
+ - **Multilingual** - Built-in English and German messages, plus AI-translated French, Dutch, and Spanish
21
+ - **User-friendly warnings** - Inform users about untested Python versions
22
+ - **OS compatibility checks** - Validate Linux, macOS, and Windows support
23
+ - **Update reminders** - Gently encourage users to check for package updates
24
+ - **High test coverage** - 100% coverage (statements and branches) for reliability
25
25
 
26
26
  ## Table of Contents
27
27
 
@@ -49,14 +49,14 @@ Compatibility is a lightweight, zero-dependency library that helps Python packag
49
49
  4. **Privacy-Friendly Update Reminders** - Optionally remind users to check for updates after N days (without phoning home or checking if updates exist).
50
50
  5. **Operating System Compatibility** - Validate whether the OS (Linux, macOS, Windows) is fully supported, partially supported, or incompatible.
51
51
 
52
- All messages are available in English and German, selectable per-instance.
52
+ All messages are available in English and German (plus AI-translated French, Dutch, and Spanish), selectable per-instance. See [Translations](#translations).
53
53
 
54
54
  ## Key Features
55
55
 
56
56
  - **Zero Dependencies**: Pure Python stdlib - no external packages required
57
57
  - **Type Safe**: Full type hints ([PEP 484](https://www.python.org/dev/peps/pep-0484/)) for excellent IDE integration
58
- - **Well Tested**: 97% minimum coverage enforced; typically 98-99%
59
- - **Python 3.10+**: Supports Python 3.10 through 3.14
58
+ - **Well Tested**: 100% coverage (statements and branches), enforced in CI
59
+ - **Python 3.10+**: Supports Python 3.10 through 3.14. Python 3.15 is already tested against its betas and will be officially supported once it is released.
60
60
 
61
61
  ## Installation
62
62
 
@@ -125,7 +125,7 @@ class MyAdvancedPackage:
125
125
  'nag_days_after_release': 90, # Start reminding after 90 days
126
126
  'nag_in_hundred': 25 # Show reminder 25% of the time
127
127
  },
128
- language_messages='en', # or 'de' for German
128
+ language_messages='en', # 'en', 'de', 'fr', 'nl', 'es', or 'auto'
129
129
  system_support={
130
130
  'full': {'Linux', 'MacOS'}, # Fully tested
131
131
  'partial': {'Windows'}, # Should work, less tested
@@ -207,16 +207,20 @@ Salted in that specific version is a relatively young package that will receive
207
207
 
208
208
  * `python_version_support`: requires a dictionary with the three following keys:
209
209
  * `min_version`: a string with the number of the oldest supported version (like `'3.10'`).
210
- * `incompatible_versions`: a list of incompatible versions that will raise the `RuntimeError` exception if they try to run your package.
210
+ * `incompatible_versions`: a list of incompatible versions that, by default, raise the `RuntimeError` exception if they try to run your package (configurable with `on_incompatible`).
211
211
  * `max_tested_version`: the latest version of the interpreter you successfully tested your code with.
212
212
  * `nag_over_update` (optional): requires a dictionary with the two following keys:
213
213
  * `nag_days_after_release`: wait this number of days (`int`) since the release before reminding users to check for an update.
214
214
  * `nag_in_hundred`: Whether to nag over a possible update is random, but this sets the probability in the form how many times (int) out of a hundred starts the message is logged. Accordingly 100 means every time.
215
- * `language_messages` (optional): the language (`en` for English or `de` for German) of the messages logged by this. Defaults to English log messages.
215
+ * `language_messages` (optional): the language of the messages logged by this — `en` (English), `de` (German), `fr` (French), `nl` (Dutch), `es` (Spanish), or `auto`. Defaults to `en`. Any explicit code selects that language; `auto` detects the language from the user's environment locale (`LANGUAGE`/`LC_ALL`/`LC_MESSAGES`/`LANG`) and falls back to English when no matching catalog is available. See [Translations](#translations) for the quality status of each language.
216
216
  * `system_support` (optional): allows you to state the level of compatibility between your code and different Operating System groups. This is purposefully done on a very high level: valid inputs are only 'Linux', 'MacOS', and 'Windows' and not specific versions and distributions. The dictionary allows three keys with a set as value each:
217
217
  * `full`: The set of operating systems that are tested on production level.
218
218
  * `partial`: The set of systems that should work, but are not as rigorously tested as those with full support. A system found running here logs a warning.
219
- * `incompatible`: The set of systems of which you know they will fail to run the code properly. If an OS in this set tries to run the code, this will yield a `RuntimeError` exception.
219
+ * `incompatible`: The set of systems of which you know they will fail to run the code properly. By default, if an OS in this set tries to run the code, this will yield a `RuntimeError` exception (configurable with `on_incompatible`).
220
+ * `on_incompatible` (optional): what to do when the running Python version or operating system is incompatible. One of:
221
+ * `'raise'` (default): raise a `RuntimeError` — the current behaviour.
222
+ * `'warn'`: log a warning and continue.
223
+ * `'ignore'`: continue silently (logged at DEBUG only). You take responsibility for running in an unsupported environment.
220
224
 
221
225
  **System Support Behavior:**
222
226
 
@@ -227,6 +231,8 @@ Salted in that specific version is a relatively young package that will receive
227
231
  | `incompatible` | ERROR | Yes (`RuntimeError`) | Known to fail |
228
232
  | Not listed | INFO | No | Support status unknown |
229
233
 
234
+ The `incompatible` row reflects the default `on_incompatible='raise'`. With `'warn'` it logs a warning and continues; with `'ignore'` it continues silently.
235
+
230
236
  ## Version strings
231
237
 
232
238
  For compatibility checks three elements of the version string are recognized:
@@ -285,6 +291,47 @@ The compatibility package logs at different levels:
285
291
  * **WARNING**: Running newer Python than tested, or partial platform support
286
292
  * **ERROR**: Incompatible Python version or operating system (also raises exceptions)
287
293
 
294
+ ### Example Messages
295
+
296
+ With logging configured, the messages look like the following (the level/name
297
+ prefix comes from your logging setup; here it is Python's `basicConfig` default):
298
+
299
+ ```text
300
+ DEBUG:compatibility:my_package fully supports Linux.
301
+ INFO:compatibility:You are using my_package 1.0.0 (released: 2025-01-01)
302
+ INFO:compatibility:Your version of my_package was released 120 days ago. Please check for updates.
303
+ WARNING:compatibility:my_package has only partial support on Windows.
304
+ WARNING:compatibility:You are running Python 3.15.final, but your version of my_package is only tested up to 3.14. Please check for updates.
305
+ ERROR:compatibility:This version of my_package is incompatible with Windows!
306
+ ```
307
+
308
+ An incompatible Python version (below `min_version`, or listed in
309
+ `incompatible_versions`) is logged the same way and, with the default
310
+ `on_incompatible='raise'`, additionally raises `RuntimeError`:
311
+
312
+ ```text
313
+ ERROR:compatibility:You use Python 3.9.final, but need at least Python 3.10 to run my_package.
314
+ ```
315
+
316
+ The same messages appear translated when you select another language (for
317
+ example `language_messages='de'`).
318
+
319
+ ## Translations
320
+
321
+ Each available language has one of the following quality levels:
322
+
323
+ | Language | Code | Status |
324
+ |----------|------|--------|
325
+ | English | `en` | Default / source language |
326
+ | German | `de` | Reviewed by a native speaker |
327
+ | French | `fr` | Translated by AI (pending native review) |
328
+ | Dutch | `nl` | Translated by AI (pending native review) |
329
+ | Spanish | `es` | Translated by AI (pending native review) |
330
+
331
+ The AI-translated languages are marked as such in the message catalog (`.po`) header until a native speaker has reviewed them. Corrections and reviews from native speakers are very welcome.
332
+
333
+ Set `language_messages='auto'` to follow the user's environment locale (`LANGUAGE`/`LC_ALL`/`LC_MESSAGES`/`LANG`); if no matching catalog is available, messages fall back to English.
334
+
288
335
  ## Exceptions
289
336
 
290
337
  The `compatibility` package may raise the following exceptions:
@@ -292,6 +339,7 @@ The `compatibility` package may raise the following exceptions:
292
339
  * `RuntimeError`: Raised when the Python version or operating system is incompatible with your package.
293
340
  * `ValueError`: Raised when invalid parameters are provided to the `Check` class.
294
341
  * `compatibility.err.BadDate`: Raised when the `release_date` parameter contains an invalid or malformed date.
342
+ * `compatibility.err.BadDateType`: Raised when the `release_date` parameter is neither a `datetime.date` nor a string. Subclasses `TypeError`.
295
343
  * `compatibility.err.ParameterContradiction`: Raised when conflicting parameters are provided (e.g., a system marked as both fully supported and incompatible).
296
344
 
297
345
  ## Use Cases
@@ -306,7 +354,7 @@ Use `incompatible_versions` to block specific Python versions where your package
306
354
  Use `max_tested_version` to warn users when they're running your package on newer Python versions you haven't tested yet. This helps manage expectations and reduces false bug reports.
307
355
 
308
356
  ### When You Drop Support for Old Python Versions
309
- After dropping Python 3.9 support, use this library to give users a clear error message instead of cryptic import errors or runtime failures.
357
+ After dropping (for example) Python 3.9 support, use this library to give users a clear error message instead of cryptic import errors or runtime failures.
310
358
 
311
359
  ### When Your Package Only Works on Certain Operating Systems
312
360
  Use `system_support` to declare which operating systems (Linux, macOS, Windows) are fully supported, partially supported, or incompatible. For example, if your package uses Linux-specific system calls.
@@ -0,0 +1,37 @@
1
+ """
2
+ A library that checks whether the running version of Python is compatible and
3
+ tested. Remind the user to check for updates of the library.
4
+ """
5
+
6
+ import importlib.metadata
7
+
8
+ from compatibility.__main__ import (
9
+ Check,
10
+ NagOverUpdate,
11
+ PythonVersionSupport,
12
+ SystemSupport,
13
+ )
14
+ from compatibility import err
15
+
16
+ __all__ = [
17
+ "Check",
18
+ "NagOverUpdate",
19
+ "PythonVersionSupport",
20
+ "SystemSupport",
21
+ "err",
22
+ ]
23
+
24
+
25
+ def _get_version() -> str:
26
+ # Reading the version from installed package metadata fails on a fresh
27
+ # source checkout (before `pip install -e .` / `poetry install`). Fall back
28
+ # to a placeholder so importing straight from the source tree still works.
29
+ try:
30
+ return importlib.metadata.version("compatibility")
31
+ except importlib.metadata.PackageNotFoundError:
32
+ return "0+unknown"
33
+
34
+
35
+ NAME = "compatibility"
36
+ __version__ = _get_version()
37
+ __author__ = "Rüdiger Voigt"