Skip to content

Commit

Permalink
Script updates to fix RST formatting issue reported by PyPI.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrimko committed Apr 22, 2020
1 parent b43c7e1 commit 423dbc6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 22 deletions.
47 changes: 47 additions & 0 deletions lib/_Check_Readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
##==============================================================#
## SECTION: Imports #
##==============================================================#

import os

import qprompt

##==============================================================#
## SECTION: Function Definitions #
##==============================================================#

class ReadmeRst:
"""Context manager that temporarily creates a RST file for the README."""
def __enter__(self):
_generate_readme()
def __exit__(self, type, value, traceback):
_cleanup_readme()

def _generate_readme():
os.system("asciidoctor -b docbook ../README.adoc")

os.system("pandoc -r docbook -w rst -o README.rst.tmp ../README.xml")
os.remove("../README.xml")

# NOTE: The following removes the reference links that are created in the
# RST by Pandoc. These currently cause PyPI to complain that the RST is not
# valid.
with open("README.rst.tmp") as fi:
with open("README.rst", "w") as fo:
for line in fi.readlines():
if line.startswith(".. __"):
continue
fo.write(line)
os.remove("README.rst.tmp")

def _cleanup_readme():
os.remove("README.rst")

##==============================================================#
## SECTION: Main Body #
##==============================================================#

if __name__ == '__main__':
with ReadmeRst():
os.system("python setup.py check -r -s")
qprompt.pause()
18 changes: 3 additions & 15 deletions lib/_Install_Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,13 @@
##==============================================================#

import os
import subprocess

##==============================================================#
## SECTION: Function Definitions #
##==============================================================#

def generate_readme():
subprocess.call("asciidoctor -b docbook ../README.adoc", shell=True)
subprocess.call("pandoc -r docbook -w rst -o README.rst ../README.xml", shell=True)
os.remove("../README.xml")

def cleanup_readme():
os.remove("README.rst")
from _Check_Readme import ReadmeRst

##==============================================================#
## SECTION: Main Body #
##==============================================================#

if __name__ == '__main__':
generate_readme()
subprocess.call("pip install -e .", shell=True)
cleanup_readme()
with ReadmeRst():
os.system("pip install -e .", shell=True)
11 changes: 5 additions & 6 deletions lib/_Upload_PyPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
sys.dont_write_bytecode = True

from _Check_Versions import VERCHK
from _Install_Package import generate_readme, cleanup_readme
from _Check_Readme import ReadmeRst

##==============================================================#
## SECTION: Main Body #
Expand All @@ -32,11 +32,10 @@
qprompt.alert("Issue running tests!")
sys.exit(1)
if qprompt.ask_yesno("Upload version `%s`?" % (ver)):
generate_readme()
fs.copy(r"..\LICENSE", "LICENSE")
sh.call("python setup.py sdist upload")
fs.delete("LICENSE")
cleanup_readme()
with ReadmeRst():
fs.copy(r"..\LICENSE", "LICENSE")
sh.call("python setup.py sdist upload")
fs.delete("LICENSE")
if pause:
qprompt.pause()
sys.exit(0)
5 changes: 4 additions & 1 deletion lib/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from os.path import isfile
from setuptools import setup, find_packages

readme = open("README.rst").read() if isfile("README.rst") else ""
print(readme)

setup(
name = "qprompt",
version = "0.16.0",
Expand All @@ -12,7 +15,7 @@
url = "https://github.com/jeffrimko/Qprompt",
py_modules=["qprompt"],
install_requires=["iterfzf"],
long_description=open("README.rst").read() if isfile("README.rst") else "",
long_description=readme,
data_files = [("", ["LICENSE"])],
classifiers=[
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit 423dbc6

Please sign in to comment.