Skip to content

CreatePythonProject

Rob Nagler edited this page Nov 9, 2021 · 9 revisions

Creating a New Python Project

PyKern automates the creation of a Python module or library that will be ready for use with PyPI, Read The Docs and related services.

Here are simplified instructions, which only work for RadiaSoft projects.

First, create a RadiaSoft GitHub repository with no files. I've ​used rssynergia as an example. Assuming you are in a RadiaSoft VM (or in any unix-like environment where PyKern is properly installed), do the following (or equivalent, using the name of your repository and an appropriate description):

cd ~/src/radiasoft/
git clone https://github.com/radiasoft/rsfriction
cd rsfriction
pykern projex init-rs-tree 'Python library for simulating the dynamical friction force exerted on ions by magnetized electrons'
git commit -am 'initial setup'
git push
python setup.py develop

One can also work with a non-RadiaSoft repository, but the argument "init_rs_tree" must be changed to "init_tree" and then several string arguments must be supplied.

Helpful hints can be obtained from

pykern projex -h

However, you may also want to look at the source code for projex.py.

Test PyPI

When you setup PyPI, you should start with the test site. The packages should be registered with the builder user. First click on Package submission on the left side:

Package Submission Link

Then upload the PKG-INFO file that was created by pykern setup.py develop. It's located in, e.g. ~/src/radiasoft/rssynergia/rssynergia.egg-info/PKG-INFO:

Upload PKG-INFO

At this point testpypi is ready to go.

ReadTheDocs

To compile the documentation on ReadTheDocs, you'll need to import the project. Go to ReadTheDocs Dashboard and click on Import a Project:

Import a Project

This will show you a list of repositories, click on the [+] next to the repository you want to import:

Select Repo

Select the Edit advanced project options and click Next:

Advanced Options

Enter a description. Select Python Programming Language. Fill in Project homepage to GitHub repo URL. Then click Finish:

Setup ReadTheDocs

Click on Admin button and then Advanced Settings (on the left):

ReadTheDocs Advanced Settings

DO NOT Install your project inside a virtualenv.

Set the Default Version to latest.

ReadTheDocs Advanced Settings: Default Version

Finally, click Submit.

You may want to edit docs/index.rst with a longer description.

Clone this wiki locally