├── .git_archival.txt ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.rst ├── setup.cfg ├── setup.py ├── setuptools_scm_git_archive └── __init__.py └── tests.py /.git_archival.txt: -------------------------------------------------------------------------------- 1 | node: cfdcdc68f75621c5808726c15daff9e490ed6d07 2 | node-date: 2023-09-21T08:26:05+02:00 3 | describe-name: 1.4-1-gcfdcdc6 4 | ref-names: HEAD -> master 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | .git_archival.txt export-subst 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.egg-info/ 2 | /build/ 3 | /dist/ 4 | /env/ 5 | .cache/ 6 | *.pyc 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | **This plugin is obsolete. ``setuptools_scm >= 7.0.0`` supports Git archives by itself.** 2 | 3 | Migration guide 4 | --------------- 5 | 6 | Change the contents of the ``.git_archival.txt`` file in the root directory of your repository from:: 7 | 8 | ref-names: $Format:%D$ 9 | 10 | to:: 11 | 12 | node: $Format:%H$ 13 | node-date: $Format:%cI$ 14 | describe-name: $Format:%(describe:tags=true)$ 15 | ref-names: $Format:%D$ 16 | 17 | Remove ``setuptools_scm_git_archive`` from your project's dependencies (e.g. the 18 | ``setup_requires`` list in your ``setup.py`` file). 19 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | 4 | [devpi:upload] 5 | formats = sdist,bdist_wheel 6 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from os.path import dirname, join 2 | from shutil import rmtree 3 | 4 | from pkg_resources import DistributionNotFound, load_entry_point, working_set 5 | from setuptools import find_packages, setup 6 | 7 | 8 | ENTRY_GROUP = 'setuptools_scm.parse_scm' 9 | ENTRY_GROUP_FALLBACK = 'setuptools_scm.parse_scm_fallback' 10 | ENTRY_NAME = '.git_archival.txt' 11 | ENTRY_POINT = ENTRY_NAME + ' = setuptools_scm_git_archive:parse' 12 | 13 | meta = dict( 14 | name='setuptools_scm_git_archive', 15 | description='setuptools_scm plugin for git archives', 16 | author='Changaco', 17 | author_email='changaco@changaco.oy.lc', 18 | url='https://github.com/Changaco/setuptools_scm_git_archive/', 19 | license='MIT', 20 | packages=find_packages(), 21 | long_description=open(join(dirname(__file__), 'README.rst')).read(), 22 | keywords='scm vcs version tags git archive', 23 | setup_requires=['setuptools-scm<8'], 24 | entry_points={ 25 | ENTRY_GROUP: ENTRY_POINT, 26 | ENTRY_GROUP_FALLBACK: ENTRY_POINT, 27 | }, 28 | ) 29 | 30 | # Clean up first, old eggs seem to confuse setuptools_scm 31 | rmtree(meta['name']+'.egg-info', ignore_errors=True) 32 | 33 | # Bootstrap 34 | try: 35 | load_entry_point(meta['name'], ENTRY_GROUP, ENTRY_NAME) 36 | except (DistributionNotFound, ImportError): 37 | working_set.add_entry('.') 38 | 39 | setup(use_scm_version=True, **meta) 40 | -------------------------------------------------------------------------------- /setuptools_scm_git_archive/__init__.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | import re 3 | import warnings 4 | 5 | from setuptools_scm import Configuration 6 | from setuptools_scm.utils import data_from_mime, trace 7 | from setuptools_scm.version import meta, tags_to_versions 8 | 9 | 10 | warnings.warn(DeprecationWarning( 11 | "This plugin is obsolete. setuptools_scm >= 7.0.0 supports Git archives by itself." 12 | )) 13 | 14 | 15 | tag_re = re.compile(r'(?<=\btag: )([^,]+)\b') 16 | 17 | # Define default config so call to meta() does not warn 18 | config = Configuration() 19 | 20 | 21 | def archival_to_version(data): 22 | trace('data', data) 23 | versions = tags_to_versions(tag_re.findall(data.get('ref-names', ''))) 24 | if versions: 25 | return meta(versions[0], config=config) 26 | 27 | 28 | def parse(root): 29 | archival = join(root, '.git_archival.txt') 30 | data = data_from_mime(archival) 31 | return archival_to_version(data) 32 | -------------------------------------------------------------------------------- /tests.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from setuptools_scm import format_version 3 | from setuptools_scm_git_archive import archival_to_version 4 | 5 | 6 | git_archival_mapping = { 7 | '1.0': {'ref-names': 'HEAD -> master, tag: foo, tag: 1.0'}, 8 | '1.1': {'ref-names': 'HEAD -> master, tag: release-1.1, tag: bar'}, 9 | '1.2': {'ref-names': 'HEAD -> master, tag: v1.2'}, 10 | } 11 | 12 | 13 | @pytest.mark.parametrize('expected,data', sorted(git_archival_mapping.items())) 14 | def test_archival_to_version(expected, data): 15 | version = archival_to_version(data) 16 | assert format_version( 17 | version, 18 | version_scheme='guess-next-dev', 19 | local_scheme='node-and-date') == expected 20 | --------------------------------------------------------------------------------