Skip to content

Rename 1-installable-code to installable-code #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: license-pyproject
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/license-github-root-dir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tutorials/github-new-repo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 21 additions & 7 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Community docs

Publish your docs
```
## _new_ Tutorial series - how to create a Python package
## _new_ Tutorial Series: How to Create a Python Package

The how to create a Python package tutorial series is being developed
by the community now! Join our community review process or watch development of these tutorials in our [Github repo here](https://github.com/pyOpenSci/python-package-guide).
Expand All @@ -67,18 +67,32 @@ by the community now! Join our community review process or watch development of
:gutter: 3

::::{grid-item}

:::{card} ✿ Tutorials ✿
:::{card} ✿ Create a Package Tutorials ✿
:class-card: left-aligned

* [What is a Python package?](/tutorials/intro)
* [Make your code installable](/tutorials/1-installable-code)
* [Make your code installable](/tutorials/installable-code)
* [Publish your package to (test) PyPi](/tutorials/publish-pypi)
* *How to add a README and LICENSE to support publication (coming next!)*
* *How to add metadata to a pyproject.toml file for publication to PyPI.*
* [Publish your package to conda-forge](/tutorials/publish-conda-forge)

:::
::::

::::{grid-item}
:::{card} ✿ Package Metadata Tutorials ✿
:class-card: left-aligned

_The third lesson is currently under review in our [GitHub Repo here](https://github.com/pyOpenSci/python-package-guide/pulls). It will be live by the end of Feb 2024_
* [How to add a README file](/tutorials/add-readme)
* [How to add metadata to a pyproject.toml file for publication to PyPI.](/tutorials/pyproject-toml.md)

:::
::::

::::{grid-item}
:::{card} ✿ Packaging Tool Tutorials ✿
:class-card: left-aligned

* [Introduction to Hatch](/tutorials/get-to-know-hatch)

:::
::::
Expand Down
177 changes: 177 additions & 0 deletions tutorials/add-license-coc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Add a LICENSE & CODE_OF_CONDUCT to your Python package

In the [previous lesson](add-readme) you:

<i class="fa-solid fa-circle-check" style="color: #703c87;"></i> Created a basic `README.md` file for your scientific Python package

<i class="fa-solid fa-circle-check" style="color: #703c87;"></i> Learned about the core components that are useful to have in a README file.

:::{admonition} Learning objectives
:class: tip

In this lesson you will learn:

1. How to select and add a `LICENSE` file to your package repository with a focus on the GitHub interface.
2. How to add a `CODE_OF_CONDUCT` file to your package repository.
3. How you can use the Contributors Covenant website to add generic language as a starting place for your `CODE_OF_CONDUCT`.
:::

## Add a LICENSE file to your project directory

A license contains legal language about how users can use and reuse your software. You should include a LICENSE file in your project directory that specifies the license that you choose for your package.

We suggest that you use a permissive license that accommodates the other most commonly used licenses in the scientific Python ecosystem (MIT[^mit] and BSD-3[^bsd3]). If you are unsure, use MIT given it's the generally recommended
license on [choosealicense.com](https://choosealicense.com/).

:::{admonition} Licenses for the scientific Python ecosystem
[We discuss licenses for the scientific Python ecosystem in more detail here in our guidebook.](permissive-license)
:::

### Where should the LICENSE file live & how do you add it?

Your `LICENSE` file should be placed at the root of your package's repository.
When you add the LICENSE at the root, GitHub will automagically discover it and
provide users with a direct link to your license file within your GitHub
repository.

:::{figure-md} github-coc-readme-license-tabs
<img src="../images/license-github-root-dir.png" alt="Image showing the GitHub repository for SunPy an accepted pyOpenSci package." width="500px">

Notice at the top of the
README portion of the GitHub landing page, there are three tabs directly linking to the README file which is visible, the CODE_OF_CONDUCT file and one that specifies
the license that SunPy uses. These files are discovered by GitHub because they
are placed in the root of the project directory using standard naming conventions.
:::

There are several ways to add a license file:

1. When you create a new repository on GitHub, it will ask you if you wish to add a `LICENSE` file at that time. If you select yes, it will create the file for you.
2. You can add a license through the GitHub gui following the [<i class="fa-brands fa-github"></i> instructions here](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository).
3. You can add the file manually like we are doing in this lesson.

:::{tip}
If you completed the past lessons including

1. [Making your code installable](installable-code.md) and
2. [publishing your package to PyPI](publish-pypi.md)

then you already have a **LICENSE** file containing text for the MIT license in your Python package. Thus you can skip to the next section of this tutorial which walks you through adding a CODE_OF_CONDUCT.

If you don't yet have a **LICENSE** file in your directory, then continue reading.
:::

### How to add a LICENSE to your existing GitHub repository

If you don't already have a LICENSE file, and you are not yet using a platform such as GitHub or GitLab, then you can create a license file by

1. Create a new file called LICENSE. If you are using a shell you can use:

```
# Create a license file in your shell
> touch LICENSE
```

1. Go to [choosealicense.com](https://choosealicense.com/)
2. Select permissive license
3. It will suggest that you use the [MIT license](https://choosealicense.com/licenses/mit/).
4. Copy the license text that it provides into your LICENSE file that you created above.

:::{admonition} An overview of LICENSES in the scientific Python ecosystem
:class: note

In the pyOpenSci [packaging guidebook](../documentation/repository-files/license-files), we provide an overview of license in the scientific Python ecosystem. We review why license files are important, which ones are most commonly used for scientific software and how to select the correct license.

If you want a broad overview of why licenses are important for protecting open source software, [check out this blog post that overviews the legal side of things.](https://opensource.guide/legal/#just-give-me-the-tldr-on-what-i-need-to-protect-my-project)
:::

::::::{dropdown} Instructions for adding a license files within the GitHub interface
:color: primary

:::::{tab-set}

::::{tab-item} Add license: new GitHub repository

When you create a new GitHub repository you can add a license
through the GitHub interface.

:::{figure-md} github-new-repo

<img src="../images/tutorials/github-new-repo.png" alt="Screenshot of the create new repository interface that GitHub provides. The elements of this are the owner and repository name for the new repo. Below that you can add a description of the repo. Below that you can set it to be public or private. At the bottom of the interface there is an Add a README checkbox where it will add a blank readme file for you. At the very bottom there is a line to add a .gitignore file and another to choose a license." width="500px">

Image showing the GitHub interface that allows you to add a LICENSE and README file when you create a new repository.
:::
::::

::::{tab-item} Add License: Existing GitHub repository

If you already have a GitHub repository for your package, then you can add a LICENSE using the GitHub interface by adding a new file to the repo.

- Follow the instructions to select and add a license to your repository on the [GitHub LICENSE page](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository) .
- Once you have added your LICENSE file, be sure to sync your git local repository with the repository on GitHub.com. This means running `git pull` to update your local branch.

:::{figure-md} view-license
<img src="../images/tutorials/view-license-github.png" alt="sdfsdfsd nasdfjsdf" width="500px">

You can also view a summary of the license on its GitHub landing page.```
:::
::::

:::::
::::::

(add-coc)=
## Add a CODE_OF_CONDUCT file to your repo

Now that you have added a LICENSE to your project, you are ready to add a `CODE_OF_CONDUCT.md` to your package directory. The `CODE_OF_CONDUCT.md` should be placed at the root of your project directory, similar to the LICENSE file,.

A `CODE_OF_CONDUCT` file is critical to supporting your community as it
grows. The `CODE_OF_CONDUCT`:

1. Establishes guidelines for how users and contributors interact with each other and you in your software repository.
2. Identifies negative behaviors that you don't want in your interactions.

You can use your code of conduct as a tool that can be referenced when moderating challenging conversations.

If you are unsure of what language to add to your `CODE_OF_CONDUCT`
file, we suggest that you adopt the [contributor covenant language](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) as a starting place.

[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](#)

### Add your CODE_OF_CONDUCT file

- Add a `CODE_OF_CONDUCT.md` file to your repository if it doesn't
already exist.
- Visit the [contributor covenant website](https://www.contributor-covenant.org/) and add [the markdown version of their code of conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) to your `CODE_OF_CONDUCT.md` file.

:::{admonition} Additional Code of Conduct resources
:class: note

- [<i class="fa-brands fa-github"></i> Guide: `CODE_OF_CONDUCT.md` files](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-code-of-conduct-to-your-project)
- [pyOpenSci package guide `CODE_OF_CONDUCT.md` overview](https://www.pyopensci.org/python-package-guide/documentation/repository-files/code-of-conduct-file.html)

:::

## <i class="fa-solid fa-hands-bubbles"></i> Wrap up

In this lesson and the [last lesson](add-readme), you have added a:

- `README` file;
- `LICENSE` file and a
- `CODE_OF_CONDUCT` file.

These are fundamental files needed for every scientific Python package
repository. These files help users understand how to use your package and
interact with package maintainers. In the upcoming
lessons, you will:

- [Flesh out your `pyproject.toml` file](pyproject-toml) to support building
and publishing your package on PyPI.
- Publish a new version of your Python package to (Test) PyPI to preview the
updated metadata landing page.

---

## Footnotes

[^mit]: https://opensource.org/license/mit/
[^bsd3]: https://opensource.org/license/bsd-3-clause/
5 changes: 4 additions & 1 deletion tutorials/add-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ Short description here using non-technical language that describes what your pac

## How to install pyosPackage

<todo - when i add more to the pyos package this can use that readme>
:::{todo}
- when i add more to the pyos package this can use that readme>
:::

To install this package run:

`pip install pyosPackage`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,9 @@ file.
[Learn more about the pyproject.toml format here.](../package-structure-code/pyproject-toml-python-package-metadata)
:::

:::{todo}

You will learn more about the `pyproject.toml` format in the
[next lesson when you add additional metadata / information to this file.](5-pyproject-toml.md)
:::
[next lesson when you add additional metadata / information to this file.](pyproject-toml.md)

- Open up the `pyproject.toml` file that Hatch created in your favorite text editor. It should look something like the example below.

Expand Down Expand Up @@ -614,13 +613,12 @@ In the upcoming lessons you will:
* Add more metadata to your `pyproject.toml` file to support PyPI publication.
* learn how to publish to **conda-forge** from **PyPI**.

:::{todo}
This is the content with links once the links are live we can uncomment this and remove the unlinked content above!
* Add a [README file](2-add-readme.md) and [LICENSE](4-add-license-file.md) to your package

* Add a [README file](add-readme.md) and [LICENSE](add-license-coc.md) to your package
* [Add more metadata to your `pyproject.toml`](5-pyproject-toml.md) file to support PyPI publication.
* [Learn how to build your package distribution](6-publish-pypi.md) files (**sdist** and **wheel**) and publish to **test PyPI**.
* Finally you will learn how to publish to **conda-forge** from **PyPI**.
:::
* [Learn how to build your package distribution](publish-pypi) files (**sdist** and **wheel**) and publish to **test PyPI**.
* Finally you will learn how to [publish to **conda-forge**](publish-conda-forge) from **PyPI**.


## Footnotes

Expand Down
10 changes: 6 additions & 4 deletions tutorials/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ Get to know Hatch <get-to-know-hatch>

:::{toctree}
:hidden:
:caption: Create a Python package
:caption: Create a Python Package

What is a Python package? <self>
Make your code installable <1-installable-code>
Make your code installable <installable-code>
Publish to PyPI <publish-pypi>
Publish to conda-forge <publish-conda-forge>
:::

:::{toctree}
:hidden:
:caption: Project Metadata
:caption: Citation, License & Project metadata

Add README file <add-readme>
Add a license & COC <add-license-coc>
Update metadata <pyproject-toml>
:::

:::{admonition} Learning Objectives
Expand Down Expand Up @@ -345,5 +347,5 @@ The elements above are also important for future maintenance of your package. In
In future lessons you will learn more about the infrastructure around a published Python package that makes it both easier to maintain, easier for others to contribute to and easier for other scientists to use. However, first we want to get you to your initial goal of publishing a Python package.

In this next lesson you will learn how to create a basic installable Python package.
Make your code pip installable <1-installable-code>
Make your code pip installable <installable-code>
:::
4 changes: 2 additions & 2 deletions tutorials/publish-conda-forge.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

In the previous lessons, you've learned:

1. How to [create the most basic version of a Python package](1-installable-code.md). This entailed making your code installable.
1. How to [create the most basic version of a Python package](installable-code.md). This entailed making your code installable.
2. [How to publish your Python package to PyPI](publish-pypi)
3. How to add a `README` and `LICENSE` file to your package
4. How to setup your `pyproject.toml` file with all of the metadata that PyPI requires and also metadata that will be helpful for users to find your package.
Expand Down Expand Up @@ -468,7 +468,7 @@ Review the pull request. If all tests are passing, you can merge it. Shortly aft
If you have walked through this entire tutorial series you have now:

1. Understand [what a Python package is ](intro.md)
2. Know how to [make your code installable](1-installable-code.md) into Python environments
2. Know how to [make your code installable](installable-code.md) into Python environments
3. Know how to create a pyproject.toml file, a README file, and a License and code of conduct.
4. Know how to [publish your package to PyPI](publish-pypi.md) and
5. Know how to publish your package to conda-forge
Expand Down
Loading