Overview

Here are the 5 levels of sharing your code. We provide tutorials for each level.

5 levels of reusing/sharing code

Level

Name

Scope

How to setup

1

function

Reuse code in the single file.

See Level 1 tutorial

2

module

Reuse code across files.

See Level 2 tutorial

3

workspace

Reuse code across project folders.

package create workspace

4

system

Reuse code across any files in the computer.

package create system

5

public

Share code as a publicly installable package.

package create public

Where do I begin?

I am here to start a new Python project

⏩️ If you have experience developing scientific code in Python, we recommend starting from Level 4, where you will create a lightweight Python package with automatic formatting and unit testing using GitHub Actions.

conda create -n skpkg-env scikit-package
conda activate skpkg-env
package create system

Follow the prompts to enter information for your package. You may follow the full tutorial provided in (Level 4) Share your code as a locally installable Python package.

⏩️ If you are an active open-source developer and are also familiar with GitHub Actions and forking workflows, we recommend you start from Level 5.

conda create -n skpkg-env scikit-package
conda activate skpkg-env
package create public

Follow the prompts to enter information for your package. You may follow the full tutorial provided in (Level 5) Share your code as a publicly installable package.

⏩️ If you are new to programming, start from Level 1. You will learn how to reuse code across files and folders. You will also learn how to write unit tests and use virtual (conda) environments. To get started, visit (Level 1-3) Reuse code within a file, across files and folders.

I am interested in migrating my existing package to the Level 5 public standard

Create a new environment with scikit-package installed:

conda create -n skpkg-env scikit-package black pre-commit
conda activate skpkg-env

Assuming a forking workflow, clone the repository and cd into the package folder:

cd <your-package-folder-path>

Then, three workflows will be introduced. First, you will lint your existing code using pre-commit. Then, you will migrate the source code, test files, and documentation to the new package directory created with package create public. Finally, you will check the content of the repository, include the license, and conduct functional testing. You may follow the complete step-by-step tutorial provided in Migrate your existing package with scikit-package.

I am interested in supporting Level 5 public from Level 4 system

To get started, follow the step-by-step instructions provided in Migrate your package from Level 4 to Level 5.

I want to publish my package on GitHub, PyPI, and conda-forge

In practice, here is how you can release your package on GitHub and PyPI using GitHub Actions:

git tag <version-number>
git push upstream <version-number>

To get started, follow the step-by-step instructions in Publish on GitHub and to PyPI. After release, if you want to make your package available on conda-forge, visit Create conda package with conda-forge.

I want to explore best practices for developing and publishing scientific code

The documentation covers, among other topics, how to write effective Git commit messages and news entries used for compiling the changelog, as well as a recommended workflow for developing and requesting new features within GitHub’s ecosystem. To get started, visit Billinge Group standards.