summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-09-22 21:59:07 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-09-22 21:59:07 -0700
commit82dd19649740270859736e6bdb91989048a46dee (patch)
tree0b4920f26c9334f6715a74128c0988b73d1eea1e /setup.py
parentc32239c7a86dad0dfd13959ec7555812c412a1cc (diff)
downloadpystache-82dd19649740270859736e6bdb91989048a46dee.tar.gz
Simplify the setup conversion code a bit more.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/setup.py b/setup.py
index 5cb6cdc..c83768c 100644
--- a/setup.py
+++ b/setup.py
@@ -184,7 +184,7 @@ def make_temp_path(path):
return temp_path
-def convert_md_to_rst(path):
+def convert_md_to_rst(md_path):
"""
Convert the given file from markdown to reStructuredText.
@@ -192,14 +192,14 @@ def convert_md_to_rst(path):
"""
# We write the converted files to temp files to simplify debugging.
- temp_path = make_temp_path(path)
- print("Converting: %s to %s" % (path, temp_path))
+ temp_path = make_temp_path(md_path)
+ print("Converting: %s to %s" % (md_path, temp_path))
if os.path.exists(temp_path):
os.remove(temp_path)
# Pandoc uses the UTF-8 character encoding for both input and output.
- command = "pandoc --write=rst --output=%s %s" % (temp_path, path)
+ command = "pandoc --write=rst --output=%s %s" % (temp_path, md_path)
os.system(command)
if not os.path.exists(temp_path):
@@ -210,13 +210,17 @@ def convert_md_to_rst(path):
return read(temp_path)
-def write_long_description(target_path):
+# The long_description needs to be formatted as reStructuredText.
+# See the following for more information:
+#
+# http://docs.python.org/distutils/setupscript.html#additional-meta-data
+# http://docs.python.org/distutils/uploading.html#pypi-package-display
+#
+def make_long_description():
"""
- Generate the long_description for setup().
-
- The long description needs to be formatted as reStructuredText:
+ Generate the long_description for setup() from source files.
- http://docs.python.org/distutils/setupscript.html#additional-meta-data
+ Returns the long_description as a unicode string.
"""
readme_section = convert_md_to_rst(README_PATH)
@@ -233,23 +237,22 @@ License
history_section,
license_section]
- description = '\n'.join(sections)
-
- write(description, target_path)
+ return '\n'.join(sections)
def prep():
- write_long_description(DESCRIPTION_PATH)
+ long_description = make_long_description()
+ write(long_description, DESCRIPTION_PATH)
+
def publish():
"""
Publish this package to PyPI (aka "the Cheeseshop").
"""
- temp_path = make_temp_path(DESCRIPTION_PATH)
- write_long_description(temp_path)
+ long_description = make_long_description()
- if read(temp_path) != read(DESCRIPTION_PATH):
+ if long_description != read(DESCRIPTION_PATH):
print("""\
Description file not up-to-date: %s
Run the following command and commit the changes--