extras
Package that allows to make assertions about extras being installed or not.
For the detailed explanation read this blog post.
Usage
For the pyproject.toml users
[tool.poetry.dependencies]
package-extras = { version = "^0.2.0", optional = true }
# your actual extras below
psycopg2 = { version = "^2.9", optional = true }
mysqlclient = { version = "^1.3", optional = true }
[tool.poetry.extras]
databases = ["package-extras", "mysqlclient", "psycopg2"]
setup.py equivalent
extras_require = \
{'databases': ['package-extras>=0.2.0',
'psycopg2>=2.9,<3.0',
'mysqlclient>=1.3,<2.0']}
setup_kwargs = {
# ... rest of the arguments
'extras_require': extras_require,
}
setup(**setup_kwargs)
Add this or similar block to your code (likely top-level __init__.py file)
import warnings
try:
import package_extras
except ModuleNotFoundError:
pass
else:
warnings.warn(
"'test_package[databases]' extra is deprecated "
"and will be removed in a future release.",
category=DeprecationWarning,
stacklevel=2,
)
Or in case you want to assert the opposite (make sure that extras have been installed)
import warnings
try:
import package_extras
except ModuleNotFoundError:
warnings.warn(
"You are going to use functionality that depends on 'databases' extras. "
"Please install 'test_package[databases]' to proceed.",
category=ImportWarning,
stacklevel=2,
)
NOTE:
ImportWarningis ignored by default, so you either need to runpython -W allor useRuntimeWarninginstead.
After installation via pip install test_package[databases] your package users will get this warning.
>>> import test_package
DeprecationWarning: 'test_package[databases]' extra is deprecated and will be removed in a future release.
Development
$ poetry install
$ poetry build
$ poetry config pypi-token.pypi my-token
$ poetry publish
Metadata
Release files for package-extras 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| package-extras-0.3.0.tar.gz | 2.4 kB | Without provenance | Details for package-extras-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| package_extras-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for package_extras-0.3.0-py3-none-any.whl |
Total release size: 4.6 kB
Release files / package-extras-0.3.0.tar.gz
| Download URL | package-extras-0.3.0.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b84ec71a5ae28448d389d3ae0d62be13e98ccb155ebf27dc679e25fbe5b23e82
|
|
BLAKE2b-256 checksum How to use checksums |
731a342e0b1d90d69ef13cafb4cb3cafb7f801e941a87a6a37374898e59e0b58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.1 CPython/3.10.6 Linux/5.14.0-1054-oem
|
Release files / package_extras-0.3.0-py3-none-any.whl
| Download URL | package_extras-0.3.0-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7e2ea8d9473be667105da6e0ac8044582fc42ab84ca72516d2f916d13b56844
|
|
BLAKE2b-256 checksum How to use checksums |
34f6ab6717c21541012248de0cb5154781f4d7c163271f908e6b9978a6c29dc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.1 CPython/3.10.6 Linux/5.14.0-1054-oem
|
Security for package-extras 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.