commit:     79422a5256927c8121cfa296132d8a6dcee4b8e6
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  9 03:47:22 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 22:08:57 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=79422a52

catalyst: Use pyproject.toml

See PEPs 517, 518, and (Draft) 621.

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 .gitattributes       |   1 -
 .gitignore           |   2 +-
 AUTHORS              |  54 ----------------------
 MANIFEST.in          |   6 ---
 catalyst/__init__.py |  10 +---
 catalyst/main.py     |   4 +-
 catalyst/version.py  |  65 --------------------------
 pyproject.toml       |  77 +++++++++++++++++++++++++++++++
 setup.py             | 127 ++++++---------------------------------------------
 9 files changed, 93 insertions(+), 253 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 19ad929b..0b2b43fc 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,3 @@
-AUTHORS ident
 ChangeLog ident
 README ident
 TODO ident

diff --git a/.gitignore b/.gitignore
index 649b79ab..8979e259 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
 *.py[co]
+/catalyst/version.py
 
 /build/
 /dist/
 /files/
-/MANIFEST

diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index 41366b8c..00000000
--- a/AUTHORS
+++ /dev/null
@@ -1,54 +0,0 @@
-The copyright for catalyst is held by the Gentoo Foundation and by each
-of the individual contributors.
-
-
-Original Authors:
------------------
-John Davis <z...@gentoo.org>
-Daniel Robbins <drobb...@gentoo.org>
-
-
-Significant contributors (including the first catalyst3 rewrite):
------------------------------------------------------------------
-Andrew Gaffney <agaff...@gentoo.org>
-Chris Gianelloni <wolf3...@wolf31o2.org>
-
-
-Contributors:
--------------
-Eric Edgar <roc...@gentoo.org>
-Andrew Gaffney <agaff...@gentoo.org>
-Chris Gianelloni <wolf3...@gentoo.org>
-David Bryson <mu...@gentoo.org>
-Mike Frysinger <vap...@gentoo.org>
-Rob Holland <tig...@gentoo.org>
-Robin H. Johnson <robb...@gentoo.org>
-Joshua Kinard <ku...@gentoo.org>
-Stuart Longland <redhat...@gentoo.org>
-Guy Martin <gms...@gentoo.org>
-Daniel Ostrow <dost...@gentoo.org>
-Robert Paskowitz <r...@gentoo.org>
-Diego Pettenò <flamee...@gentoo.org>
-Matsuu Takuto <mat...@gentoo.org>
-Lars Weiler <py...@gentoo.org>
-Gustavo Zacarias <gusta...@gentoo.org>
-Raúl Porcel <armi...@gentoo.org>
-Jorge Manuel B. S. Vicetto <jmbsvice...@gentoo.org>
-W. Trevor King <wk...@tremily.us>
-Matt Turner <matts...@gmail.com>
-Anthony G. Basile <bluen...@gentoo.org>
-Ben Kohler <bkoh...@gmail.com>
-Brian Dolbec <dol...@gentoo.org>
-Douglas Freed <dwfr...@mtu.edu>
-Dylan Baker <baker.dyla...@gmail.com>
-Jeremy Olexa <darks...@gentoo.org>
-Kevin Zhao <kevin.zhaosh...@gmail.com>
-Rick Farina (Zero_Chaos) <zeroch...@gentoo.org>
-Sebastian Pipping <sebast...@pipping.org>
-Yuta SATOH <nigoro....@gmail.com>
-William Hubbs <w.d.hu...@gmail.com>
-
-Maintainers:
-------------
-Catalyst maintainers <catal...@gentoo.org>
-Release Engineering <rel...@gentoo.org>

diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 4274094a..00000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,6 +0,0 @@
-include AUTHORS
-include ChangeLog
-include COPYING
-include Makefile
-recursive-include doc *.conf *.py HOWTO.txt catalyst*.txt
-recursive-include examples README *.example *.spec

diff --git a/catalyst/__init__.py b/catalyst/__init__.py
index 143bdf81..13a72c07 100644
--- a/catalyst/__init__.py
+++ b/catalyst/__init__.py
@@ -1,10 +1,2 @@
-"Catalyst is the release building tool used by Gentoo Linux"
 
-__maintainer__ = 'Catalyst <catal...@gentoo.org>'
-
-try:
-    from .verinfo import version as fullversion
-    __version__ = fullversion.split('\n')[0].split()[1]
-except ImportError:
-    from .version import get_version, __version__
-    fullversion = get_version(reset=True)
+from .version import version as __version__

diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..ab5c2a01 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -18,13 +18,11 @@ import catalyst.config
 from catalyst.defaults import (confdefaults, option_messages,
                                DEFAULT_CONFIG_FILE, valid_config_file_values)
 from catalyst.support import CatalystError
-from catalyst.version import get_version
 
 conf_values = confdefaults
 
 
 def version():
-    log.info(get_version())
     log.info('Copyright 2003-%s Gentoo Foundation',
              datetime.datetime.now().year)
     log.info('Copyright 2008-2012 various authors')
@@ -118,7 +116,7 @@ def get_parser():
         epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter)
 
     parser.add_argument('-V', '--version',
-                        action='version', version=get_version(),
+                        action='version', version=catalyst.__version__,
                         help='display version information')
 
     group = parser.add_argument_group('Program output options')

diff --git a/catalyst/version.py b/catalyst/version.py
deleted file mode 100644
index dbada51a..00000000
--- a/catalyst/version.py
+++ /dev/null
@@ -1,65 +0,0 @@
-'''Version information and/or git version information
-'''
-
-import os
-
-from snakeoil.version import get_git_version as get_ver
-
-__version__ = "3.0.7"
-_ver = None
-
-
-def get_git_version(version=__version__):
-    """Return: a string describing our version."""
-    # pylint: disable=global-statement
-    global _ver
-    cwd = os.path.dirname(os.path.abspath(__file__))
-    version_info = get_ver(cwd)
-
-    if not version_info:
-        s = "extended version info unavailable"
-    elif version_info['tag'] == __version__:
-        s = 'released %s' % (version_info['date'],)
-    else:
-        s = ('vcs version %s, date %s' %
-             (version_info['rev'], version_info['date']))
-
-    _ver = 'Catalyst %s\n%s' % (version, s)
-
-    return _ver
-
-
-def get_version(reset=False):
-    '''Returns a saved release version string or the
-    generated git release version.
-    '''
-    # pylint: disable=global-statement
-    global __version__, _ver
-    if _ver and not reset:
-        return _ver
-    try:  # getting the fixed version
-        from .verinfo import version
-        _ver = version
-        __version__ = version.split('\n')[0].split()[1]
-    except ImportError:  # get the live version
-        version = get_git_version()
-    return version
-
-
-def set_release_version(version, root=None):
-    '''Saves the release version along with the
-    git log release information
-
-    @param version: string
-    @param root: string, optional alternate root path to save to
-    '''
-    #global __version__
-    filename = "verinfo.py"
-    if not root:
-        path = os.path.join(os.path.dirname(__file__), filename)
-    else:
-        path = os.path.join(root, filename)
-    #__version__ = version
-    ver = get_git_version(version)
-    with open(path, 'w') as f:
-        f.write("version = {0!r}".format(ver))

diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..e6a14f35
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,77 @@
+[project]
+name = "catalyst"
+description = "Tool for creating releases based on Gentoo Linux"
+authors = [
+    "Andrew Gaffney <agaff...@gentoo.org>",
+    "Anthony G. Basile <bluen...@gentoo.org>",
+    "Ben Kohler <bkoh...@gmail.com>",
+    "Brian Dolbec <dol...@gentoo.org>",
+    "Chris Gianelloni <wolf3...@gentoo.org>",
+    "Daniel Ostrow <dost...@gentoo.org>",
+    "David Bryson <mu...@gentoo.org>",
+    "Diego Pettenò <flamee...@gentoo.org>",
+    "Douglas Freed <dwfr...@mtu.edu>",
+    "Dylan Baker <baker.dyla...@gmail.com>",
+    "Eric Edgar <roc...@gentoo.org>",
+    "Gustavo Zacarias <gusta...@gentoo.org>",
+    "Guy Martin <gms...@gentoo.org>",
+    "Jeremy Olexa <darks...@gentoo.org>",
+    "Jorge Manuel B. S. Vicetto <jmbsvice...@gentoo.org>",
+    "Joshua Kinard <ku...@gentoo.org>",
+    "Kevin Zhao <kevin.zhaosh...@gmail.com>",
+    "Lars Weiler <py...@gentoo.org>",
+    "Matsuu Takuto <mat...@gentoo.org>",
+    "Matt Turner <matts...@gentoo.org>",
+    "Mike Frysinger <vap...@gentoo.org>",
+    "Raúl Porcel <armi...@gentoo.org>",
+    "Rick Farina <zeroch...@gentoo.org>",
+    "Robert Paskowitz <r...@gentoo.org>",
+    "Rob Holland <tig...@gentoo.org>",
+    "Robin H. Johnson <robb...@gentoo.org>",
+    "Sebastian Pipping <sebast...@pipping.org>",
+    "Stuart Longland <redhat...@gentoo.org>",
+    "William Hubbs <w.d.hu...@gmail.com>",
+    "W. Trevor King <wk...@tremily.us>",
+    "Yuta SATOH <nigoro....@gmail.com>",
+]
+maintainers = [
+    "Catalyst maintainers <catal...@gentoo.org>",
+    "Catalyst mailing list <gentoo-catal...@lists.gentoo.org>",
+]
+license = "GPL-2.0-or-later"
+readme = "README"
+python = "^3.8"
+homepage = "https://wiki.gentoo.org/wiki/Project:Catalyst";
+repository = "https://gitweb.gentoo.org/proj/catalyst.git/";
+documentation = "https://wiki.gentoo.org/wiki/Catalyst";
+
+keywords = ["gentoo"]
+
+classifiers = [
+    'Development Status :: 5 - Production/Stable',
+    'License :: OSI Approved :: GNU General Public License v2 or later 
(GPLv2+)',
+    'Intended Audience :: System Administrators',
+    'Operating System :: POSIX',
+    'Topic :: System :: Archiving :: Packaging',
+    'Topic :: System :: Installation/Setup',
+    'Topic :: System :: Software Distribution',
+    'Programming Language :: Python :: 3',
+    'Programming Language :: Python :: 3.8',
+]
+
+# Requirements
+[dependencies]
+
+[dev-dependencies]
+
+[scripts]
+
+[build-system]
+requires = [
+    "setuptools >= 42",
+    "setuptools_scm[toml] >= 3.4",
+]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools_scm]
+write_to = "catalyst/version.py"

diff --git a/setup.py b/setup.py
index 7a97b30c..d807ea02 100755
--- a/setup.py
+++ b/setup.py
@@ -1,119 +1,18 @@
 #!/usr/bin/env python
-"""Catalyst is a release building tool used by Gentoo Linux"""
 
-import codecs as _codecs
-from distutils.core import setup as _setup, Command as _Command
-from email.utils import parseaddr as _parseaddr
-import os as _os
+from glob import glob
 
-from catalyst import __version__, __maintainer__
-from catalyst.version import set_release_version as _set_release_version
-from catalyst.version import get_version as _get_version
+from ppsetuptools import setup
 
+data_files = [
+    ('/etc/catalyst', ['etc/catalyst.conf', 'etc/catalystrc']),
+    ('/usr/share/man/man1', ['files/catalyst.1']),
+    ('/usr/share/man/man5',
+     ['files/catalyst-config.5', 'files/catalyst-spec.5']
+    ),
+    ('share/catalyst/arch', glob('arch/*')),
+    ('share/catalyst/livecd', glob('livecd/**/*', recursive=True)),
+    ('share/catalyst/targets', glob('targets/**', recursive=True)),
+]
 
-_this_dir = _os.path.dirname(__file__)
-_package_name = 'catalyst'
-_maintainer_name, _maintainer_email = _parseaddr(__maintainer__)
-
-
-def _posix_path(path):
-    """Convert a native path to a POSIX path
-
-    Distutils wants all paths to be written in the Unix convention
-    (i.e. slash-separated) [1], so that's what we'll do here.
-
-    [1]: https://docs.python.org/2/distutils/setupscript.html
-    """
-    if _os.path.sep != '/':
-        return path.replace(_os.path.sep, '/')
-    return path
-
-
-def _files(prefix, root):
-    """Iterate through all the file paths under `root`
-
-    Yielding `(target_dir, (file_source_paths, ...))` tuples.
-    """
-    for dirpath, _dirnames, filenames in _os.walk(root):
-        reldir = _os.path.relpath(dirpath, root)
-        install_directory = _posix_path(
-            _os.path.join(prefix, reldir))
-        file_source_paths = [
-            _posix_path(_os.path.join(dirpath, filename))
-            for filename in filenames]
-        yield (install_directory, file_source_paths)
-
-
-_data_files = [('/etc/catalyst', ['etc/catalyst.conf', 'etc/catalystrc']),
-               ('/usr/share/man/man1', ['files/catalyst.1']),
-               ('/usr/share/man/man5',
-                ['files/catalyst-config.5', 'files/catalyst-spec.5'])
-               ]
-_data_files.extend(_files('share/catalyst/arch', 'arch'))
-_data_files.extend(_files('share/catalyst/livecd', 'livecd'))
-_data_files.extend(_files('share/catalyst/targets', 'targets'))
-
-
-class set_version(_Command):
-    '''Saves the specified release version information
-    '''
-    description = "hardcode script's version using VERSION from environment"
-    user_options = []  # [(long_name, short_name, desc),]
-
-    def initialize_options(self):
-        pass
-
-    def finalize_options(self):
-        pass
-
-    def run(self):
-        # pylint: disable=global-statement
-        global __version__
-        try:
-            version = _os.environ['VERSION']
-        except KeyError:
-            print("Try setting 'VERSION=x.y.z' on the command line... 
Aborting")
-            return
-        _set_release_version(version)
-        __version__ = _get_version()
-        print("Version set to:\n", __version__)
-
-
-_setup(
-    name=_package_name,
-    version=__version__,
-    maintainer=_maintainer_name,
-    maintainer_email=_maintainer_email,
-    url='https://wiki.gentoo.org/wiki/Catalyst',
-    
download_url='http://distfiles.gentoo.org/distfiles/{0}-{1}.tar.bz2'.format(
-        _package_name, __version__),
-    license='GNU General Public License (GPL)',
-    platforms=['all'],
-    description=__doc__,
-    long_description=_codecs.open(
-        _os.path.join(_this_dir, 'README'), 'r', 'utf-8').read(),
-    classifiers=[
-        'Development Status :: 5 - Production/Stable',
-        'License :: OSI Approved :: GNU General Public License v2 or later 
(GPLv2+)',
-        'Intended Audience :: System Administrators',
-        'Operating System :: POSIX',
-        'Topic :: System :: Archiving :: Packaging',
-        'Topic :: System :: Installation/Setup',
-        'Topic :: System :: Software Distribution',
-        'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.6',
-        'Programming Language :: Python :: 3.7',
-        'Programming Language :: Python :: 3.8',
-    ],
-    scripts=['bin/{0}'.format(_package_name)],
-    packages=[
-        _package_name,
-        '{0}.base'.format(_package_name),
-        '{0}.targets'.format(_package_name),
-    ],
-    data_files=_data_files,
-    provides=[_package_name],
-    cmdclass={
-        'set_version': set_version
-    },
-)
+setup(data_files=data_files)

Reply via email to