Skip to content

Commit 79d79f3

Browse files
committed
deploy: 1191048
1 parent 0949409 commit 79d79f3

40 files changed

+3105
-180
lines changed
Binary file not shown.

.doctrees/environment.pickle

204 KB
Binary file not shown.

.doctrees/index.doctree

2.04 KB
Binary file not shown.
-961 Bytes
Binary file not shown.
49.2 KB
Binary file not shown.
2.98 KB
Binary file not shown.

.doctrees/tutorials/intro.doctree

204 Bytes
Binary file not shown.
-340 Bytes
Binary file not shown.
99.5 KB
Binary file not shown.

_images/github-new-repo.png

527 KB
Loading

_images/license-github-root-dir.png

355 KB
Loading
Loading
Loading
Binary file not shown.
Loading

_images/view-license-github.png

538 KB
Loading

_sources/documentation/repository-files/license-files.md.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To select your license, we suggest that you use GitHub's
4747
[Choose a License tool ](https://choosealicense.com/).
4848

4949
If you choose your license when creating a new GitHub repository, you can also
50-
automatically get a text copy of the license file to add to your repo. However
50+
automatically get a text copy of the license file to add to your repository. However
5151
in some cases the license that you want is not available through that online
5252
process.
5353

@@ -78,9 +78,9 @@ with the license that you selected for your package.
7878
:::{admonition} An example of how a license determine how code can be reused
7979
:class: note
8080

81-
Let's use stackOverflow as an example that highlights how a license determines how code can or can not be used.
81+
Let's use StackOverflow as an example that highlights how a license determines how code can or can not be used.
8282

83-
[Stack overflow uses a Creative Commons Share Alike license.](https://stackoverflow.com/help/licensing). The sharealike license requires you to use the same sharealike license when you reuse any code from stackoverflow.
83+
[Stack overflow uses a Creative Commons Share Alike license.](https://stackoverflow.com/help/licensing). The sharealike license requires you to use the same sharealike license when you reuse any code from StackOverflow.
8484

8585
This means that technically, if you copy code from the Stack Overflow website, and use it in your package. And your packages uses a different license such as a MIT license, you are violating Stack Overflow's license requirements!
8686

@@ -92,7 +92,7 @@ This means that technically, if you copy code from the Stack Overflow website, a
9292

9393
While many permissive licenses do not require citation we STRONG encourage that you cite all software that you use in papers, blogs and other publications. You tell your users how to cite your package by using a [citation.cff file](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files). We will cover this topic when we talk about creating DOI's for your package using zenodo.
9494

95-
<!-- TODO: add link when lesson is created - but also we don't yet know how citation.cff files work with zenodo (do they work??) will the citation info update with a new zenodo link
95+
<!-- TODO: add link when lesson is created - but also we don't yet know how citation.cff files work with Zenodo (do they work??) will the citation info update with a new Zenodo link
9696

9797
These files - we need to understand if that date releases auto populates or forces zenodo to modify it's citation. if it's not dynamic it could be problematic
9898

_sources/index.md.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Community docs
5656

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

6161
The how to create a Python package tutorial series is being developed
6262
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).
@@ -67,18 +67,32 @@ by the community now! Join our community review process or watch development of
6767
:gutter: 3
6868

6969
::::{grid-item}
70-
71-
:::{card} ✿ Tutorials ✿
70+
:::{card} ✿ Create a Package Tutorials ✿
7271
:class-card: left-aligned
7372

7473
* [What is a Python package?](/tutorials/intro)
7574
* [Make your code installable](/tutorials/1-installable-code)
7675
* [Publish your package to (test) PyPi](/tutorials/publish-pypi)
77-
* *How to add a README and LICENSE to support publication (coming next!)*
78-
* *How to add metadata to a pyproject.toml file for publication to PyPI.*
76+
* [Publish your package to conda-forge](/tutorials/publish-conda-forge)
77+
78+
:::
79+
::::
80+
81+
::::{grid-item}
82+
:::{card} ✿ Package Metadata Tutorials ✿
83+
:class-card: left-aligned
7984

80-
_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_
85+
* [How to add a README file](/tutorials/add-readme)
86+
* [How to add metadata to a pyproject.toml file for publication to PyPI.](/tutorials/pyproject-toml.md)
87+
88+
:::
89+
::::
90+
91+
::::{grid-item}
92+
:::{card} ✿ Packaging Tool Tutorials ✿
93+
:class-card: left-aligned
8194

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

8397
:::
8498
::::

_sources/tutorials/1-installable-code.md.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,9 @@ file.
331331
[Learn more about the pyproject.toml format here.](../package-structure-code/pyproject-toml-python-package-metadata)
332332
:::
333333

334-
:::{todo}
334+
335335
You will learn more about the `pyproject.toml` format in the
336-
[next lesson when you add additional metadata / information to this file.](5-pyproject-toml.md)
337-
:::
336+
[next lesson when you add additional metadata / information to this file.](pyproject-toml.md)
338337

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

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

617-
:::{todo}
618-
This is the content with links once the links are live we can uncomment this and remove the unlinked content above!
619-
* Add a [README file](2-add-readme.md) and [LICENSE](4-add-license-file.md) to your package
616+
617+
* Add a [README file](add-readme.md) and [LICENSE](add-license-coc.md) to your package
620618
* [Add more metadata to your `pyproject.toml`](5-pyproject-toml.md) file to support PyPI publication.
621-
* [Learn how to build your package distribution](6-publish-pypi.md) files (**sdist** and **wheel**) and publish to **test PyPI**.
622-
* Finally you will learn how to publish to **conda-forge** from **PyPI**.
623-
:::
619+
* [Learn how to build your package distribution](publish-pypi) files (**sdist** and **wheel**) and publish to **test PyPI**.
620+
* Finally you will learn how to [publish to **conda-forge**](publish-conda-forge) from **PyPI**.
621+
624622

625623
## Footnotes
626624

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Add a LICENSE & CODE_OF_CONDUCT to your Python package
2+
3+
In the [previous lesson](add-readme) you:
4+
5+
<i class="fa-solid fa-circle-check" style="color: #703c87;"></i> Created a basic `README.md` file for your scientific Python package
6+
7+
<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.
8+
9+
:::{admonition} Learning objectives
10+
:class: tip
11+
12+
In this lesson you will learn:
13+
14+
1. How to select and add a `LICENSE` file to your package repository with a focus on the GitHub interface.
15+
2. How to add a `CODE_OF_CONDUCT` file to your package repository.
16+
3. How you can use the Contributors Covenant website to add generic language as a starting place for your `CODE_OF_CONDUCT`.
17+
:::
18+
19+
## What is a license?
20+
21+
A license contains legal language about how users can use and reuse your software. To set the LICENSE for your project, you:
22+
23+
1. create LICENSE file in your project directory that specifies the license that you choose for your package and
24+
2. reference that file in your pyproject.toml data where metadata are set.
25+
26+
By adding the LICENSE file to your pyproject.toml file, the LICENSE will be included in your package's metadata which is used to populate your package's PyPI landing page. The LICENSE is also used in your GitHub repository's landing page interface.
27+
28+
### What license should you use?
29+
30+
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
31+
license on [choosealicense.com](https://choosealicense.com/).
32+
33+
:::{admonition} Licenses for the scientific Python ecosystem
34+
[We discuss licenses for the scientific Python ecosystem in more detail here in our guidebook.](../documentation/repository-files/license-files)
35+
:::
36+
37+
### Where should the LICENSE file live
38+
39+
Your `LICENSE` file should be placed at the root of your package's repository.
40+
When you add the LICENSE at the root, GitHub will automagically discover it and
41+
provide users with a direct link to your license file within your GitHub
42+
repository.
43+
44+
:::{figure-md} github-coc-readme-license-tabs
45+
<img src="../images/license-github-root-dir.png" alt="Image showing the GitHub repository for SunPy an accepted pyOpenSci package." width="500px">
46+
47+
Notice at the top of the
48+
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
49+
the license that SunPy uses. These files are discovered by GitHub because they
50+
are placed in the root of the project directory using standard naming conventions.
51+
:::
52+
53+
54+
### How to add a LICENSE file to your package directory
55+
56+
There are several ways to add a LICENSE file:
57+
58+
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.
59+
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).
60+
3. You can add the file manually like we are doing in this lesson.
61+
62+
:::{tip}
63+
If you completed the past lessons including
64+
65+
1. [Making your code installable](1-installable-code.md) and
66+
2. [publishing your package to PyPI](publish-pypi.md)
67+
68+
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.
69+
70+
If you don't yet have a **LICENSE** file in your directory, then continue reading.
71+
:::
72+
73+
### How to add a LICENSE to your package - the manual way
74+
75+
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
76+
77+
1. Create a new file called LICENSE. If you are using shell you can type:
78+
79+
```
80+
# Create a license file in your shell
81+
> touch LICENSE
82+
```
83+
84+
1. Go to [choosealicense.com](https://choosealicense.com/)
85+
2. Select permissive license
86+
3. It will suggest that you use the [MIT license](https://choosealicense.com/licenses/mit/).
87+
4. Copy the license text that it provides into your LICENSE file that you created above.
88+
5. Save your file. You're all done!
89+
90+
:::{admonition} An overview of LICENSES in the scientific Python ecosystem
91+
:class: note
92+
93+
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.
94+
95+
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)
96+
:::
97+
98+
::::::{dropdown} Instructions for adding a license files within the GitHub interface
99+
:color: primary
100+
101+
:::::{tab-set}
102+
103+
::::{tab-item} Add license: new GitHub repository
104+
105+
When you create a new GitHub repository you can add a license
106+
through the GitHub interface.
107+
108+
:::{figure-md} github-new-repo
109+
110+
<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 repository. 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">
111+
112+
Image showing the GitHub interface that allows you to add a LICENSE and README file when you create a new repository.
113+
:::
114+
::::
115+
116+
::::{tab-item} Add License: Existing GitHub repository
117+
118+
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 repository.
119+
120+
- 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) .
121+
- 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.
122+
123+
:::{figure-md} view-license
124+
<img src="../images/tutorials/view-license-github.png" alt="Image showing what the LICENSE file looks like in the GItHub interface. At the top you can see the actual license which in this image is BSD 3-clause New or revised license. Then there is some text describing both what the license is and the associated permissions for that specific license. At the bottom of the image, the actual text for the license is shown in the LICENSE file." width="500px">
125+
126+
You can view a summary of the LICENSE chosen on your project's
127+
GitHub landing page.
128+
:::
129+
::::
130+
131+
:::::
132+
::::::
133+
134+
Now you know how to add a LICENSE to your project. Next, you'll learn
135+
about the `CODE_OF_CONDUCT.md` file and how to add it to your
136+
package directory.
137+
138+
(add-coc)=
139+
## What is a code of conduct file?
140+
141+
A `CODE_OF_CONDUCT` file is used to establish guidelines for how people in your community interact.
142+
143+
This file is critical to supporting your community as it
144+
grows. The `CODE_OF_CONDUCT`:
145+
146+
1. Establishes guidelines for how users and contributors interact with each other and you in your software repository.
147+
2. Identifies negative behaviors that you don't want in your interactions.
148+
149+
You can use your code of conduct as a tool that can be referenced when moderating challenging conversations.
150+
151+
### What to put in your code of conduct file
152+
153+
If you are unsure of what language to add to your `CODE_OF_CONDUCT`
154+
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.
155+
156+
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](#)
157+
158+
The `CODE_OF_CONDUCT.md` should be placed at the root of your project directory, similar to the LICENSE file.
159+
160+
### How to add a CODE_OF_CONDUCT file to your package directory
161+
162+
- Add a `CODE_OF_CONDUCT.md` file to the root of your repository if it doesn't already exist.
163+
164+
```bash
165+
> touch CODE_OF_CONDUCT.md
166+
```
167+
168+
- 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. Read the text closely to ensure you both understand it and also agree with its contents!
169+
170+
That's it - you've now added a code of conduct to your package directory.
171+
172+
:::{admonition} Additional Code of Conduct resources
173+
:class: note
174+
175+
- [<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)
176+
- [pyOpenSci package guide `CODE_OF_CONDUCT.md` overview](https://www.pyopensci.org/python-package-guide/documentation/repository-files/code-of-conduct-file.html)
177+
178+
:::
179+
180+
## <i class="fa-solid fa-hands-bubbles"></i> Wrap up
181+
182+
In this lesson and the [last lesson](add-readme), you have added a:
183+
184+
- `README` file;
185+
- `LICENSE` file and a
186+
- `CODE_OF_CONDUCT` file.
187+
188+
These are fundamental files needed for every scientific Python package
189+
repository. These files help users understand how to use your package and
190+
interact with package maintainers.
191+
192+
In the upcoming lessons, you will:
193+
194+
- [Add more metadata to your `pyproject.toml` file](pyproject-toml) to support building and publishing your package on PyPI.
195+
- Publish a new version of your Python package to (Test) PyPI to preview the
196+
updated metadata landing page.
197+
198+
---
199+
200+
## Footnotes
201+
202+
[^mit]: https://opensource.org/license/mit/
203+
[^bsd3]: https://opensource.org/license/bsd-3-clause/

0 commit comments

Comments
 (0)