<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<br>
<div class="moz-cite-prefix">On 05/09/17 17:41, Cédric Bosdonnat
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20170905164124.11973-7-cbosdonnat@suse.com">
<pre wrap="">Clean up the file, tell the world we are now stable enough, generate
ChangeLog and AUTHORS files and add license header.
---
AUTHORS.in | 12 +++++++
setup.py | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 111 insertions(+), 20 deletions(-)
create mode 100644 AUTHORS.in
diff --git a/AUTHORS.in b/AUTHORS.in
new file mode 100644
index 0000000..9a57532
--- /dev/null
+++ b/AUTHORS.in
@@ -0,0 +1,12 @@
+ virt-boostrap Authors
+ ==============================
+
+The virt-bootstrap tool is maintained by the
+virt-manager development team, who can be contacted
+at
+
+ <a class="moz-txt-link-abbreviated" href="mailto:virt-tools-list@redhat.com">virt-tools-list@redhat.com</a>
+
+The individual contributors are
+
+@AUTHORS@
diff --git a/setup.py b/setup.py
index 1ed852f..d2a0c8b 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8; -*-
+# Authors: Cedric Bosdonnat <a class="moz-txt-link-rfc2396E" href="mailto:cbosdonnat@suse.com"><cbosdonnat@suse.com></a>
+# Authors: Radostin Stoyanov <a class="moz-txt-link-rfc2396E" href="mailto:rstoyanov1@gmail.com"><rstoyanov1@gmail.com></a>
+#
+# Copyright (C) 2017 SUSE, Inc.
+# Copyright (C) 2017 Radostin Stoyanov
+#
+# 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 3 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 <a class="moz-txt-link-rfc2396E" href="http://www.gnu.org/licenses/"><http://www.gnu.org/licenses/></a>.
"""
Setup script used for building, testing, and installing modules
@@ -8,8 +26,10 @@ based on setuptools.
import codecs
import os
+import re
import sys
import subprocess
+import time
import setuptools
from setuptools.command.install import install
from setuptools.command.sdist import sdist</pre>
</blockquote>
^^ This import statement should be added in this patch (not in patch
3).<br>
<blockquote type="cite"
cite="mid:20170905164124.11973-7-cbosdonnat@suse.com">
<pre wrap="">@@ -91,6 +111,78 @@ class CheckPylint(setuptools.Command):
sys.exit(res)
+# SdistCommand is reused from the libvirt python binding (GPLv2+)
+class SdistCommand(sdist):
+ """
+ Custom sdist command, generating a few files.
+ """
+ user_options = sdist.user_options
+
+ description = "Update AUTHORS and ChangeLog; build sdist-tarball."
+
+ def gen_authors(self):
+ """
+ Generate AUTHOS file out of git log
+ """
+ fdlog = os.popen("git log --pretty=format:'%aN <%aE>'")
+ authors = []
+ for line in fdlog:
+ line = " " + line.strip()
+ if line not in authors:
+ authors.append(line)
+
+ authors.sort(key=str.lower)
+
+ fd1 = open('AUTHORS.in', 'r')
+ fd2 = open('AUTHORS', 'w')
+ for line in fd1:
+ fd2.write(line.replace('@AUTHORS@', "\n".join(authors)))
+ fd1.close()
+ fd2.close()
+</pre>
</blockquote>
Here we can use the "with" statement<br>
<br>
with open('AUTHORS.in', 'r') as fd1, open('AUTHORS', 'w') as fd2:<br>
for line in fd1:<br>
fd2.write(line.replace('@AUTHORS@', "\n".join(authors)))<br>
<br>
For more info see:<br>
-
<a class="moz-txt-link-freetext"
href="https://docs.python.org/2/reference/datamodel.html#with-statement-context-managers">https://docs.python.org/2/reference/datamodel.html#with-statement-context-managers</a><br>
- <a class="moz-txt-link-freetext"
href="https://www.python.org/dev/peps/pep-0343">https://www.python.org/dev/peps/pep-0343</a><br>
<blockquote type="cite"
cite="mid:20170905164124.11973-7-cbosdonnat@suse.com">
<pre wrap="">+
+ def gen_changelog(self):
+ """
+ Generate ChangeLog file out of git log
+ """
+ fd1 = os.popen("git log '--pretty=format:%H:%ct %an <%ae>%n%n%s%n%b%n'")
+ fd2 = open("ChangeLog", 'w')
+
+ for line in fd1:
+ match = re.match(r'([a-f0-9]+):(\d+)\s(.*)', line)
+ if match:
+ timestamp = time.gmtime(int(match.group(2)))
+ fd2.write("%04d-%02d-%02d %s\n" % (timestamp.tm_year,
+ timestamp.tm_mon,
+ timestamp.tm_mday, match.group(3)))
+ else:
+ if re.match(r'Signed-off-by', line):
+ continue
+ fd2.write(" " + line.strip() + "\n")
+
+ fd1.close()
+ fd2.close()
+
+
+ def run(self):
+ if not os.path.exists("build"):
+ os.mkdir("build")
+
+ if os.path.exists(".git"):
+ try:
+ self.gen_authors()
+ self.gen_changelog()
+
+ sdist.run(self)
+
+ finally:
+ files = ["AUTHORS",
+ "ChangeLog"]
+ for file in files:
+ if os.path.exists(file):
+ os.unlink(file)
+ else:
+ sdist.run(self)
</pre>
</blockquote>
AFAIK the idea is to generate ChangeLog and AUTHORS files which are
included in the "dist/virt-bootstrap-0.1.0.tar.gz" archive and then
these files are deleted.<br>
However, for this work we need to include "ChangeLog" and "AUTHORS"
in the MANIFEST.in file.<br>
<blockquote type="cite"
cite="mid:20170905164124.11973-7-cbosdonnat@suse.com">
<pre wrap="">
setuptools.setup(
name='virt-bootstrap',
@@ -98,10 +190,9 @@ setuptools.setup(
author='Cedric Bosdonnat',
author_email='<a class="moz-txt-link-abbreviated" href="mailto:cbosdonnat@suse.com">cbosdonnat@suse.com</a>',
description='Container bootstrapping tool',
- license="GPLv3",
+ license="GPLv3+",
long_description=read('README.md'),
url='<a class="moz-txt-link-freetext" href="https://github.com/virt-manager/virt-bootstrap">https://github.com/virt-manager/virt-bootstrap</a>',
- # What does your project relate to?
keywords='virtualization container rootfs',
packages=setuptools.find_packages(),
test_suite='tests',
@@ -111,30 +202,18 @@ setuptools.setup(
]
},
classifiers=[
- # How mature is this project? Common values are
- # 3 - Alpha
- # 4 - Beta
- # 5 - Production/Stable
- 'Development Status :: 3 - Alpha',
-
- # Indicate who your project is intended for
+ 'Development Status :: 5 - Production/Stable',
'Intended Audience :: System Administrators',
'Intended Audience :: Developers',
-
- # Pick your license as you wish (should match "license" above)
- 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
-
- # Specify the Python versions you support here. In particular, ensure
- # that you indicate whether you support Python 2, Python 3 or both.
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6'
+ 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 3',
],
cmdclass={
'install': PostInstallCommand,
- 'pylint': CheckPylint
+ 'pylint': CheckPylint,
+ 'sdist': SdistCommand
},
data_files=[
</pre>
</blockquote>
<br>
There are a few errors from pylint which need to be fixed.<br>
<br>
ACK with the above-mentioned changes<br>
</body>
</html>