We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ttx] Flexible manual page install directory 
https://sourceforge.net/p/fonttools/bugs/51/

"""
The BSDs are patching setup.py during their build process so that they get the manual page installed in /usr/man instead of /usr/share/man. The setup.py script should either know where to install manual pages on BSD or have a --mandir argument that can be used to set the right directory for the manual page. 
"""


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 #! /usr/bin/env python
2 
3 from __future__ import print_function
4 import io
5 import sys
6 from setuptools import setup, find_packages, Command
7 from distutils import log
8 import subprocess as sp
9 import contextlib
10 
11 # Force distutils to use py_compile.compile() function with 'doraise' argument
12 # set to True, in order to raise an exception on compilation errors
13 import py_compile
14 orig_py_compile = py_compile.compile
15 
16 def doraise_py_compile(file, cfile=None, dfile=None, doraise=False):
17 	orig_py_compile(file, cfile=cfile, dfile=dfile, doraise=True)
18 
19 py_compile.compile = doraise_py_compile
20 
21 needs_pytest = {'pytest', 'test'}.intersection(sys.argv)
22 pytest_runner = ['pytest_runner'] if needs_pytest else []
23 needs_wheel = {'bdist_wheel'}.intersection(sys.argv)
24 wheel = ['wheel'] if needs_wheel else []
25 needs_bumpversion = {'release'}.intersection(sys.argv)
26 bumpversion = ['bumpversion'] if needs_bumpversion else []
27 
28 # Trove classifiers for PyPI
29 classifiers = {"classifiers": [
30 	"Development Status :: 5 - Production/Stable",
31 	"Environment :: Console",
32 	"Environment :: Other Environment",
33 	"Intended Audience :: Developers",
34 	"Intended Audience :: End Users/Desktop",
35 	"License :: OSI Approved :: BSD License",
36 	"Natural Language :: English",
37 	"Operating System :: OS Independent",
38 	"Programming Language :: Python",
39 	"Programming Language :: Python :: 2",
40 	"Programming Language :: Python :: 3",
41 	"Topic :: Text Processing :: Fonts",
42 	"Topic :: Multimedia :: Graphics",
43 	"Topic :: Multimedia :: Graphics :: Graphics Conversion",
44 ]}
45 
46 long_description = """\
47 FontTools/TTX is a library to manipulate font files from Python.
48 It supports reading and writing of TrueType/OpenType fonts, reading
49 and writing of AFM files, reading (and partially writing) of PS Type 1
50 fonts. The package also contains a tool called "TTX" which converts
51 TrueType/OpenType fonts to and from an XML-based format.
52 """
53 
54 
55 @contextlib.contextmanager
56 def capture_logger(name):
57 	""" Context manager to capture a logger output with a StringIO stream.
58 	"""
59 	import logging
60 
61 	logger = logging.getLogger(name)
62 	try:
63 		import StringIO
64 		stream = StringIO.StringIO()
65 	except ImportError:
66 		stream = io.StringIO()
67 	handler = logging.StreamHandler(stream)
68 	logger.addHandler(handler)
69 	try:
70 		yield stream
71 	finally:
72 		logger.removeHandler(handler)
73 
74 
75 class release(Command):
76 	"""
77 	Tag a new release with a single command, using the 'bumpversion' tool
78 	to update all the version strings in the source code.
79 	The version scheme conforms to 'SemVer' and PEP 440 specifications.
80 
81 	Firstly, the pre-release '.devN' suffix is dropped to signal that this is
82 	a stable release. If '--major' or '--minor' options are passed, the
83 	the first or second 'semver' digit is also incremented. Major is usually
84 	for backward-incompatible API changes, while minor is used when adding
85 	new backward-compatible functionalities. No options imply 'patch' or bug-fix
86 	release.
87 
88 	A new header is also added to the changelog file ("NEWS"), containing the
89 	new version string and the current 'YYYY-MM-DD' date.
90 
91 	All changes are committed, and an annotated git tag is generated. With the
92 	--sign option, the tag is GPG-signed with the user's default key.
93 
94 	Finally, the 'patch' part of the version string is bumped again, and a
95 	pre-release suffix '.dev0' is appended to mark the opening of a new
96 	development cycle.
97 
98 	Links:
99 	- http://semver.org/
100 	- https://www.python.org/dev/peps/pep-0440/
101 	- https://github.com/peritus/bumpversion
102 	"""
103 
104 	description = "update version strings for release"
105 
106 	user_options = [
107 		("major", None, "bump the first digit (incompatible API changes)"),
108 		("minor", None, "bump the second digit (new backward-compatible features)"),
109 		("sign", "s", "make a GPG-signed tag, using the default key"),
110 		("allow-dirty", None, "don't abort if working directory is dirty"),
111 	]
112 
113 	changelog_name = "NEWS"
114 	changelog_header = u"## TTX/FontTools Version "
115 	changelog_date_fmt = "%Y-%m-%d"
116 	commit_message = "Release {new_version}"
117 	tag_name = "{new_version}"
118 	version_files = [
119 		"setup.cfg",
120 		"setup.py",
121 		"Lib/fontTools/__init__.py",
122 	]
123 
124 	def initialize_options(self):
125 		self.minor = False
126 		self.major = False
127 		self.sign = False
128 		self.allow_dirty = False
129 
130 	def finalize_options(self):
131 		if all([self.major, self.minor]):
132 			from distutils.errors import DistutilsOptionError
133 			raise DistutilsOptionError("--major/--minor are mutually exclusive")
134 		self.part = "major" if self.major else "minor" if self.minor else None
135 
136 	def run(self):
137 		if self.part is not None:
138 			log.info("bumping '%s' version" % self.part)
139 			self.bumpversion(self.part, commit=False)
140 			release_version = self.bumpversion(
141 				"release", commit=False, allow_dirty=True)
142 		else:
143 			log.info("stripping pre-release suffix")
144 			release_version = self.bumpversion("release")
145 		log.info("  version = %s" % release_version)
146 
147 		changes = self.format_changelog(release_version)
148 
149 		self.git_commit(release_version)
150 		self.git_tag(release_version, changes, self.sign)
151 
152 		log.info("bumping 'patch' version and pre-release suffix")
153 		next_dev_version = self.bumpversion('patch', commit=True)
154 		log.info("  version = %s" % next_dev_version)
155 
156 	def git_commit(self, version):
157 		""" Stage and commit all relevant version files, and format the commit
158 		message with specified 'version' string.
159 		"""
160 		files = self.version_files + [self.changelog_name]
161 
162 		log.info("committing changes")
163 		for f in files:
164 			log.info("  %s" % f)
165 		if self.dry_run:
166 			return
167 		sp.check_call(["git", "add"] + files)
168 		msg = self.commit_message.format(new_version=version)
169 		sp.check_call(["git", "commit", "-m", msg], stdout=sp.PIPE)
170 
171 	def git_tag(self, version, message, sign=False):
172 		""" Create annotated git tag with given 'version' and 'message'.
173 		Optionally 'sign' the tag with the user's GPG key.
174 		"""
175 		log.info("creating %s git tag '%s'" % (
176 			"signed" if sign else "annotated", version))
177 		if self.dry_run:
178 			return
179 		# create an annotated (or signed) tag from the new version
180 		tag_opt = "-s" if sign else "-a"
181 		tag_name = self.tag_name.format(new_version=version)
182 		proc = sp.Popen(
183 			["git", "tag", tag_opt, "-F", "-", tag_name], stdin=sp.PIPE)
184 		# use the latest changes from the changelog file as the tag message
185 		tag_message = u"%s\n\n%s" % (tag_name, message)
186 		proc.communicate(tag_message.encode('utf-8'))
187 		if proc.returncode != 0:
188 			sys.exit(proc.returncode)
189 
190 	def bumpversion(self, part, commit=False, message=None, allow_dirty=None):
191 		""" Run bumpversion.main() with the specified arguments, and return the
192 		new computed version string (cf. 'bumpversion --help' for more info)
193 		"""
194 		import bumpversion
195 
196 		args = (
197 			(['--verbose'] if self.verbose > 1 else []) +
198 			(['--dry-run'] if self.dry_run else []) +
199 			(['--allow-dirty'] if (allow_dirty or self.allow_dirty) else []) +
200 			(['--commit'] if commit else ['--no-commit']) +
201 			(['--message', message] if message is not None else []) +
202 			['--list', part]
203 		)
204 		log.debug("$ bumpversion %s" % " ".join(a.replace(" ", "\\ ") for a in args))
205 
206 		with capture_logger("bumpversion.list") as out:
207 			bumpversion.main(args)
208 
209 		last_line = out.getvalue().splitlines()[-1]
210 		new_version = last_line.replace("new_version=", "")
211 		return new_version
212 
213 	def format_changelog(self, version):
214 		""" Write new header at beginning of changelog file with the specified
215 		'version' and the current date.
216 		Return the changelog content for the current release.
217 		"""
218 		from datetime import datetime
219 
220 		log.info("formatting changelog")
221 
222 		changes = []
223 		with io.open(self.changelog_name, "r+", encoding="utf-8") as f:
224 			for ln in f:
225 				if ln.startswith(self.changelog_header):
226 					break
227 				else:
228 					changes.append(ln)
229 			if not self.dry_run:
230 				f.seek(0)
231 				content = f.read()
232 				f.seek(0)
233 				f.write(u"%s%s\n\n%s\n\n%s" % (
234 					self.changelog_header,
235 					version,
236 					datetime.today().strftime(self.changelog_date_fmt),
237 					content))
238 
239 		return u"".join(changes)
240 
241 
242 class PassCommand(Command):
243 	""" This is used with Travis `dpl` tool so that it skips creating sdist
244 	and wheel packages, but simply uploads to PyPI the files found in ./dist
245 	folder, that were previously built inside the tox 'bdist' environment.
246 	This ensures that the same files are uploaded to Github Releases and PyPI.
247 	"""
248 
249 	description = "do nothing"
250 	user_options = []
251 
252 	def initialize_options(self):
253 		pass
254 
255 	def finalize_options(self):
256 		pass
257 
258 	def run(self):
259 		pass
260 
261 
262 setup(
263 	name="fonttools",
264 	version="3.5.0.dev0",
265 	description="Tools to manipulate font files",
266 	author="Just van Rossum",
267 	author_email="just@letterror.com",
268 	maintainer="Behdad Esfahbod",
269 	maintainer_email="behdad@behdad.org",
270 	url="http://github.com/fonttools/fonttools",
271 	license="OpenSource, BSD-style",
272 	platforms=["Any"],
273 	long_description=long_description,
274 	package_dir={'': 'Lib'},
275 	packages=find_packages("Lib"),
276 	include_package_data=True,
277 	data_files=[
278 		('share/man/man1', ["Doc/ttx.1"])
279 	] if sys.platform.startswith('linux') else [],
280 	setup_requires=pytest_runner + wheel + bumpversion,
281 	tests_require=[
282 		'pytest>=2.8',
283 	],
284 	entry_points={
285 		'console_scripts': [
286 			"fonttools = fontTools.__main__:main",
287 			"ttx = fontTools.ttx:main",
288 			"pyftsubset = fontTools.subset:main",
289 			"pyftmerge = fontTools.merge:main",
290 			"pyftinspect = fontTools.inspect:main"
291 		]
292 	},
293 	cmdclass={
294 		"release": release,
295 		'pass': PassCommand,
296 	},
297 	**classifiers
298 )
299
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -3,8 +3,12 @@
 from __future__ import print_function
 import io
 import sys
+import os
+from os.path import isfile, join as pjoin
+from glob import glob
 from setuptools import setup, find_packages, Command
 from distutils import log
+from distutils.util import convert_path
 import subprocess as sp
 import contextlib
 
@@ -259,6 +263,49 @@
 		pass
 
 
+def find_data_files(manpath="share/man"):
+	""" Find FontTools's data_files (just man pages at this point).
+
+	By default, we install man pages to "share/man" directory relative to the
+	base installation directory for data_files. The latter can be changed with
+	the --install-data option of 'setup.py install' sub-command.
+
+	E.g., if the data files installation directory is "/usr", the default man
+	page installation directory will be "/usr/share/man".
+
+	You can override this via the $FONTTOOLS_MANPATH environment variable.
+
+	E.g., on some BSD systems man pages are installed to 'man' instead of
+	'share/man'; you can export $FONTTOOLS_MANPATH variable just before
+	installing:
+
+	$ FONTTOOLS_MANPATH="man" pip install -v .
+	    [...]
+	    running install_data
+	    copying Doc/man/ttx.1 -> /usr/man/man1
+
+	When installing from PyPI, for this variable to have effect you need to
+	force pip to install from the source distribution instead of the wheel
+	package (otherwise setup.py is not run), by using the --no-binary option:
+
+	$ FONTTOOLS_MANPATH="man" pip install --no-binary=fonttools fonttools
+
+	Note that you can only override the base man path, i.e. without the
+	section number (man1, man3, etc.). The latter is always implied to be 1,
+	for "general commands".
+	"""
+
+	# get base installation directory for man pages
+	manpagebase = os.environ.get('FONTTOOLS_MANPATH', convert_path(manpath))
+	# all our man pages go to section 1
+	manpagedir = pjoin(manpagebase, 'man1')
+
+	manpages = [f for f in glob(pjoin('Doc', 'man', 'man1', '*.1')) if isfile(f)]
+
+	data_files = [(manpagedir, manpages)]
+	return data_files
+
+
 setup(
 	name="fonttools",
 	version="3.5.0.dev0",
@@ -274,9 +321,7 @@
 	package_dir={'': 'Lib'},
 	packages=find_packages("Lib"),
 	include_package_data=True,
-	data_files=[
-		('share/man/man1', ["Doc/ttx.1"])
-	] if sys.platform.startswith('linux') else [],
+	data_files=find_data_files(),
 	setup_requires=pytest_runner + wheel + bumpversion,
 	tests_require=[
 		'pytest>=2.8',

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -3,8 +3,12 @@\n from __future__ import print_function\n import io\n import sys\n+import os\n+from os.path import isfile, join as pjoin\n+from glob import glob\n from setuptools import setup, find_packages, Command\n from distutils import log\n+from distutils.util import convert_path\n import subprocess as sp\n import contextlib\n \n@@ -259,6 +263,49 @@\n \t\tpass\n \n \n+def find_data_files(manpath=\"share/man\"):\n+\t\"\"\" Find FontTools's data_files (just man pages at this point).\n+\n+\tBy default, we install man pages to \"share/man\" directory relative to the\n+\tbase installation directory for data_files. The latter can be changed with\n+\tthe --install-data option of 'setup.py install' sub-command.\n+\n+\tE.g., if the data files installation directory is \"/usr\", the default man\n+\tpage installation directory will be \"/usr/share/man\".\n+\n+\tYou can override this via the $FONTTOOLS_MANPATH environment variable.\n+\n+\tE.g., on some BSD systems man pages are installed to 'man' instead of\n+\t'share/man'; you can export $FONTTOOLS_MANPATH variable just before\n+\tinstalling:\n+\n+\t$ FONTTOOLS_MANPATH=\"man\" pip install -v .\n+\t    [...]\n+\t    running install_data\n+\t    copying Doc/man/ttx.1 -> /usr/man/man1\n+\n+\tWhen installing from PyPI, for this variable to have effect you need to\n+\tforce pip to install from the source distribution instead of the wheel\n+\tpackage (otherwise setup.py is not run), by using the --no-binary option:\n+\n+\t$ FONTTOOLS_MANPATH=\"man\" pip install --no-binary=fonttools fonttools\n+\n+\tNote that you can only override the base man path, i.e. without the\n+\tsection number (man1, man3, etc.). The latter is always implied to be 1,\n+\tfor \"general commands\".\n+\t\"\"\"\n+\n+\t# get base installation directory for man pages\n+\tmanpagebase = os.environ.get('FONTTOOLS_MANPATH', convert_path(manpath))\n+\t# all our man pages go to section 1\n+\tmanpagedir = pjoin(manpagebase, 'man1')\n+\n+\tmanpages = [f for f in glob(pjoin('Doc', 'man', 'man1', '*.1')) if isfile(f)]\n+\n+\tdata_files = [(manpagedir, manpages)]\n+\treturn data_files\n+\n+\n setup(\n \tname=\"fonttools\",\n \tversion=\"3.5.0.dev0\",\n@@ -274,9 +321,7 @@\n \tpackage_dir={'': 'Lib'},\n \tpackages=find_packages(\"Lib\"),\n \tinclude_package_data=True,\n-\tdata_files=[\n-\t\t('share/man/man1', [\"Doc/ttx.1\"])\n-\t] if sys.platform.startswith('linux') else [],\n+\tdata_files=find_data_files(),\n \tsetup_requires=pytest_runner + wheel + bumpversion,\n \ttests_require=[\n \t\t'pytest>=2.8',\n", "issue": "[ttx] Flexible manual page install directory \nhttps://sourceforge.net/p/fonttools/bugs/51/\n\n\"\"\"\nThe BSDs are patching setup.py during their build process so that they get the manual page installed in /usr/man instead of /usr/share/man. The setup.py script should either know where to install manual pages on BSD or have a --mandir argument that can be used to set the right directory for the manual page. \n\"\"\"\n\n", "before_files": [{"content": "#! /usr/bin/env python\n\nfrom __future__ import print_function\nimport io\nimport sys\nfrom setuptools import setup, find_packages, Command\nfrom distutils import log\nimport subprocess as sp\nimport contextlib\n\n# Force distutils to use py_compile.compile() function with 'doraise' argument\n# set to True, in order to raise an exception on compilation errors\nimport py_compile\norig_py_compile = py_compile.compile\n\ndef doraise_py_compile(file, cfile=None, dfile=None, doraise=False):\n\torig_py_compile(file, cfile=cfile, dfile=dfile, doraise=True)\n\npy_compile.compile = doraise_py_compile\n\nneeds_pytest = {'pytest', 'test'}.intersection(sys.argv)\npytest_runner = ['pytest_runner'] if needs_pytest else []\nneeds_wheel = {'bdist_wheel'}.intersection(sys.argv)\nwheel = ['wheel'] if needs_wheel else []\nneeds_bumpversion = {'release'}.intersection(sys.argv)\nbumpversion = ['bumpversion'] if needs_bumpversion else []\n\n# Trove classifiers for PyPI\nclassifiers = {\"classifiers\": [\n\t\"Development Status :: 5 - Production/Stable\",\n\t\"Environment :: Console\",\n\t\"Environment :: Other Environment\",\n\t\"Intended Audience :: Developers\",\n\t\"Intended Audience :: End Users/Desktop\",\n\t\"License :: OSI Approved :: BSD License\",\n\t\"Natural Language :: English\",\n\t\"Operating System :: OS Independent\",\n\t\"Programming Language :: Python\",\n\t\"Programming Language :: Python :: 2\",\n\t\"Programming Language :: Python :: 3\",\n\t\"Topic :: Text Processing :: Fonts\",\n\t\"Topic :: Multimedia :: Graphics\",\n\t\"Topic :: Multimedia :: Graphics :: Graphics Conversion\",\n]}\n\nlong_description = \"\"\"\\\nFontTools/TTX is a library to manipulate font files from Python.\nIt supports reading and writing of TrueType/OpenType fonts, reading\nand writing of AFM files, reading (and partially writing) of PS Type 1\nfonts. The package also contains a tool called \"TTX\" which converts\nTrueType/OpenType fonts to and from an XML-based format.\n\"\"\"\n\n\n@contextlib.contextmanager\ndef capture_logger(name):\n\t\"\"\" Context manager to capture a logger output with a StringIO stream.\n\t\"\"\"\n\timport logging\n\n\tlogger = logging.getLogger(name)\n\ttry:\n\t\timport StringIO\n\t\tstream = StringIO.StringIO()\n\texcept ImportError:\n\t\tstream = io.StringIO()\n\thandler = logging.StreamHandler(stream)\n\tlogger.addHandler(handler)\n\ttry:\n\t\tyield stream\n\tfinally:\n\t\tlogger.removeHandler(handler)\n\n\nclass release(Command):\n\t\"\"\"\n\tTag a new release with a single command, using the 'bumpversion' tool\n\tto update all the version strings in the source code.\n\tThe version scheme conforms to 'SemVer' and PEP 440 specifications.\n\n\tFirstly, the pre-release '.devN' suffix is dropped to signal that this is\n\ta stable release. If '--major' or '--minor' options are passed, the\n\tthe first or second 'semver' digit is also incremented. Major is usually\n\tfor backward-incompatible API changes, while minor is used when adding\n\tnew backward-compatible functionalities. No options imply 'patch' or bug-fix\n\trelease.\n\n\tA new header is also added to the changelog file (\"NEWS\"), containing the\n\tnew version string and the current 'YYYY-MM-DD' date.\n\n\tAll changes are committed, and an annotated git tag is generated. With the\n\t--sign option, the tag is GPG-signed with the user's default key.\n\n\tFinally, the 'patch' part of the version string is bumped again, and a\n\tpre-release suffix '.dev0' is appended to mark the opening of a new\n\tdevelopment cycle.\n\n\tLinks:\n\t- http://semver.org/\n\t- https://www.python.org/dev/peps/pep-0440/\n\t- https://github.com/peritus/bumpversion\n\t\"\"\"\n\n\tdescription = \"update version strings for release\"\n\n\tuser_options = [\n\t\t(\"major\", None, \"bump the first digit (incompatible API changes)\"),\n\t\t(\"minor\", None, \"bump the second digit (new backward-compatible features)\"),\n\t\t(\"sign\", \"s\", \"make a GPG-signed tag, using the default key\"),\n\t\t(\"allow-dirty\", None, \"don't abort if working directory is dirty\"),\n\t]\n\n\tchangelog_name = \"NEWS\"\n\tchangelog_header = u\"## TTX/FontTools Version \"\n\tchangelog_date_fmt = \"%Y-%m-%d\"\n\tcommit_message = \"Release {new_version}\"\n\ttag_name = \"{new_version}\"\n\tversion_files = [\n\t\t\"setup.cfg\",\n\t\t\"setup.py\",\n\t\t\"Lib/fontTools/__init__.py\",\n\t]\n\n\tdef initialize_options(self):\n\t\tself.minor = False\n\t\tself.major = False\n\t\tself.sign = False\n\t\tself.allow_dirty = False\n\n\tdef finalize_options(self):\n\t\tif all([self.major, self.minor]):\n\t\t\tfrom distutils.errors import DistutilsOptionError\n\t\t\traise DistutilsOptionError(\"--major/--minor are mutually exclusive\")\n\t\tself.part = \"major\" if self.major else \"minor\" if self.minor else None\n\n\tdef run(self):\n\t\tif self.part is not None:\n\t\t\tlog.info(\"bumping '%s' version\" % self.part)\n\t\t\tself.bumpversion(self.part, commit=False)\n\t\t\trelease_version = self.bumpversion(\n\t\t\t\t\"release\", commit=False, allow_dirty=True)\n\t\telse:\n\t\t\tlog.info(\"stripping pre-release suffix\")\n\t\t\trelease_version = self.bumpversion(\"release\")\n\t\tlog.info(\"  version = %s\" % release_version)\n\n\t\tchanges = self.format_changelog(release_version)\n\n\t\tself.git_commit(release_version)\n\t\tself.git_tag(release_version, changes, self.sign)\n\n\t\tlog.info(\"bumping 'patch' version and pre-release suffix\")\n\t\tnext_dev_version = self.bumpversion('patch', commit=True)\n\t\tlog.info(\"  version = %s\" % next_dev_version)\n\n\tdef git_commit(self, version):\n\t\t\"\"\" Stage and commit all relevant version files, and format the commit\n\t\tmessage with specified 'version' string.\n\t\t\"\"\"\n\t\tfiles = self.version_files + [self.changelog_name]\n\n\t\tlog.info(\"committing changes\")\n\t\tfor f in files:\n\t\t\tlog.info(\"  %s\" % f)\n\t\tif self.dry_run:\n\t\t\treturn\n\t\tsp.check_call([\"git\", \"add\"] + files)\n\t\tmsg = self.commit_message.format(new_version=version)\n\t\tsp.check_call([\"git\", \"commit\", \"-m\", msg], stdout=sp.PIPE)\n\n\tdef git_tag(self, version, message, sign=False):\n\t\t\"\"\" Create annotated git tag with given 'version' and 'message'.\n\t\tOptionally 'sign' the tag with the user's GPG key.\n\t\t\"\"\"\n\t\tlog.info(\"creating %s git tag '%s'\" % (\n\t\t\t\"signed\" if sign else \"annotated\", version))\n\t\tif self.dry_run:\n\t\t\treturn\n\t\t# create an annotated (or signed) tag from the new version\n\t\ttag_opt = \"-s\" if sign else \"-a\"\n\t\ttag_name = self.tag_name.format(new_version=version)\n\t\tproc = sp.Popen(\n\t\t\t[\"git\", \"tag\", tag_opt, \"-F\", \"-\", tag_name], stdin=sp.PIPE)\n\t\t# use the latest changes from the changelog file as the tag message\n\t\ttag_message = u\"%s\\n\\n%s\" % (tag_name, message)\n\t\tproc.communicate(tag_message.encode('utf-8'))\n\t\tif proc.returncode != 0:\n\t\t\tsys.exit(proc.returncode)\n\n\tdef bumpversion(self, part, commit=False, message=None, allow_dirty=None):\n\t\t\"\"\" Run bumpversion.main() with the specified arguments, and return the\n\t\tnew computed version string (cf. 'bumpversion --help' for more info)\n\t\t\"\"\"\n\t\timport bumpversion\n\n\t\targs = (\n\t\t\t(['--verbose'] if self.verbose > 1 else []) +\n\t\t\t(['--dry-run'] if self.dry_run else []) +\n\t\t\t(['--allow-dirty'] if (allow_dirty or self.allow_dirty) else []) +\n\t\t\t(['--commit'] if commit else ['--no-commit']) +\n\t\t\t(['--message', message] if message is not None else []) +\n\t\t\t['--list', part]\n\t\t)\n\t\tlog.debug(\"$ bumpversion %s\" % \" \".join(a.replace(\" \", \"\\\\ \") for a in args))\n\n\t\twith capture_logger(\"bumpversion.list\") as out:\n\t\t\tbumpversion.main(args)\n\n\t\tlast_line = out.getvalue().splitlines()[-1]\n\t\tnew_version = last_line.replace(\"new_version=\", \"\")\n\t\treturn new_version\n\n\tdef format_changelog(self, version):\n\t\t\"\"\" Write new header at beginning of changelog file with the specified\n\t\t'version' and the current date.\n\t\tReturn the changelog content for the current release.\n\t\t\"\"\"\n\t\tfrom datetime import datetime\n\n\t\tlog.info(\"formatting changelog\")\n\n\t\tchanges = []\n\t\twith io.open(self.changelog_name, \"r+\", encoding=\"utf-8\") as f:\n\t\t\tfor ln in f:\n\t\t\t\tif ln.startswith(self.changelog_header):\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tchanges.append(ln)\n\t\t\tif not self.dry_run:\n\t\t\t\tf.seek(0)\n\t\t\t\tcontent = f.read()\n\t\t\t\tf.seek(0)\n\t\t\t\tf.write(u\"%s%s\\n\\n%s\\n\\n%s\" % (\n\t\t\t\t\tself.changelog_header,\n\t\t\t\t\tversion,\n\t\t\t\t\tdatetime.today().strftime(self.changelog_date_fmt),\n\t\t\t\t\tcontent))\n\n\t\treturn u\"\".join(changes)\n\n\nclass PassCommand(Command):\n\t\"\"\" This is used with Travis `dpl` tool so that it skips creating sdist\n\tand wheel packages, but simply uploads to PyPI the files found in ./dist\n\tfolder, that were previously built inside the tox 'bdist' environment.\n\tThis ensures that the same files are uploaded to Github Releases and PyPI.\n\t\"\"\"\n\n\tdescription = \"do nothing\"\n\tuser_options = []\n\n\tdef initialize_options(self):\n\t\tpass\n\n\tdef finalize_options(self):\n\t\tpass\n\n\tdef run(self):\n\t\tpass\n\n\nsetup(\n\tname=\"fonttools\",\n\tversion=\"3.5.0.dev0\",\n\tdescription=\"Tools to manipulate font files\",\n\tauthor=\"Just van Rossum\",\n\tauthor_email=\"just@letterror.com\",\n\tmaintainer=\"Behdad Esfahbod\",\n\tmaintainer_email=\"behdad@behdad.org\",\n\turl=\"http://github.com/fonttools/fonttools\",\n\tlicense=\"OpenSource, BSD-style\",\n\tplatforms=[\"Any\"],\n\tlong_description=long_description,\n\tpackage_dir={'': 'Lib'},\n\tpackages=find_packages(\"Lib\"),\n\tinclude_package_data=True,\n\tdata_files=[\n\t\t('share/man/man1', [\"Doc/ttx.1\"])\n\t] if sys.platform.startswith('linux') else [],\n\tsetup_requires=pytest_runner + wheel + bumpversion,\n\ttests_require=[\n\t\t'pytest>=2.8',\n\t],\n\tentry_points={\n\t\t'console_scripts': [\n\t\t\t\"fonttools = fontTools.__main__:main\",\n\t\t\t\"ttx = fontTools.ttx:main\",\n\t\t\t\"pyftsubset = fontTools.subset:main\",\n\t\t\t\"pyftmerge = fontTools.merge:main\",\n\t\t\t\"pyftinspect = fontTools.inspect:main\"\n\t\t]\n\t},\n\tcmdclass={\n\t\t\"release\": release,\n\t\t'pass': PassCommand,\n\t},\n\t**classifiers\n)\n", "path": "setup.py"}], "after_files": [{"content": "#! /usr/bin/env python\n\nfrom __future__ import print_function\nimport io\nimport sys\nimport os\nfrom os.path import isfile, join as pjoin\nfrom glob import glob\nfrom setuptools import setup, find_packages, Command\nfrom distutils import log\nfrom distutils.util import convert_path\nimport subprocess as sp\nimport contextlib\n\n# Force distutils to use py_compile.compile() function with 'doraise' argument\n# set to True, in order to raise an exception on compilation errors\nimport py_compile\norig_py_compile = py_compile.compile\n\ndef doraise_py_compile(file, cfile=None, dfile=None, doraise=False):\n\torig_py_compile(file, cfile=cfile, dfile=dfile, doraise=True)\n\npy_compile.compile = doraise_py_compile\n\nneeds_pytest = {'pytest', 'test'}.intersection(sys.argv)\npytest_runner = ['pytest_runner'] if needs_pytest else []\nneeds_wheel = {'bdist_wheel'}.intersection(sys.argv)\nwheel = ['wheel'] if needs_wheel else []\nneeds_bumpversion = {'release'}.intersection(sys.argv)\nbumpversion = ['bumpversion'] if needs_bumpversion else []\n\n# Trove classifiers for PyPI\nclassifiers = {\"classifiers\": [\n\t\"Development Status :: 5 - Production/Stable\",\n\t\"Environment :: Console\",\n\t\"Environment :: Other Environment\",\n\t\"Intended Audience :: Developers\",\n\t\"Intended Audience :: End Users/Desktop\",\n\t\"License :: OSI Approved :: BSD License\",\n\t\"Natural Language :: English\",\n\t\"Operating System :: OS Independent\",\n\t\"Programming Language :: Python\",\n\t\"Programming Language :: Python :: 2\",\n\t\"Programming Language :: Python :: 3\",\n\t\"Topic :: Text Processing :: Fonts\",\n\t\"Topic :: Multimedia :: Graphics\",\n\t\"Topic :: Multimedia :: Graphics :: Graphics Conversion\",\n]}\n\nlong_description = \"\"\"\\\nFontTools/TTX is a library to manipulate font files from Python.\nIt supports reading and writing of TrueType/OpenType fonts, reading\nand writing of AFM files, reading (and partially writing) of PS Type 1\nfonts. The package also contains a tool called \"TTX\" which converts\nTrueType/OpenType fonts to and from an XML-based format.\n\"\"\"\n\n\n@contextlib.contextmanager\ndef capture_logger(name):\n\t\"\"\" Context manager to capture a logger output with a StringIO stream.\n\t\"\"\"\n\timport logging\n\n\tlogger = logging.getLogger(name)\n\ttry:\n\t\timport StringIO\n\t\tstream = StringIO.StringIO()\n\texcept ImportError:\n\t\tstream = io.StringIO()\n\thandler = logging.StreamHandler(stream)\n\tlogger.addHandler(handler)\n\ttry:\n\t\tyield stream\n\tfinally:\n\t\tlogger.removeHandler(handler)\n\n\nclass release(Command):\n\t\"\"\"\n\tTag a new release with a single command, using the 'bumpversion' tool\n\tto update all the version strings in the source code.\n\tThe version scheme conforms to 'SemVer' and PEP 440 specifications.\n\n\tFirstly, the pre-release '.devN' suffix is dropped to signal that this is\n\ta stable release. If '--major' or '--minor' options are passed, the\n\tthe first or second 'semver' digit is also incremented. Major is usually\n\tfor backward-incompatible API changes, while minor is used when adding\n\tnew backward-compatible functionalities. No options imply 'patch' or bug-fix\n\trelease.\n\n\tA new header is also added to the changelog file (\"NEWS\"), containing the\n\tnew version string and the current 'YYYY-MM-DD' date.\n\n\tAll changes are committed, and an annotated git tag is generated. With the\n\t--sign option, the tag is GPG-signed with the user's default key.\n\n\tFinally, the 'patch' part of the version string is bumped again, and a\n\tpre-release suffix '.dev0' is appended to mark the opening of a new\n\tdevelopment cycle.\n\n\tLinks:\n\t- http://semver.org/\n\t- https://www.python.org/dev/peps/pep-0440/\n\t- https://github.com/peritus/bumpversion\n\t\"\"\"\n\n\tdescription = \"update version strings for release\"\n\n\tuser_options = [\n\t\t(\"major\", None, \"bump the first digit (incompatible API changes)\"),\n\t\t(\"minor\", None, \"bump the second digit (new backward-compatible features)\"),\n\t\t(\"sign\", \"s\", \"make a GPG-signed tag, using the default key\"),\n\t\t(\"allow-dirty\", None, \"don't abort if working directory is dirty\"),\n\t]\n\n\tchangelog_name = \"NEWS\"\n\tchangelog_header = u\"## TTX/FontTools Version \"\n\tchangelog_date_fmt = \"%Y-%m-%d\"\n\tcommit_message = \"Release {new_version}\"\n\ttag_name = \"{new_version}\"\n\tversion_files = [\n\t\t\"setup.cfg\",\n\t\t\"setup.py\",\n\t\t\"Lib/fontTools/__init__.py\",\n\t]\n\n\tdef initialize_options(self):\n\t\tself.minor = False\n\t\tself.major = False\n\t\tself.sign = False\n\t\tself.allow_dirty = False\n\n\tdef finalize_options(self):\n\t\tif all([self.major, self.minor]):\n\t\t\tfrom distutils.errors import DistutilsOptionError\n\t\t\traise DistutilsOptionError(\"--major/--minor are mutually exclusive\")\n\t\tself.part = \"major\" if self.major else \"minor\" if self.minor else None\n\n\tdef run(self):\n\t\tif self.part is not None:\n\t\t\tlog.info(\"bumping '%s' version\" % self.part)\n\t\t\tself.bumpversion(self.part, commit=False)\n\t\t\trelease_version = self.bumpversion(\n\t\t\t\t\"release\", commit=False, allow_dirty=True)\n\t\telse:\n\t\t\tlog.info(\"stripping pre-release suffix\")\n\t\t\trelease_version = self.bumpversion(\"release\")\n\t\tlog.info(\"  version = %s\" % release_version)\n\n\t\tchanges = self.format_changelog(release_version)\n\n\t\tself.git_commit(release_version)\n\t\tself.git_tag(release_version, changes, self.sign)\n\n\t\tlog.info(\"bumping 'patch' version and pre-release suffix\")\n\t\tnext_dev_version = self.bumpversion('patch', commit=True)\n\t\tlog.info(\"  version = %s\" % next_dev_version)\n\n\tdef git_commit(self, version):\n\t\t\"\"\" Stage and commit all relevant version files, and format the commit\n\t\tmessage with specified 'version' string.\n\t\t\"\"\"\n\t\tfiles = self.version_files + [self.changelog_name]\n\n\t\tlog.info(\"committing changes\")\n\t\tfor f in files:\n\t\t\tlog.info(\"  %s\" % f)\n\t\tif self.dry_run:\n\t\t\treturn\n\t\tsp.check_call([\"git\", \"add\"] + files)\n\t\tmsg = self.commit_message.format(new_version=version)\n\t\tsp.check_call([\"git\", \"commit\", \"-m\", msg], stdout=sp.PIPE)\n\n\tdef git_tag(self, version, message, sign=False):\n\t\t\"\"\" Create annotated git tag with given 'version' and 'message'.\n\t\tOptionally 'sign' the tag with the user's GPG key.\n\t\t\"\"\"\n\t\tlog.info(\"creating %s git tag '%s'\" % (\n\t\t\t\"signed\" if sign else \"annotated\", version))\n\t\tif self.dry_run:\n\t\t\treturn\n\t\t# create an annotated (or signed) tag from the new version\n\t\ttag_opt = \"-s\" if sign else \"-a\"\n\t\ttag_name = self.tag_name.format(new_version=version)\n\t\tproc = sp.Popen(\n\t\t\t[\"git\", \"tag\", tag_opt, \"-F\", \"-\", tag_name], stdin=sp.PIPE)\n\t\t# use the latest changes from the changelog file as the tag message\n\t\ttag_message = u\"%s\\n\\n%s\" % (tag_name, message)\n\t\tproc.communicate(tag_message.encode('utf-8'))\n\t\tif proc.returncode != 0:\n\t\t\tsys.exit(proc.returncode)\n\n\tdef bumpversion(self, part, commit=False, message=None, allow_dirty=None):\n\t\t\"\"\" Run bumpversion.main() with the specified arguments, and return the\n\t\tnew computed version string (cf. 'bumpversion --help' for more info)\n\t\t\"\"\"\n\t\timport bumpversion\n\n\t\targs = (\n\t\t\t(['--verbose'] if self.verbose > 1 else []) +\n\t\t\t(['--dry-run'] if self.dry_run else []) +\n\t\t\t(['--allow-dirty'] if (allow_dirty or self.allow_dirty) else []) +\n\t\t\t(['--commit'] if commit else ['--no-commit']) +\n\t\t\t(['--message', message] if message is not None else []) +\n\t\t\t['--list', part]\n\t\t)\n\t\tlog.debug(\"$ bumpversion %s\" % \" \".join(a.replace(\" \", \"\\\\ \") for a in args))\n\n\t\twith capture_logger(\"bumpversion.list\") as out:\n\t\t\tbumpversion.main(args)\n\n\t\tlast_line = out.getvalue().splitlines()[-1]\n\t\tnew_version = last_line.replace(\"new_version=\", \"\")\n\t\treturn new_version\n\n\tdef format_changelog(self, version):\n\t\t\"\"\" Write new header at beginning of changelog file with the specified\n\t\t'version' and the current date.\n\t\tReturn the changelog content for the current release.\n\t\t\"\"\"\n\t\tfrom datetime import datetime\n\n\t\tlog.info(\"formatting changelog\")\n\n\t\tchanges = []\n\t\twith io.open(self.changelog_name, \"r+\", encoding=\"utf-8\") as f:\n\t\t\tfor ln in f:\n\t\t\t\tif ln.startswith(self.changelog_header):\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tchanges.append(ln)\n\t\t\tif not self.dry_run:\n\t\t\t\tf.seek(0)\n\t\t\t\tcontent = f.read()\n\t\t\t\tf.seek(0)\n\t\t\t\tf.write(u\"%s%s\\n\\n%s\\n\\n%s\" % (\n\t\t\t\t\tself.changelog_header,\n\t\t\t\t\tversion,\n\t\t\t\t\tdatetime.today().strftime(self.changelog_date_fmt),\n\t\t\t\t\tcontent))\n\n\t\treturn u\"\".join(changes)\n\n\nclass PassCommand(Command):\n\t\"\"\" This is used with Travis `dpl` tool so that it skips creating sdist\n\tand wheel packages, but simply uploads to PyPI the files found in ./dist\n\tfolder, that were previously built inside the tox 'bdist' environment.\n\tThis ensures that the same files are uploaded to Github Releases and PyPI.\n\t\"\"\"\n\n\tdescription = \"do nothing\"\n\tuser_options = []\n\n\tdef initialize_options(self):\n\t\tpass\n\n\tdef finalize_options(self):\n\t\tpass\n\n\tdef run(self):\n\t\tpass\n\n\ndef find_data_files(manpath=\"share/man\"):\n\t\"\"\" Find FontTools's data_files (just man pages at this point).\n\n\tBy default, we install man pages to \"share/man\" directory relative to the\n\tbase installation directory for data_files. The latter can be changed with\n\tthe --install-data option of 'setup.py install' sub-command.\n\n\tE.g., if the data files installation directory is \"/usr\", the default man\n\tpage installation directory will be \"/usr/share/man\".\n\n\tYou can override this via the $FONTTOOLS_MANPATH environment variable.\n\n\tE.g., on some BSD systems man pages are installed to 'man' instead of\n\t'share/man'; you can export $FONTTOOLS_MANPATH variable just before\n\tinstalling:\n\n\t$ FONTTOOLS_MANPATH=\"man\" pip install -v .\n\t    [...]\n\t    running install_data\n\t    copying Doc/man/ttx.1 -> /usr/man/man1\n\n\tWhen installing from PyPI, for this variable to have effect you need to\n\tforce pip to install from the source distribution instead of the wheel\n\tpackage (otherwise setup.py is not run), by using the --no-binary option:\n\n\t$ FONTTOOLS_MANPATH=\"man\" pip install --no-binary=fonttools fonttools\n\n\tNote that you can only override the base man path, i.e. without the\n\tsection number (man1, man3, etc.). The latter is always implied to be 1,\n\tfor \"general commands\".\n\t\"\"\"\n\n\t# get base installation directory for man pages\n\tmanpagebase = os.environ.get('FONTTOOLS_MANPATH', convert_path(manpath))\n\t# all our man pages go to section 1\n\tmanpagedir = pjoin(manpagebase, 'man1')\n\n\tmanpages = [f for f in glob(pjoin('Doc', 'man', 'man1', '*.1')) if isfile(f)]\n\n\tdata_files = [(manpagedir, manpages)]\n\treturn data_files\n\n\nsetup(\n\tname=\"fonttools\",\n\tversion=\"3.5.0.dev0\",\n\tdescription=\"Tools to manipulate font files\",\n\tauthor=\"Just van Rossum\",\n\tauthor_email=\"just@letterror.com\",\n\tmaintainer=\"Behdad Esfahbod\",\n\tmaintainer_email=\"behdad@behdad.org\",\n\turl=\"http://github.com/fonttools/fonttools\",\n\tlicense=\"OpenSource, BSD-style\",\n\tplatforms=[\"Any\"],\n\tlong_description=long_description,\n\tpackage_dir={'': 'Lib'},\n\tpackages=find_packages(\"Lib\"),\n\tinclude_package_data=True,\n\tdata_files=find_data_files(),\n\tsetup_requires=pytest_runner + wheel + bumpversion,\n\ttests_require=[\n\t\t'pytest>=2.8',\n\t],\n\tentry_points={\n\t\t'console_scripts': [\n\t\t\t\"fonttools = fontTools.__main__:main\",\n\t\t\t\"ttx = fontTools.ttx:main\",\n\t\t\t\"pyftsubset = fontTools.subset:main\",\n\t\t\t\"pyftmerge = fontTools.merge:main\",\n\t\t\t\"pyftinspect = fontTools.inspect:main\"\n\t\t]\n\t},\n\tcmdclass={\n\t\t\"release\": release,\n\t\t'pass': PassCommand,\n\t},\n\t**classifiers\n)\n", "path": "setup.py"}]}