* [gentoo-commits] proj/catalyst:rewrite-on-master commit in: catalyst/, /
@ 2013-11-22 7:13 Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2013-11-22 7:13 UTC (permalink / raw
To: gentoo-commits
commit: 34be7b0c24c49868cfad5791b5c08f86d7ac19bf
Author: W. Trevor King <wking <AT> tremily <DOT> us>
AuthorDate: Wed Jun 5 17:13:43 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Nov 22 06:02:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=34be7b0c
setup.py: Add disutils-based packaging
Package catalyst in the usual manner for Python projects. Now it is
ready for PyPI :).
I also expose the version string in catalyst.__version__, since that's
a more traditional location than catalyst.version.__version__.
---
.gitignore | 7 ++++-
MANIFEST.in | 6 ++++
catalyst/__init__.py | 3 ++
setup.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 711f9e8..0cf4f26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,10 @@
*.py[co]
+
+build
+dist
+files
+MANIFEST
+
test.*
*.geany
Scratch
-
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..4274094
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,6 @@
+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 e69de29..c2538aa 100644
--- a/catalyst/__init__.py
+++ b/catalyst/__init__.py
@@ -0,0 +1,3 @@
+"Catalyst is a release building tool used by Gentoo Linux"
+
+from .version import __version__
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..34eae53
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,89 @@
+# Copyright (C) 2013 W. Trevor King <wking@tremily.us>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"Catalyst is a release building tool used by Gentoo Linux"
+
+import codecs as _codecs
+from distutils.core import setup as _setup
+import itertools as _itertools
+import os as _os
+
+from catalyst import __version__
+
+
+_this_dir = _os.path.dirname(__file__)
+package_name = 'catalyst'
+tag = '{0}-{1}'.format(package_name, __version__)
+
+
+def files(root):
+ """Iterate through all the file paths under `root`
+
+ 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]: http://docs.python.org/2/distutils/setupscript.html#writing-the-setup-script
+ """
+ for dirpath, dirnames, filenames in _os.walk(root):
+ for filename in filenames:
+ path = _os.path.join(dirpath, filename)
+ if _os.path.sep != '/':
+ path = path.replace(_os.path.sep, '/')
+ yield path
+
+
+_setup(
+ name=package_name,
+ version=__version__,
+ maintainer='Gentoo Release Engineering',
+ maintainer_email='releng@gentoo.org',
+ url='http://www.gentoo.org/proj/en/releng/{0}/'.format(package_name),
+ download_url='http://git.overlays.gentoo.org/gitweb/?p=proj/{0}.git;a=snapshot;h={1};sf=tgz'.format(package_name, tag),
+ 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 :: 2',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ ],
+ scripts=['bin/{0}'.format(package_name)],
+ packages=[
+ package_name,
+ '{0}.arch'.format(package_name),
+ '{0}.base'.format(package_name),
+ '{0}.targets'.format(package_name),
+ ],
+ data_files=[
+ ('/etc/catalyst', [
+ 'etc/catalyst.conf',
+ 'etc/catalystrc',
+ ]),
+ ('lib/catalyst/', list(_itertools.chain(
+ files('livecd'),
+ files('targets'),
+ ))),
+ ],
+ provides=[package_name],
+ )
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/catalyst:rewrite-on-master commit in: catalyst/, /
@ 2013-11-22 7:13 Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2013-11-22 7:13 UTC (permalink / raw
To: gentoo-commits
commit: 1ff4b0d5ad73bcd43c7939b1001aea5597330e8f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 6 15:57:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Nov 22 06:02:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=1ff4b0d5
Add set_version command to setup.py.
* Add/modify functions to save and retrieve the set version
information or the live git version.
* Change indent to tabs.
---
catalyst/__init__.py | 7 ++++++-
catalyst/version.py | 44 +++++++++++++++++++++++++++++++++++++++++---
setup.py | 38 ++++++++++++++++++++++++++++++++++++--
3 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/catalyst/__init__.py b/catalyst/__init__.py
index c2538aa..c9c2eab 100644
--- a/catalyst/__init__.py
+++ b/catalyst/__init__.py
@@ -1,3 +1,8 @@
"Catalyst is a release building tool used by Gentoo Linux"
-from .version import __version__
+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)
diff --git a/catalyst/version.py b/catalyst/version.py
index 03c77e4..d379d35 100644
--- a/catalyst/version.py
+++ b/catalyst/version.py
@@ -10,14 +10,52 @@
'''Version information and/or git version information
'''
+import os
+
from snakeoil.version import format_version
__version__="rewrite-git"
_ver = None
-def get_version():
+
+def get_git_version(version=__version__):
"""Return: a string describing our version."""
global _ver
- if _ver is None:
- _ver = format_version('catalyst',__file__, __version__)
+ _ver = format_version('catalyst',__file__, version)
return _ver
+
+
+def get_version(reset=False):
+ '''Returns a saved release version string or the
+ generated git release version.
+ '''
+ 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/setup.py b/setup.py
old mode 100644
new mode 100755
index 34eae53..f585b99
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,5 @@
+#!/usr/bin/python2 -OO
+
# Copyright (C) 2013 W. Trevor King <wking@tremily.us>
#
# This program is free software: you can redistribute it and/or modify
@@ -13,14 +15,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-"Catalyst is a release building tool used by Gentoo Linux"
+"""Catalyst is a release building tool used by Gentoo Linux"""
+
+# py2.6 compatibility
+from __future__ import print_function
import codecs as _codecs
-from distutils.core import setup as _setup
+from distutils.core import setup as _setup, Command as _Command
import itertools as _itertools
import os as _os
from catalyst import __version__
+from catalyst.version import set_release_version as _set_release_version
+from catalyst.version import get_version as _get_version
_this_dir = _os.path.dirname(__file__)
@@ -44,6 +51,30 @@ def files(root):
yield path
+class set_version(_Command):
+ '''Saves the specified release version information
+ '''
+ global __version__
+ 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):
+ 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__,
@@ -86,4 +117,7 @@ _setup(
))),
],
provides=[package_name],
+ cmdclass={
+ 'set_version': set_version
+ },
)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-22 7:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-22 7:13 [gentoo-commits] proj/catalyst:rewrite-on-master commit in: catalyst/, / Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2013-11-22 7:13 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox