Skip to main content

Latest PyPI Version Documentation Status License Supported Python Versions

IPython Secrets makes it easier to use secrets in a Jupyter notebook.

The first time get_secret is called, it prompts the user for the password or other secret. After this value is read, it is saved in the system keyring, and the Jupyter output cell is then cleared.

gif1

Subsequent calls to get_secret use the saved value. This is true even if they are called in a different process running in the same account – for example, if the machine has been rebooted, or the local Jupyter server has otherwise been shut down and restarted.

gif2

Install

pip3 install ipython-secrets

Usage

from ipython_secrets import *

TWILIO_API_KEY = get_secret('TWILIO_API_KEY')

Alternatives

Secrets can also be stored in an environment variable, and read from the notebook. This is a best practice for applications (and especially web and other server-side services), but I’ve found it inconvenient for notebooks – the notebook server must be re-started to pick up a new environment variable; and, it complicates the setup instructions for notebook users.

Development

Install Pipenv, and required packages:

$ pip3 install pipenv
$ pipenv install
$ pipenv shell
$ pip install flit

Install locally:

flit install --symlink

Acknowledgements

This package is a thin wrapper around Keyring.

License

MIT

Release files for ipython-secrets 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipython-secrets 1.1.1
File Size Uploaded
ipython-secrets-1.1.1.tar.gz 70.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ipython-secrets 1.1.1
File Interpreter ABI Platform
ipython_secrets-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 79.8 kB

Release files / ipython-secrets-1.1.1.tar.gz

Download URL ipython-secrets-1.1.1.tar.gz
Size 70.2 kB
Tags Source
SHA-256 checksum
How to use checksums
346bbf40977e61196564328b3e134ec4c71fc6fbe2bb192ea90716bd951585b5
BLAKE2b-256 checksum
How to use checksums
4b5d7670d778e0469f341946e4318127f005ca41d670d32de6037e5df312c1e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / ipython_secrets-1.1.1-py3-none-any.whl

Download URL ipython_secrets-1.1.1-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d1f088e8095d51fec5dae5fd72aa2faf290dfe6914abdde7cb3ccf45eb4043b
BLAKE2b-256 checksum
How to use checksums
53c38bf761aff37e08141bfe7f3086f276a9545b73b10ba935b48bb4dc036f54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page