readonly is a simple package to make any given module attributes into read only mode.
🛠️ Requirements
readonly requires Python 3.9 or above.
To install Python 3.9, I recommend using pyenv.
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv
# setup pyenv (you should also put these three lines in .bashrc or similar)
# if you are using zsh
cat << EOF >> ~/.zshrc
# pyenv config
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"
EOF
# or if you using the default bash shell, do this instead:
cat << EOF >> ~/.bashrc
# pyenv config
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"
EOF
# Close and open a new shell session
# install Python 3.9.10
pyenv install 3.9.10
# make it available globally
pyenv global system 3.9.10
To manage the Python 3.9 virtualenv, I recommend using poetry.
# install poetry
curl -sSL https://install.python-poetry.org | python3 -
poetry --version
Poetry version 1.1.13
# Having the python executable in your PATH, you can use it:
poetry env use 3.9.10
# However, you are most likely to get the following issue:
Creating virtualenv readonly-dxc671ba-py3.9 in ~/.cache/pypoetry/virtualenvs
ModuleNotFoundError
No module named 'virtualenv.seed.via_app_data'
at <frozen importlib._bootstrap>:973 in _find_and_load_unlocked
# To resolve it, you need to reinstall virtualenv through pip
sudo apt remove --purge python3-virtualenv virtualenv
python3 -m pip install -U virtualenv
# Now, you can just use the minor Python version in this case:
poetry env use 3.9.10
Using virtualenv: ~/.cache/pypoetry/virtualenvs/readonly-dxc671ba-py3.9
🚨 Installation
With pip:
python3.9 -m pip install readonly
🚸 Usage
>>> from readonly import readonly
>>> import math
>>> math = readonly(math)
# raises AttributeError
>>> math.pi = 3.0
🎉 Credits
The following projects were used to build and test readonly.
👋 Contribute
If you are looking for a way to contribute to the project, please refer to the Guideline.
📝 License
This program and the accompanying materials are made available under the terms and conditions of the GNU GENERAL PUBLIC LICENSE.
Metadata
Release files for readonly 0.1.2
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 |
|---|---|---|---|---|
| readonly-0.1.2.tar.gz | 4.6 kB | Without provenance | Details for readonly-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| readonly-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for readonly-0.1.2-py3-none-any.whl |
Total release size: 11.8 kB
Release files / readonly-0.1.2.tar.gz
| Download URL | readonly-0.1.2.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2608fd5a355d42cb3ddb2de502a296be8a5ac9885c64d7002180e96cec02f6c
|
|
BLAKE2b-256 checksum How to use checksums |
02924ec1230d43fe7f93ef6dc00e5ecf33013e47875fa24fb4000de81b00c358
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.6 Linux/5.19.0-38-generic
|
Release files / readonly-0.1.2-py3-none-any.whl
| Download URL | readonly-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c95cd593bb1fc62f842c357e9a15c47af009e91de5b9c8acc7f9ac4534ca3d11
|
|
BLAKE2b-256 checksum How to use checksums |
82f623cba74140a256a5f44ffdb7a00b868ec2c37f9764e095e15e9b33516775
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.6 Linux/5.19.0-38-generic
|
Security for readonly 0.1.2
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.