snowflake-uuid


Namesnowflake-uuid JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/shaddi/snowflake
SummarySimple persistent unique IDs.
upload_time2023-08-27 21:26:37
maintainer
docs_urlNone
authorShaddi Hasan
requires_python
licensebsd
keywords unique id uuid persistent identification
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/shaddi/snowflake",
    "name": "snowflake-uuid",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "unique id uuid persistent identification",
    "author": "Shaddi Hasan",
    "author_email": "shaddih@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/34/3f/46fe2c5b065c2a9bae8bc14b1769ce2a352a01f6aeac9e3749fc71943aaa/snowflake_uuid-0.1.1.tar.gz",
    "platform": null,
    "description": "snowflake_uuid: Simple Persistent System-wide Unique IDs\n========================================================\n\nI've often found myself needing to have a per-machine unique identifier, but\nactually getting one of these is harder than it should be. You can't just use\nthe MAC address, since those aren't guaranteed to be unique, especially when\nyou're working with a batch of cheap embedded devices. While not rocket\nscience, it's also not trivial to get the MAC address of a box sometimes: which\ninterface to use? What if you change network cards? What if you have to spoof a\nMAC address? POSIX specifies gethostid(1), but on Linux the man page notes\nunder \"Bugs\" that \"It is impossible to ensure that the identifier is globally\nunique.\" Indeed, my laptop and my work computer have the same hostid value.\n\nsnowflake_uuid is a trivial wrapper around Python's uuid library to create a\npersistent, per-machine UUID (called a 'snowflake', not to be confused with the\n[data warehousing project](https://www.snowflake.com)) and give you a nice API\nto mess with it. Usage is simple:\n\n    >>> import snowflake_uuid\n    >>> snowflake_uuid.snowflake()\n    '7232c1c3-f6d1-4aec-bedd-c7e4c10dc8d3'\n\nThere's also a script that can be run from the command line:\n\n    $ snowflake\n    7232c1c3-f6d1-4aec-bedd-c7e4c10dc8d3\n\nInstallation and Setup\n----------------------\nTo generate a machine's snowflake ID, just install snowflake:\n\n    $ pip install snowflake_uuid\n\nOr from source:\n\n    $ python setup.py install\n\nThe machine's snowflake is saved in /etc/snowflake during installation. Any\nuser can read this file, but only users with root access can modify it. You can\nalso generate other snowflakes in other locations, so each user (or\napplication) can make their own snowflakes.\n\nOf course, you can do all this in Python too:\n\n    >>> import snowflake_uuid\n    >>> snowflake_uuid.make_snowflake(snowflake_file='foo')\n    ee2b1891-ccd3-4a23-9246-4ce40d20e740\n    >>> snowflake_uuid.snowflake(snowflake_file='foo')\n    ee2b1891-ccd3-4a23-9246-4ce40d20e740",
    "bugtrack_url": null,
    "license": "bsd",
    "summary": "Simple persistent unique IDs.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/shaddi/snowflake"
    },
    "split_keywords": [
        "unique",
        "id",
        "uuid",
        "persistent",
        "identification"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "343f46fe2c5b065c2a9bae8bc14b1769ce2a352a01f6aeac9e3749fc71943aaa",
                "md5": "d41904c4b12a2fc33363852d337b6b63",
                "sha256": "eaf629fd1787f6aca495020116fc92149d012c29962d558f42b64182ddff77a8"
            },
            "downloads": -1,
            "filename": "snowflake_uuid-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d41904c4b12a2fc33363852d337b6b63",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3316,
            "upload_time": "2023-08-27T21:26:37",
            "upload_time_iso_8601": "2023-08-27T21:26:37.521042Z",
            "url": "https://files.pythonhosted.org/packages/34/3f/46fe2c5b065c2a9bae8bc14b1769ce2a352a01f6aeac9e3749fc71943aaa/snowflake_uuid-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-27 21:26:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shaddi",
    "github_project": "snowflake",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "snowflake-uuid"
}
        
Elapsed time: 0.10421s