calver


Namecalver JSON
Version 2025.4.1 PyPI version JSON
download
home_pageNone
SummarySetuptools extension for CalVer package versions
upload_time2025-04-01 14:12:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords calver
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CalVer

The `calver` package is a [setuptools](https://pypi.org/p/setuptools) extension
for automatically defining your Python package version as a calendar version.

## Usage

First, ensure `calver` is present during the project's build step by specifying
it as one of the build requirements:

`pyproject.toml`:
```toml
[build-system]
requires = ["setuptools>=42", "calver"]
```

To enable generating the version automatically based on the date, add the
following to `setup.py`:

`setup.py`:
```python
from setuptools import setup

setup(
    ...
    use_calver=True,
    setup_requires=['calver'],
    ...
)
```

You can test that it is working with:

```console
$ python setup.py --version
2020.6.16
```

## Configuration

By default, when setting `use_calver=True`, it uses the following to generate
the version string:

```pycon
>>> import datetime
>>> datetime.datetime.now(tz=datetime.timezone.utc).strftime("%Y.%m.%d")
2020.6.16
```

You can override the format string by passing it instead of `True`:

`setup.py`:
```python
from setuptools import setup

setup(
    ...
    use_calver="%Y.%m.%d.%H.%M",
    setup_requires=['calver'],
    ...
)
```

You can override the current date/time by passing the environment variable
`SOURCE_DATE_EPOCH`, which should be a Unix timestamp in seconds. 
This is useful for reproducible builds (see https://reproducible-builds.org/docs/source-date-epoch/):

```console
env SOURCE_DATE_EPOCH=1743428011000 python setup.py --version
```

You can override this entirely by passing a callable instead, which will be called
with no arguments at build time:

`setup.py`:
```python
import datetime
from setuptools import setup

def long_now_version():
    now = datetime.datetime.now(tz=datetime.timezone.utc)
    return now.strftime("%Y").zfill(5) + "." + now.strftime("%m.%d")

setup(
    ...
    use_calver=long_now_version,
    setup_requires=['calver'],
    ...
)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "calver",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "calver",
    "author": null,
    "author_email": "Dustin Ingram <di@python.org>",
    "download_url": "https://files.pythonhosted.org/packages/51/a5/2371326892fcea6f185c0febea51139ce4f8a68a3c5d105e54cefe99637e/calver-2025.4.1.tar.gz",
    "platform": null,
    "description": "# CalVer\n\nThe `calver` package is a [setuptools](https://pypi.org/p/setuptools) extension\nfor automatically defining your Python package version as a calendar version.\n\n## Usage\n\nFirst, ensure `calver` is present during the project's build step by specifying\nit as one of the build requirements:\n\n`pyproject.toml`:\n```toml\n[build-system]\nrequires = [\"setuptools>=42\", \"calver\"]\n```\n\nTo enable generating the version automatically based on the date, add the\nfollowing to `setup.py`:\n\n`setup.py`:\n```python\nfrom setuptools import setup\n\nsetup(\n    ...\n    use_calver=True,\n    setup_requires=['calver'],\n    ...\n)\n```\n\nYou can test that it is working with:\n\n```console\n$ python setup.py --version\n2020.6.16\n```\n\n## Configuration\n\nBy default, when setting `use_calver=True`, it uses the following to generate\nthe version string:\n\n```pycon\n>>> import datetime\n>>> datetime.datetime.now(tz=datetime.timezone.utc).strftime(\"%Y.%m.%d\")\n2020.6.16\n```\n\nYou can override the format string by passing it instead of `True`:\n\n`setup.py`:\n```python\nfrom setuptools import setup\n\nsetup(\n    ...\n    use_calver=\"%Y.%m.%d.%H.%M\",\n    setup_requires=['calver'],\n    ...\n)\n```\n\nYou can override the current date/time by passing the environment variable\n`SOURCE_DATE_EPOCH`, which should be a Unix timestamp in seconds. \nThis is useful for reproducible builds (see https://reproducible-builds.org/docs/source-date-epoch/):\n\n```console\nenv SOURCE_DATE_EPOCH=1743428011000 python setup.py --version\n```\n\nYou can override this entirely by passing a callable instead, which will be called\nwith no arguments at build time:\n\n`setup.py`:\n```python\nimport datetime\nfrom setuptools import setup\n\ndef long_now_version():\n    now = datetime.datetime.now(tz=datetime.timezone.utc)\n    return now.strftime(\"%Y\").zfill(5) + \".\" + now.strftime(\"%m.%d\")\n\nsetup(\n    ...\n    use_calver=long_now_version,\n    setup_requires=['calver'],\n    ...\n)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Setuptools extension for CalVer package versions",
    "version": "2025.4.1",
    "project_urls": {
        "Homepage": "https://github.com/di/calver",
        "Repository": "https://github.com/di/calver"
    },
    "split_keywords": [
        "calver"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "aaed5c5e858854029916fd3a956eb1c3398abdf13881c1bca12660a8eeb8d17f",
                "md5": "c78d873b8586fec28f70bd153e9967fd",
                "sha256": "3fa871867ff40d4d54803a3339a571c928101bc33e5f15d830b2b292c543e085"
            },
            "downloads": -1,
            "filename": "calver-2025.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c78d873b8586fec28f70bd153e9967fd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 7358,
            "upload_time": "2025-04-01T14:12:08",
            "upload_time_iso_8601": "2025-04-01T14:12:08.364733Z",
            "url": "https://files.pythonhosted.org/packages/aa/ed/5c5e858854029916fd3a956eb1c3398abdf13881c1bca12660a8eeb8d17f/calver-2025.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "51a52371326892fcea6f185c0febea51139ce4f8a68a3c5d105e54cefe99637e",
                "md5": "3378afab63377a0926a805b920f1f820",
                "sha256": "662f1518a4ddeb7e31470cca55f56b3272dcd94be60d7a1fc20a27b44d162bca"
            },
            "downloads": -1,
            "filename": "calver-2025.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3378afab63377a0926a805b920f1f820",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 7354,
            "upload_time": "2025-04-01T14:12:09",
            "upload_time_iso_8601": "2025-04-01T14:12:09.371050Z",
            "url": "https://files.pythonhosted.org/packages/51/a5/2371326892fcea6f185c0febea51139ce4f8a68a3c5d105e54cefe99637e/calver-2025.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-04-01 14:12:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "di",
    "github_project": "calver",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "calver"
}
        
Elapsed time: 1.72519s