├── .flake8 ├── .github └── workflows │ ├── build.yml │ ├── lint.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.md ├── pyproject.toml ├── setup.py ├── src └── calver │ ├── __init__.py │ └── integration.py ├── tests ├── __init__.py ├── conftest.py └── test_integration.py └── tox.ini /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E731 3 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [push, pull_request, workflow_dispatch] 3 | 4 | env: 5 | FORCE_COLOR: 1 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: Set up Python 13 | uses: actions/setup-python@v5 14 | with: 15 | python-version: '3.x' 16 | - name: Install dependencies 17 | run: | 18 | python -m pip install --upgrade pip 19 | pip install build 20 | - name: Build package 21 | run: python -m build 22 | - name: Unpack sdist 23 | run: | 24 | mkdir -p dist/calver 25 | tar -xvvf dist/*.tar.gz -C dist/calver/ --strip-components=1 26 | - name: Install tox 27 | run: python -m pip install tox 28 | - name: Test 29 | run: python -m tox -e py --root dist/calver 30 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: [push, pull_request, workflow_dispatch] 3 | 4 | env: 5 | FORCE_COLOR: 1 6 | 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: Setup Python 13 | uses: actions/setup-python@v4 14 | with: 15 | python-version: "3.x" 16 | - name: Install tox 17 | run: python -m pip install tox 18 | - name: Lint 19 | run: python -m tox -e lint 20 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This workflow will upload a Python Package using Twine when a release is created 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: Upload Python Package 10 | 11 | on: 12 | release: 13 | types: [published] 14 | 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | deploy: 20 | 21 | runs-on: ubuntu-latest 22 | permissions: 23 | # Used to authenticate to PyPI via OIDC. 24 | id-token: write 25 | 26 | steps: 27 | - uses: actions/checkout@v4 28 | - name: Set up Python 29 | uses: actions/setup-python@v5 30 | with: 31 | python-version: '3.x' 32 | - name: Install dependencies 33 | run: | 34 | python -m pip install --upgrade pip 35 | pip install build 36 | - name: Build package 37 | run: python -m build 38 | - name: Publish package 39 | uses: pypa/gh-action-pypi-publish@release/v1 40 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: [push, pull_request, workflow_dispatch] 3 | 4 | env: 5 | FORCE_COLOR: 1 6 | 7 | jobs: 8 | test: 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"] 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | - name: Use Python ${{ matrix.python }} 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: ${{ matrix.python }} 21 | - name: Install tox 22 | run: python -m pip install tox 23 | - name: Test 24 | run: python -m tox -e py 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # general things to ignore 2 | build/ 3 | dist/ 4 | *.egg-info/ 5 | *.egg 6 | *.py[cod] 7 | __pycache__/ 8 | *.so 9 | *~ 10 | pip-wheel-metadata 11 | 12 | # due to using tox and pytest 13 | .tox 14 | .cache 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include tests *.py 2 | include pyproject.toml 3 | include tox.ini 4 | include *.md 5 | include LICENSE 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CalVer 2 | 3 | The `calver` package is a [setuptools](https://pypi.org/p/setuptools) extension 4 | for automatically defining your Python package version as a calendar version. 5 | 6 | ## Usage 7 | 8 | First, ensure `calver` is present during the project's build step by specifying 9 | it as one of the build requirements: 10 | 11 | `pyproject.toml`: 12 | ```toml 13 | [build-system] 14 | requires = ["setuptools>=42", "calver"] 15 | ``` 16 | 17 | To enable generating the version automatically based on the date, add the 18 | following to `setup.py`: 19 | 20 | `setup.py`: 21 | ```python 22 | from setuptools import setup 23 | 24 | setup( 25 | ... 26 | use_calver=True, 27 | setup_requires=['calver'], 28 | ... 29 | ) 30 | ``` 31 | 32 | You can test that it is working with: 33 | 34 | ```console 35 | $ python setup.py --version 36 | 2020.6.16 37 | ``` 38 | 39 | ## Configuration 40 | 41 | By default, when setting `use_calver=True`, it uses the following to generate 42 | the version string: 43 | 44 | ```pycon 45 | >>> import datetime 46 | >>> datetime.datetime.now(tz=datetime.timezone.utc).strftime("%Y.%m.%d") 47 | 2020.6.16 48 | ``` 49 | 50 | You can override the format string by passing it instead of `True`: 51 | 52 | `setup.py`: 53 | ```python 54 | from setuptools import setup 55 | 56 | setup( 57 | ... 58 | use_calver="%Y.%m.%d.%H.%M", 59 | setup_requires=['calver'], 60 | ... 61 | ) 62 | ``` 63 | 64 | You can override the current date/time by passing the environment variable 65 | `SOURCE_DATE_EPOCH`, which should be a Unix timestamp in seconds. 66 | This is useful for reproducible builds (see https://reproducible-builds.org/docs/source-date-epoch/): 67 | 68 | ```console 69 | env SOURCE_DATE_EPOCH=1743428011000 python setup.py --version 70 | ``` 71 | 72 | You can override this entirely by passing a callable instead, which will be called 73 | with no arguments at build time: 74 | 75 | `setup.py`: 76 | ```python 77 | import datetime 78 | from setuptools import setup 79 | 80 | def long_now_version(): 81 | now = datetime.datetime.now(tz=datetime.timezone.utc) 82 | return now.strftime("%Y").zfill(5) + "." + now.strftime("%m.%d") 83 | 84 | setup( 85 | ... 86 | use_calver=long_now_version, 87 | setup_requires=['calver'], 88 | ... 89 | ) 90 | ``` 91 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=77.0.1"] # https://github.com/di/calver/pull/19 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "calver" 7 | dynamic = ["version"] 8 | description = "Setuptools extension for CalVer package versions" 9 | readme = "README.md" 10 | requires-python = ">=3.9" 11 | license = "Apache-2.0" 12 | authors = [ 13 | { name = "Dustin Ingram", email = "di@python.org" } 14 | ] 15 | keywords = ["calver"] 16 | classifiers = [ 17 | "Intended Audience :: Developers", 18 | "Topic :: Software Development :: Build Tools", 19 | "Programming Language :: Python :: 3", 20 | ] 21 | 22 | [project.urls] 23 | Homepage = "https://github.com/di/calver" 24 | Repository = "https://github.com/di/calver" 25 | 26 | [project.entry-points."distutils.setup_keywords"] 27 | use_calver = "calver.integration:version" 28 | 29 | [tool.setuptools] 30 | [tool.setuptools.packages.find] 31 | where = ["src"] 32 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from setuptools import setup 5 | 6 | 7 | def calver_version(value): 8 | here = os.path.abspath(os.path.dirname(__file__)) 9 | src = os.path.join(here, "src") 10 | 11 | sys.path.insert(0, src) 12 | 13 | from calver.integration import _get_version 14 | 15 | return _get_version(value) 16 | 17 | 18 | setup( 19 | version=calver_version(True), 20 | ) 21 | -------------------------------------------------------------------------------- /src/calver/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/di/calver/3b74bdce35f2814eb2b65db39a133d5c849ddea7/src/calver/__init__.py -------------------------------------------------------------------------------- /src/calver/integration.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import os 3 | import time 4 | 5 | DEFAULT_FORMAT = "%Y.%m.%d" 6 | 7 | 8 | def get_pkginfo_contents(): 9 | path = os.path.join(os.path.abspath("."), "PKG-INFO") 10 | with open(path, encoding="utf-8") as fp: 11 | return fp.read() 12 | 13 | 14 | def pkginfo_version(): 15 | try: 16 | content = get_pkginfo_contents() 17 | except FileNotFoundError: 18 | return 19 | 20 | data = dict(x.split(": ", 1) for x in content.splitlines() if ": " in x) 21 | 22 | version = data.get("Version") 23 | if version != "UNKNOWN": 24 | return version 25 | 26 | 27 | def _get_version(value): 28 | if not value: 29 | return 30 | 31 | version_from_package_info = pkginfo_version() 32 | if version_from_package_info: 33 | return version_from_package_info 34 | 35 | build_date = datetime.datetime.fromtimestamp( 36 | int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), 37 | tz=datetime.timezone.utc, 38 | ) 39 | 40 | if value is True: 41 | generate_version = lambda: build_date.strftime(DEFAULT_FORMAT) 42 | elif isinstance(value, str): 43 | generate_version = lambda: build_date.strftime(value) 44 | elif getattr(value, "__call__", None): 45 | generate_version = value 46 | else: 47 | return 48 | return generate_version() 49 | 50 | 51 | def version(dist, keyword, value): 52 | _version = _get_version(value) 53 | 54 | if _version: 55 | dist.metadata.version = _version 56 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # the inclusion of the tests module is not meant to offer best practices for 2 | # testing in general, but rather to support the `find_packages` example in 3 | # setup.py that excludes installing the "tests" package 4 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pretend 4 | import pytest 5 | 6 | import calver.integration 7 | 8 | 9 | # Clean environment variable SOURCE_DATE_EPOCH if it's already present, e.g. 10 | # set up by packaging tool, since it may mess up logic of our testsuite. 11 | def pytest_configure(config): 12 | if "SOURCE_DATE_EPOCH" in os.environ: 13 | del os.environ["SOURCE_DATE_EPOCH"] 14 | 15 | 16 | @pytest.fixture 17 | def original_version(): 18 | return pretend.stub() 19 | 20 | 21 | @pytest.fixture 22 | def dist(original_version): 23 | return pretend.stub(metadata=pretend.stub(version=original_version)) 24 | 25 | 26 | @pytest.fixture 27 | def keyword(): 28 | return pretend.stub() 29 | 30 | 31 | @pytest.fixture 32 | def ignore_pkginfo(monkeypatch): 33 | # Ensure that the test doesn't unintently prefer to read from a PKG_INFO 34 | # that might exist in the source directory, e.g. when testing a sdist 35 | # https://github.com/di/calver/issues/20 36 | monkeypatch.setattr( 37 | calver.integration, "get_pkginfo_contents", pretend.raiser(FileNotFoundError) 38 | ) 39 | 40 | 41 | @pytest.fixture 42 | def source_date_epoch(monkeypatch): 43 | _source_date_epoch = 1234567890 44 | monkeypatch.setenv("SOURCE_DATE_EPOCH", str(_source_date_epoch)) 45 | yield _source_date_epoch 46 | monkeypatch.delenv("SOURCE_DATE_EPOCH") 47 | -------------------------------------------------------------------------------- /tests/test_integration.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import os 3 | 4 | import pretend 5 | import pytest 6 | 7 | import calver.integration 8 | 9 | 10 | @pytest.mark.parametrize("value", [None, False, ""]) 11 | def test_version_missing(dist, keyword, original_version, value): 12 | calver.integration.version(dist, keyword, value) 13 | 14 | assert dist.metadata.version == original_version 15 | 16 | 17 | def test_version_true(dist, keyword, ignore_pkginfo): 18 | value = True 19 | 20 | calver.integration.version(dist, keyword, value) 21 | 22 | assert dist.metadata.version == datetime.datetime.now().strftime( 23 | calver.integration.DEFAULT_FORMAT 24 | ) 25 | 26 | 27 | def test_version_str(dist, keyword, ignore_pkginfo): 28 | value = "%c" 29 | 30 | calver.integration.version(dist, keyword, value) 31 | 32 | assert dist.metadata.version == datetime.datetime.utcnow().strftime(value) 33 | 34 | 35 | def test_version_callable(dist, keyword, ignore_pkginfo): 36 | v = pretend.stub() 37 | 38 | calver.integration.version(dist, keyword, lambda: v) 39 | 40 | assert dist.metadata.version == v 41 | 42 | 43 | def test_reads_pkginfo(dist, keyword, monkeypatch): 44 | pkginfo_contents = "Version: 42" 45 | monkeypatch.setattr( 46 | calver.integration, "get_pkginfo_contents", lambda: pkginfo_contents 47 | ) 48 | 49 | calver.integration.version(dist, keyword, True) 50 | 51 | assert dist.metadata.version == "42" 52 | 53 | 54 | def test_reproducible_build(dist, keyword, source_date_epoch, ignore_pkginfo): 55 | calver.integration.version(dist, keyword, True) 56 | 57 | assert dist.metadata.version == datetime.datetime.fromtimestamp( 58 | source_date_epoch, tz=datetime.timezone.utc 59 | ).strftime(calver.integration.DEFAULT_FORMAT) 60 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py{39,310,311,312,313,314},lint 3 | minversion = 3.3.0 4 | isolated_build = true 5 | 6 | [testenv] 7 | usedevelop = true 8 | deps = 9 | pytest 10 | pretend 11 | commands = pytest {posargs} 12 | 13 | [testenv:lint] 14 | basepython=python3 15 | deps = 16 | black 17 | twine 18 | isort 19 | build 20 | commands = 21 | black --check src tests setup.py 22 | isort -rc -c src tests setup.py 23 | python -m build . 24 | twine check dist/* 25 | --------------------------------------------------------------------------------