Menu

[9ff791]: / setup.py  Maximize  Restore  History

Download this file

151 lines (128 with data), 6.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# setup.py --- Setup script for pythondialog
# Copyright (c) 2002-2019 Florent Rougon
#
# This file is part of pythondialog.
#
# pythondialog is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# pythondialog 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301 USA.
import os, sys, subprocess, traceback
from setuptools import setup
PACKAGE = "pythondialog"
# This is OK because dialog.py has no dependency outside the standard library.
from dialog import __version__ as VERSION
def run_gitlog_to_changelog(after_this_commit, output=None):
args = [ "gitlog-to-changelog", "--format=%s%n%n%b%n", "--",
"{0}..".format(after_this_commit) ]
try:
subprocess.check_call(args, stdout=output)
except os.error:
print(traceback.format_exc(), file=sys.stderr)
print("""\
Error (see above for a traceback): unable to run {prg}
================================================={underlining}
Maybe this program is not installed on your system. You can download it from:
{url}
Note: if you have problems with the infamous shell+Perl crap in the first lines
of that file, you can replace it with a simple shebang line such as
"#! /usr/bin/perl".""".format(
prg=args[0],
underlining="=" * len(args[0]),
url="https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;"
"f=build-aux/gitlog-to-changelog"), file=sys.stderr)
sys.exit(1)
def generate_changelog(ch_name, write_to_stdout=False):
print("Converting the Git log into ChangeLog format...", end=' ',
file=sys.stderr)
orig_ch_name = "{0}.init".format(ch_name)
# Most recent commit in the file referenced by 'orig_ch_name' (normally,
# ChangeLog.init)
last_commit_in_ch_init = "df4f82a63cc11f9ba389810e1a913c97a8fa5029"
if write_to_stdout:
run_gitlog_to_changelog(last_commit_in_ch_init)
with open(orig_ch_name, "r", encoding="utf-8") as orig_ch:
# Make sure the output is encoded in UTF-8
sys.stdout.buffer.write(("\n" + orig_ch.read()).encode("utf-8"))
else:
tmp_ch_name = "{0}.new".format(ch_name)
try:
with open(tmp_ch_name, "w", encoding="utf-8") as tmp_ch:
run_gitlog_to_changelog(last_commit_in_ch_init, output=tmp_ch)
with open(orig_ch_name, "r", encoding="utf-8") as orig_ch:
tmp_ch.write("\n" + orig_ch.read())
os.rename(tmp_ch_name, ch_name)
finally:
if os.path.exists(tmp_ch_name):
os.unlink(tmp_ch_name)
print("done.", file=sys.stderr)
def main():
ch_name = "ChangeLog"
if os.path.isdir(".git"):
generate_changelog(ch_name)
elif not os.path.isfile(ch_name):
msg = """\
There is no {cl!r} file here and it seems you are not operating from a
clone of the Git repository (no .git directory); therefore, it is impossible to
generate the {cl!r} file from the Git log. Aborting.""".format(cl=ch_name)
sys.exit(msg)
with open("README.rst", "r", encoding="utf-8") as f:
long_description = f.read()
setup(name=PACKAGE,
version=VERSION,
description="A Python interface to the UNIX dialog utility and "
"mostly-compatible programs",
# According to
# <https://packaging.python.org/specifications/core-metadata/> and
# the rendering on PyPI, it appears that only the original author can
# be listed in 'author'. See the AUTHORS file for other contributors.
author="Robb Shecter",
author_email="robb@acm.org",
maintainer="Florent Rougon",
maintainer_email="f.rougon@free.fr",
url="https://pythondialog.sourceforge.io/",
project_urls={
"Documentation": "https://pythondialog.sourceforge.io/doc/",
"SourceForge project page":
"https://sourceforge.net/projects/pythondialog",
"Git repository": "https://sourceforge.net/p/pythondialog/code/",
"Mailing list": "https://sourceforge.net/p/pythondialog/mailman/",
"Issue tracker":
"https://sourceforge.net/p/pythondialog/_list/tickets",
},
long_description=long_description,
long_description_content_type="text/x-rst",
keywords="dialog,ncurses,Xdialog,text-mode interface,terminal",
# Well, there isn't much UNIX-specific code in dialog.py, if at all.
# I am putting Unix here only because of the dialog dependency...
# Note: using the "Unix" case instead of "UNIX", because it is
# spelled this way in Trove classifiers. This argument should be
# unneeded given the Trove classifers, however omitting it leads to
# an ugly 'Platform: UNKNOWN' in pythondialog.egg-info/PKG-INFO.
platforms=["Unix"],
classifiers=[
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Environment :: Console :: Curses",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or Lesser General Public "
"License (LGPL)",
"Operating System :: Unix",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: User Interfaces",
"Topic :: Software Development :: Widget Sets"],
py_modules=["dialog"],
python_requires=">=3")
if __name__ == "__main__": main()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.