development

Convenient uploading of a project to PyPI using a bash alias

Earlier I thought that using pypandoc in your setup.py was a great idea to solve the long_description and the README.rst, when you write your README in Markdown. Spoiler: it’s a pretty terrible idea…

So:

  • I have my README files in Markdown
  • I would like to have them also in reStructuredText for PyPI submission
  • I don’t want to copy paste and edit those files
  • I want to fill in the long_description in setup.py when uploading projects to PyPI

So the new solution is a bash alias:

alias pypush='rm -r dist/ *.egg-info/ ; pandoc --from=markdown --to=rst --output=README.rst README.md && python setup.py sdist && twine upload dist/*'

 

This appears to solve the problems listed above.
It starts with clearing up the directory from the previous ‘upload’, then executes pandoc for conversion of the README.md to README.rst (which I also added to my .gitignore), followed by creating the source distribution and uploading of the package. My setup.py (see below) opens the README.rst to get the long_description which is shown on the PyPI webpage.

Getting quite efficient here!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s