Publicizing Your Code - UMKCgeg/Wiki GitHub Wiki

If you write some code that may be useful to others, you may want to share it. A good first start is to upload it to GitHub. If you put it in a public repository, everyone can see it, download it, and suggest changes.

PyPI

If your code is in Python, you may want to consider putting your code on PyPI (the Python Package Index). While having code on GitHub is nice, PyPI allows others to easily install your code with tools like pip. pip install your_package is much easier for someone than git clone https://github.com/your_username/your_package. Here is a short guide on how to do that.

This website has everything you need to know, but it can be a little overwhelming for the first time user, so here is a condensed guide on how to do things. Check that link for details if need be. It also has a sample project, which is very helpful.

Uploading for the first time

  1. Install Twine, which is a tool that does uploads to PyPI nicely. It can be done with pip install twine

  2. Configure your setup.py file, which goes in the root directory of your project. This contains info about the project. This section of the above link explains most of what you need to know. Make sure to include a version.

  3. From inside your project's root directory, run python setup.py sdist. This creates the distribution files, which will be uploaded.

  4. From the same directory, run python setup.py bdist_wheel --universal. This creates a wheel, which is useful for others installing your project. This command assumes your project is compatible with both Python 2 and 3. If not, read here

  5. If you haven't already made an account on the PyPI website, do so. You'll need to create a ~/.pypirc file, which contains your login information. It will look something like this:

    [distutils]
    index-servers=pypi
    
    [pypi]
    repository = https://pypi.python.org/pypi
    username = your_username
    password = your_password
    
  6. From your package's root directory, run python setup.py register. This registers your project on PyPI. This should probably be done with Twine, but I couldn't get it to work.

  7. From the same directory, run twine upload dist/*. This uploads the current version of your project to PyPI. You're all done!

  8. Assuming your package is on GitHub, you'll want to add all the files you created to your .gitignore file if you haven't already.

Uploading Future Releases

Once your project is all set up on PyPI, uploading future versions is fairly easy.

  1. Change the version number in setup.py.
  2. Delete all the old files in dist/.
  3. Step 3 above. python setup.py sdist
  4. Step 4 above. python setup.py bdist_wheel --universal
  5. Step 7 above. twine upload dist/*

ReadTheDocs (under construction)

If your project is hosted on GitHub and you want to have a website with documentation for the project, you can use ReadTheDocs. Setup is complicated, but it's worth it.

Some things to elaborate on: plot_directive, nbsphinx