def release(): """Release/publish the code. """ # Rebase and push the master with tags to origin. print("Here are the remaining TODO items:") print(bash('TODO.sh')) print() if not util.yes("Do you still want to rebase and push the master with tags " "to origin (y/n)?"): util.delayed_exit() git.rebase('-i', 'origin/master') git.push('--tags', 'origin', 'master') # Upload to PyPI. if not util.yes("Do you want to upload to PyPI (this is permanent!) " "(y/n)?"): util.delayed_exit() setup.sdist.upload() # Reset the version number. # In natu/__init__.py: set_version('None') # In CHANGES.txt: newheading = ('TBD (in `GitHub <https://github.com/kdavies4/natu>`_ ' 'only) -- Updates:') newlink = ('.. _vx.x.x: ' 'https://github.com/kdavies4/natu/archive/vx.x.x.zip') rpls = [(r'(<http://semver.org>`_\.)', r'\1\n\n' + newheading), (r'(Initial release\n\n\n)', r'\1%s\n' % newlink)] util.replace('CHANGES.txt', rpls)
def release(): """Release/publish the code. """ # Rebase and push the master with tags to origin. print("Here are the remaining TODO items:") print(bash('TODO.sh')) print() if not util.yes( "Do you still want to rebase and push the master with tags " "to origin (y/n)?"): util.delayed_exit() git.rebase('-i', 'origin/master') git.push('--tags', 'origin', 'master') # Upload to PyPI. if not util.yes("Do you want to upload to PyPI (this is permanent!) " "(y/n)?"): util.delayed_exit() setup.sdist.upload() # Reset the version number. # In CHANGES.txt: newheading = ('TBD (in `GitHub <https://github.com/kdavies4/natu>`_ ' 'only) -- Updates:') newlink = ('.. _vx.x.x: ' 'https://github.com/kdavies4/natu/archive/vx.x.x.zip') rpls = [(r'(<http://semver.org>`_\.)', r'\1\n\n' + newheading), (r'(Initial release\n\n\n)', r'\1%s\n' % newlink)] util.replace('CHANGES.txt', rpls)
def html(): """Build/make the HTML documentation. """ # Rebuild the static images. if util.yes("Do you want to rebuild the static images (y/n)?"): static() # Update the download link. try: commit = git('rev-list', '--tags', '--max-count=1').stdout.rstrip() lastversion = git.describe('--tags', commit).stdout.rstrip() # This is simpler but doesn't always return the latest tag: # lastversion = git.describe('--tag', abbrev=0).stdout.rstrip() except ErrorReturnCode_128: pass # No tags recorded; leave download link as is else: date = git.log('-1', lastversion, date='short', format='%ad').stdout[8:18] rpls = [(r'(ModelicaRes)-.*(\.tar)', r'\1-%s\2' % lastversion[1:]), (r'(Latest version<br>\().*(\)</a>)', r'\1%s, %s\2' % (lastversion, date)), ] util.replace('_templates/download.html', rpls) # Build the documentation. make_dirs() sphinx = sphinx_build.bake(b='html', d='build/doctrees') print(sphinx('.', BUILD_DIR)) # Spellcheck. if util.yes("Do you want to spellcheck the HTML documentation (y/n)?"): spellcheck()
def html(): """Build/make the HTML documentation. """ # Rebuild the static images. if util.yes("Do you want to rebuild the static images (y/n)?"): static() # Update the download link. try: commit = git('rev-list', '--tags', '--max-count=1').stdout.rstrip() lastversion = git.describe('--tags', commit).stdout.rstrip() # This is simpler but doesn't always return the latest tag: # lastversion = git.describe('--tag', abbrev=0).stdout.rstrip() except ErrorReturnCode_128: pass # No tags recorded; leave download link as is else: date = git.log('-1', lastversion, date='short', format='%ad').stdout[8:18] rpls = [ (r'(ModelicaRes)-.*(\.tar)', r'\1-%s\2' % lastversion[1:]), (r'(Latest version<br>\().*(\)</a>)', r'\1%s, %s\2' % (lastversion, date)), ] util.replace('_templates/download.html', rpls) # Build the documentation. make_dirs() sphinx = sphinx_build.bake(b='html', d='build/doctrees') print((sphinx('.', BUILD_DIR))) # Spellcheck. if util.yes("Do you want to spellcheck the HTML documentation (y/n)?"): spellcheck()
def build(): """Build the code to prepare for release. """ # Check that long-description.txt is a valid ReST file (otherwise, the PyPI # page won't display correctly). readme = 'doc/long-description.txt' error_start = 'Docutils System Messages\n' with open(readme, 'r') as rstfile: parsed = publish_string(rstfile.read()) if error_start in parsed: print("Errors in " + readme) util.delayed_exit() # Run other setup tests. if setup.check('-rms').exit_code: print("The setup.py check failed.") util.delayed_exit() # Get the new version number. commit = git('rev-list', '--tags', '--max-count=1').stdout.rstrip() lastversion = git.describe('--tags', commit).stdout.rstrip().lstrip('v') # This is simpler but doesn't always return the latest tag: # lastversion = git.describe('--tag', abbrev=0).stdout.rstrip() version = raw_input("Enter the version number (last was %s): " % lastversion) # Tag the version (will prompt for message). git.tag('-af', 'v' + version) # Update the version number. # In CHANGES.txt: date = strftime('%Y-%-m-%-d') rpls = [(r'TBD.*( -- Updates:)', r'v{v}_ ({d})\1'.format(v=version, d=date)), (r'v%s_ \(.+\)( -- Updates:)' % version, r'v{v}_ ({d})\1'.format(v=version, d=date)), (r'(.. _)vx\.x\.x(.+)vx\.x\.x(\.zip)', r'\1v{v}\2v{v}\3'.format(v=version))] util.replace('CHANGES.txt', rpls) # Note that versioneer automatically handles the version number in # natu/__init__.py. # Build, install, and test the code. setup.build() os.system('sudo python setup.py install') os.system('sudo python3 setup.py install') os.system('python setup.py test') os.system('python3 setup.py test') # Create a tarball and zip (*.tar.gz and *.zip). setup.sdist(formats='gztar,zip')
def set_version(version, fname='natu/__init__.py'): """Update the version in a file. """ util.replace(fname, [('(__version__) *= *.+', r"\1 = %s" % version)])
def release(): """Release/publish the documentation to the webpage. """ # Save the current state. branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout.rstrip() git.stash('save', "Work in progress while updating gh-pages branch") # Check out the gh-pages branch. try: git.checkout('gh-pages') except ErrorReturnCode_128: # Create the branch if necessary. git.checkout('-b', 'gh-pages') # Remove the existing files in the base folder. extensions = ['*.html', '*.inv'] fnames = util.multiglob('..', extensions) for fname in fnames: os.remove(fname) # Copy the new files to the base folder. fnames = util.multiglob(BUILD_DIR, extensions) for fname in fnames: shutil.copy(fname, '..') # Track the new files. fnames = util.multiglob('..', extensions) git.add(*fnames) # Copy but rename the folders referenced in the HTML files. # Github only recognizes images, stylesheets, and javascripts as folders. folders = [('_images', 'images'), ('_static', 'javascripts'), ] for (src, dst) in folders: dst = os.path.join('..', dst) # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new folder. shutil.copytree(os.path.join(BUILD_DIR, src), dst) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. html_fnames = glob(os.path.join('..', '*.html')) util.replace(html_fnames, folders) # Copy and rename the examples folder. src = os.path.join(BUILD_DIR, 'examples') dst = '../examples2' # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new files. os.mkdir(dst) for fname in os.listdir(src): shutil.copy(os.path.join(src, fname), os.path.join(dst, fname)) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. util.replace(html_fnames, [(r'"\./examples/', r'"./examples2/')]) # Update the sitemap. print(python('sitemap_gen.py', config="sitemap_conf.xml")) # Commit the changes. try: git.commit('-a', m="Rebuilt documentation") except ErrorReturnCode_1: pass # No changes to commit # If desired, rebase and push the changes to origin. print("The gh-pages branch has been updated and is currently checked out.") if util.yes("Do you want to rebase it and push the changes to " "origin (y/n)?"): git.rebase('-i', 'origin/gh-pages') git.push.origin('gh-pages') # Return to the original state. git.checkout(branch) try: git.stash.pop() except ErrorReturnCode_1: pass # No stash was necessary in the first place. print("Now back on " + branch)
def release(): """Release/publish the documentation to the webpage. """ # Save the current state. branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout.rstrip() git.stash('save', "Work in progress while updating gh-pages branch") # Check out the gh-pages branch. try: git.checkout('gh-pages') except ErrorReturnCode_128: # Create the branch if necessary. git.checkout('-b', 'gh-pages') # Remove the existing files in the base folder. extensions = ['*.html', '*.inv'] fnames = util.multiglob('..', extensions) for fname in fnames: os.remove(fname) # Copy the new files to the base folder. fnames = util.multiglob(BUILD_DIR, extensions) for fname in fnames: shutil.copy(fname, '..') # Track the new files. fnames = util.multiglob('..', extensions) git.add(*fnames) # Copy but rename the folders referenced in the HTML files. # Github only recognizes images, stylesheets, and javascripts as folders. folders = [ ('_images', 'images'), ('_static', 'javascripts'), ] for (src, dst) in folders: dst = os.path.join('..', dst) # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new folder. shutil.copytree(os.path.join(BUILD_DIR, src), dst) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. html_fnames = glob(os.path.join('..', '*.html')) util.replace(html_fnames, folders) # Copy and rename the examples folder. src = os.path.join(BUILD_DIR, 'examples') dst = '../examples2' # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new files. os.mkdir(dst) for fname in os.listdir(src): shutil.copy(os.path.join(src, fname), os.path.join(dst, fname)) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. util.replace(html_fnames, [(r'"\./examples/', r'"./examples2/')]) # Update the sitemap. print((python('sitemap_gen.py', config="sitemap_conf.xml"))) # Commit the changes. try: git.commit('-a', m="Rebuilt documentation") except ErrorReturnCode_1: pass # No changes to commit # If desired, rebase and push the changes to origin. print("The gh-pages branch has been updated and is currently checked out.") if util.yes("Do you want to rebase it and push the changes to " "origin (y/n)?"): git.rebase('-i', 'origin/gh-pages') git.push.origin('gh-pages') # Return to the original state. git.checkout(branch) try: git.stash.pop() except ErrorReturnCode_1: pass # No stash was necessary in the first place. print(("Now back on " + branch))
<ul> <li><a href="QCalc_UsersGuide.html"><img src="QCalc.UsersGuideS.png" alt="QCalc.UsersGuide" width="20" height="20" align="top"> User's Guide</a></li> <li><a href="QCalc_Blocks.html"><img src="QCalc.BlocksS.png" alt="QCalc.Blocks" width="20" height="20" align="top"> Blocks</a></li> <li><a href="QCalc_Units.html"><img src="QCalc.UnitsS.png" alt="QCalc.Units" width="20" height="20" align="top"> Units</a></li> <li><a href="QCalc_Quantities.html"><img src="QCalc.QuantitiesS.png" alt="QCalc.Quantities" width="20" height="20" align="top"> Quantities</a></li> <li><a href="QCalc_Math.html"><img src="QCalc.MathS.png" alt="QCalc.Math" width="20" height="20" align="top"> Math</a></li> <li><a href="QCalc_Icons.html"><img src="QCalc.IconsS.png" alt="QCalc.Icons" width="20" height="20" align="top"> Icons</a></li> </ul> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body">"""), # Fix some file links. ('href="QCalc/Resources/Documentation/UsersGuide/Publications/Natural-Unit-Representation-in-Modelica-\(poster\)\.html#QCalc/Resources/Documentation/UsersGuide/Publications/Natural-Unit-Representation-in-Modelica-\(poster\)\.pdf"', 'href="../Resources/Documentation/UsersGuide/Publications/Natural-Unit-Representation-in-Modelica-(poster).pdf"' ), ] # Process the arguments. try: directory = argv[1] except IndexError: directory = DEFAULT_DIR # Replace the text. fnames = glob(join(directory, '*.html')) replace(fnames, RPLS)
def set_version(version, fname='modelicares/__init__.py'): """Update the version in a file. """ replace(fname, [('(__version__) *= *.+', r"\1 = %s" % version)])
<h3>Library Contents</h3> <ul> <li><a href="QCalc_UsersGuide.html"><img src="QCalc.UsersGuideS.png" alt="QCalc.UsersGuide" width="20" height="20" align="top"> User's Guide</a></li> <li><a href="QCalc_Blocks.html"><img src="QCalc.BlocksS.png" alt="QCalc.Blocks" width="20" height="20" align="top"> Blocks</a></li> <li><a href="QCalc_Units.html"><img src="QCalc.UnitsS.png" alt="QCalc.Units" width="20" height="20" align="top"> Units</a></li> <li><a href="QCalc_Quantities.html"><img src="QCalc.QuantitiesS.png" alt="QCalc.Quantities" width="20" height="20" align="top"> Quantities</a></li> <li><a href="QCalc_Math.html"><img src="QCalc.MathS.png" alt="QCalc.Math" width="20" height="20" align="top"> Math</a></li> <li><a href="QCalc_Icons.html"><img src="QCalc.IconsS.png" alt="QCalc.Icons" width="20" height="20" align="top"> Icons</a></li> </ul> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body">"""), # Fix some file links. ('href="QCalc/Resources/Documentation/UsersGuide/Publications/Natural-Unit-Representation-in-Modelica-\(poster\)\.html#QCalc/Resources/Documentation/UsersGuide/Publications/Natural-Unit-Representation-in-Modelica-\(poster\)\.pdf"', 'href="../Resources/Documentation/UsersGuide/Publications/Natural-Unit-Representation-in-Modelica-(poster).pdf"'), ] # Process the arguments. try: directory = argv[1] except IndexError: directory = DEFAULT_DIR # Replace the text. fnames = glob(join(directory, '*.html')) replace(fnames, RPLS)