snowflake_uuid: Simple Persistent System-wide Unique IDs
I’ve often found myself needing to have a per-machine unique identifier, but actually getting one of these is harder than it should be. You can’t just use the MAC address, since those aren’t guaranteed to be unique, especially when you’re working with a batch of cheap embedded devices. While not rocket science, it’s also not trivial to get the MAC address of a box sometimes: which interface to use? What if you change network cards? What if you have to spoof a MAC address? POSIX specifies gethostid(1), but on Linux the man page notes under “Bugs” that “It is impossible to ensure that the identifier is globally unique.” Indeed, my laptop and my work computer have the same hostid value.
snowflake_uuid is a trivial wrapper around Python’s uuid library to create a persistent, per-machine UUID (called a ‘snowflake’, not to be confused with the [data warehousing project](https://www.snowflake.com)) and give you a nice API to mess with it. Usage is simple:
>>> import snowflake_uuid >>> snowflake_uuid.snowflake() '7232c1c3-f6d1-4aec-bedd-c7e4c10dc8d3'
There’s also a script that can be run from the command line:
$ snowflake 7232c1c3-f6d1-4aec-bedd-c7e4c10dc8d3
Installation and Setup
To generate a machine’s snowflake ID, just install snowflake:
$ pip install snowflake_uuid
Or from source:
$ python setup.py install
The machine’s snowflake is saved in /etc/snowflake during installation. Any user can read this file, but only users with root access can modify it. You can also generate other snowflakes in other locations, so each user (or application) can make their own snowflakes.
Of course, you can do all this in Python too:
>>> import snowflake_uuid >>> snowflake_uuid.make_snowflake(snowflake_file='foo') ee2b1891-ccd3-4a23-9246-4ce40d20e740 >>> snowflake_uuid.snowflake(snowflake_file='foo') ee2b1891-ccd3-4a23-9246-4ce40d20e740
Metadata
Release files for snowflake-uuid 0.1.1
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 |
|---|---|---|---|---|
| snowflake_uuid-0.1.1.tar.gz | 3.3 kB | Without provenance | Details for snowflake_uuid-0.1.1.tar.gz |
Release files / snowflake_uuid-0.1.1.tar.gz
| Download URL | snowflake_uuid-0.1.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaf629fd1787f6aca495020116fc92149d012c29962d558f42b64182ddff77a8
|
|
BLAKE2b-256 checksum How to use checksums |
343f46fe2c5b065c2a9bae8bc14b1769ce2a352a01f6aeac9e3749fc71943aaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for snowflake-uuid 0.1.1
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.