Skip to content

Commit c2e399f

Browse files
committed
Fix: edits from review
1 parent 24ebbc9 commit c2e399f

File tree

3 files changed

+60
-48
lines changed

3 files changed

+60
-48
lines changed

images/license-github-root-dir.png

355 KB
Loading

tutorials/add-license-coc.md

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ In this lesson you will learn:
2020

2121
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.
2222

23-
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]).
23+
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
24+
license on [choosealicense.com](https://choosealicense.com/).
2425

2526
:::{admonition} Licenses for the scientific Python ecosystem
2627
[We discuss licenses for the scientific Python ecosystem in more detail here in our guidebook.](permissive-license)
@@ -29,6 +30,18 @@ We suggest that you use a permissive license that accommodates the other most co
2930
### Where should the LICENSE file live & how do you add it?
3031

3132
Your `LICENSE` file should be placed at the root of your package's repository.
33+
When you add the LICENSE at the root, GitHub will automagically discover it and
34+
provide users with a direct link to your license file within your GitHub
35+
repository.
36+
37+
:::{figure-md} github-coc-readme-license-tabs
38+
<img src="../images/license-github-root-dir.png" alt="Image showing the GitHub repository for SunPy an accepted pyOpenSci package." width="500px">
39+
40+
Notice at the top of the
41+
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
42+
the license that SunPy uses. These files are discovered by GitHub because they
43+
are placed in the root of the project directory using standard naming conventions.
44+
:::
3245

3346
There are several ways to add a license file:
3447

@@ -57,6 +70,7 @@ If you don't already have a LICENSE file, and you are not yet using a platform s
5770
# Create a license file in your shell
5871
> touch LICENSE
5972
```
73+
6074
1. Go to [choosealicense.com](https://choosealicense.com/)
6175
2. Select permissive license
6276
3. It will suggest that you use the [MIT license](https://choosealicense.com/licenses/mit/).
@@ -70,7 +84,6 @@ In the pyOpenSci [packaging guidebook](../documentation/repository-files/license
7084
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)
7185
:::
7286

73-
7487
::::::{dropdown} Instructions for adding a license files within the GitHub interface
7588
:color: primary
7689

@@ -89,13 +102,12 @@ Image showing the GitHub interface that allows you to add a LICENSE and README f
89102
:::
90103
::::
91104

92-
93105
::::{tab-item} Add License: Existing GitHub repository
94106

95-
If you already have a GitHub repo for your package, then you can add a LICENSE using the GitHub interface by adding a new file to the repo.
107+
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.
96108

97-
* 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) .
98-
* 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.
109+
- 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) .
110+
- 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.
99111

100112
:::{figure-md} view-license
101113
<img src="../images/tutorials/view-license-github.png" alt="sdfsdfsd nasdfjsdf" width="500px">
@@ -110,7 +122,9 @@ You can also view a summary of the license on its GitHub landing page.```
110122
(add-coc)=
111123
## Add a CODE_OF_CONDUCT file to your repo
112124

113-
Now that you have added a LICENSE to your project, you are ready to add a file called `CODE_OF_CONDUCT.md` to your package directory. A `CODE_OF_CONDUCT` file is critical to supporting your community as it
125+
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,.
126+
127+
A `CODE_OF_CONDUCT` file is critical to supporting your community as it
114128
grows. The `CODE_OF_CONDUCT`:
115129

116130
1. Establishes guidelines for how users and contributors interact with each other and you in your software repository.
@@ -123,40 +137,39 @@ file, we suggest that you adopt the [contributor covenant language](https://www.
123137

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

126-
127140
### Add your CODE_OF_CONDUCT file
128141

129-
* Add a `CODE_OF_CONDUCT.md` file to your repository if it doesn't
130-
already exist.
131-
* 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.
132-
142+
- Add a `CODE_OF_CONDUCT.md` file to your repository if it doesn't
143+
already exist.
144+
- 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.
133145

134146
:::{admonition} Additional Code of Conduct resources
135147
:class: note
136148

137-
* [<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)
138-
* [pyOpenSci package guide `CODE_OF_CONDUCT.md` overview](https://www.pyopensci.org/python-package-guide/documentation/repository-files/code-of-conduct-file.html)
149+
- [<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)
150+
- [pyOpenSci package guide `CODE_OF_CONDUCT.md` overview](https://www.pyopensci.org/python-package-guide/documentation/repository-files/code-of-conduct-file.html)
139151

140152
:::
141153

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

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

146-
* `README` file;
147-
* `LICENSE` file and a
148-
* `CODE_OF_CONDUCT` file.
158+
- `README` file;
159+
- `LICENSE` file and a
160+
- `CODE_OF_CONDUCT` file.
149161

150-
These are core files needed for every scientific Python package. In the upcoming
162+
These are fundamental files needed for every scientific Python package
163+
repository. These files help users understand how to use your package and
164+
interact with package maintainers. In the upcoming
151165
lessons, you will:
152166

153-
* [Flesh out your `pyproject.toml` file](pyproject-toml) to support building
154-
and publishing your package on PyPI.
155-
* Publish a new version of your Python package to (Test) PyPI to preview the
156-
updated metadata landing page.
157-
167+
- [Flesh out your `pyproject.toml` file](pyproject-toml) to support building
168+
and publishing your package on PyPI.
169+
- Publish a new version of your Python package to (Test) PyPI to preview the
170+
updated metadata landing page.
158171

159-
****
172+
---
160173

161174
## Footnotes
162175

tutorials/publish-pypi.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Publish your Python package to PyPI
22

33
:::{todo}
4-
* emphasize that we recommended the trusted publisher GitHub action for most maintainers
5-
* Make sure they add /dist to their .gitignore file. We have not discussed GitHub workflows anywhere yet. Where does that fit?
6-
* https://hatch.pypa.io/latest/intro/#existing-project <- hatch will migrate from setup.py for you - if we go with hatch then we may want to add this to the installable code lesson
7-
* Should we install hatch with pipx?
4+
5+
- emphasize that we recommended the trusted publisher GitHub action for most maintainers
6+
- Make sure they add /dist to their .gitignore file. We have not discussed GitHub workflows anywhere yet. Where does that fit?
7+
- https://hatch.pypa.io/latest/intro/#existing-project <- hatch will migrate from setup.py for you - if we go with hatch then we may want to add this to the installable code lesson
8+
- Should we install hatch with pipx?
89

910
```bash
1011
pipx install hatch
@@ -51,7 +52,6 @@ You will learn how to publish to conda-forge in the [next lesson](7-publish-cond
5152
You need to build your Python package in order to publish it to PyPI (or Conda). The build process organizes your code and metadata into a distribution format that can be uploaded to PyPI and subsequently downloaded and installed by users.
5253
:::
5354

54-
5555
## Test PyPI vs PyPI
5656

5757
There are two "warehouses" that you can use to publish
@@ -76,13 +76,13 @@ to PyPI. You need to:
7676
1. **Create an account on (test) PyPI**: You will need to create a PyPI account and associated token which provides permissions for you to upload your package.
7777
1. **Publish to PyPI using `hatch publish`**
7878

79-
8079
In a future lesson, you will learn how to create an automated
8180
GitHub action workflow that publishes an updated
8281
version of your package to PyPI every time you create a GitHub release.
8382

8483
:::{admonition} Learn more about building Python packages in our guide
8584
:class: tip
85+
8686
- [Learn more about what building a Python package is](../package-structure-code/python-package-distribution-files-sdist-wheel)
8787
- [Learn more about package distribution file that PyPI needs called the wheel](#python-wheel)
8888
- [Learn more about the package distribution file that conda-forge will need on PyPI called the sdist (source distribution)](#python-source-distribution)
@@ -139,7 +139,6 @@ six 1.16.0
139139
tzdata 2023.4
140140
```
141141

142-
143142
At any time you can exit the environment using `exit`.
144143

145144
```bash
@@ -154,13 +153,13 @@ pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv took 43s
154153
155154
```
156155

157-
158156
### Hatch and environments
159157

160158
Behind the scenes when hatch creates a new virtual environment,
161159
by default it uses venv[^venv] which is the default environment management tool that comes with Python installations.
162160

163161
Hatch will:
162+
164163
1. Create a new virtualenv (venv) that is located on your computer.
165164
2. Install your package into the environment in editable mode (similar to `pip install -e`). This means it installs both your project and your project's dependencies as declared in your pyproject.toml file.
166165

@@ -232,8 +231,8 @@ Example: `pyosPackage_yourNameHere`.
232231
Show them how to do this
233232

234233
1. update the project-name in the pyproject.toml file
235-
2. update the module repo directory to be the same
236-
:::
234+
2. update the module repository directory to be the same
235+
:::
237236

238237
:::{figure-md} build-workflow-tutorial
239238
<img src="../images/tutorials/testpypi-search.png" alt="This is a screenshot of the test PyPI website. At the top in the search bar, you can see the search for pyosPackage. The search return says there were no results for pyosPackage Did you mean probpackage" width="700px">
@@ -242,7 +241,6 @@ Before you try to upload to test PyPI, check to see if the name of your package
242241
the search box at the top of the test PyPI website.
243242
:::
244243

245-
246244
:::{admonition} Setup 2-factor (2FA) authentication
247245

248246
2-factor authentication is a secure login process that allows you to
@@ -268,12 +266,11 @@ It's ideal to create a package-specific token. When you create an account wide t
268266

269267
### Follow the steps below to create your token.
270268

271-
* Login to test PyPI and go to your account settings
272-
* Scroll down to the **API tokens** section
273-
* Click on the **Add API Token** button
274-
* If you are new to using PyPI and don't have any packages there yet, OR if you have other packages on PyPI but are uploading a new package, you will need to create an account-wide token.
275-
* When you create your token, be sure to copy the token value and store it in a secure place before closing that browser.
276-
269+
- Login to test PyPI and go to your account settings
270+
- Scroll down to the **API tokens** section
271+
- Click on the **Add API Token** button
272+
- If you are new to using PyPI and don't have any packages there yet, OR if you have other packages on PyPI but are uploading a new package, you will need to create an account-wide token.
273+
- When you create your token, be sure to copy the token value and store it in a secure place before closing that browser.
277274

278275
Your token should look something like this:
279276

@@ -286,12 +283,12 @@ It should start with `pypi` followed by a dash and a bunch of characters.
286283
Once you have your token, you are ready to publish to
287284
PyPI.
288285

289-
* Run `hatch publish -r test`
286+
- Run `hatch publish -r test`
290287

291288
`-r` stands for repository. In this case because you are publishing to test-PyPI you will use `-r test`. Hatch will then ask for a username and credentials.
292289

293-
* Add the word `__token__` for your username. This tells Test PyPI that you are using a token value rather than a username.
294-
* Paste your PyPI token value in at the `Enter your credentials` prompt:
290+
- Add the word `__token__` for your username. This tells Test PyPI that you are using a token value rather than a username.
291+
- Paste your PyPI token value in at the `Enter your credentials` prompt:
295292

296293
```bash
297294
❯ hatch publish -r test
@@ -321,7 +318,6 @@ landing page for your newly uploaded package.
321318
This is an example landing page for the pyosPackage that was just uploaded. Notice at the top of the page there is instruction for how to install the package from test PyPI. You can simply copy that code and use it to install your package from testPyPi locally.
322319
:::
323320

324-
325321
As an example, [check out our pyOpenSci pyosPackage landing page on test PyPI](https://test.pypi.org/project/pyosPackage/). Notice that
326322
the page has information about the current package version and also
327323
installation instructions as follows:
@@ -335,9 +331,9 @@ testPyPI as a permanent way to install your package. Test PyPi is a perfect plac
335331

336332
### Time to install your package
337333

338-
* On your computer, activate the development environment that
339-
you wish to install your newly published package in.
340-
* Run the installation instructions for your package from test PyPI.
334+
- On your computer, activate the development environment that
335+
you wish to install your newly published package in.
336+
- Run the installation instructions for your package from test PyPI.
341337

342338
::::{tab-set}
343339

@@ -348,9 +344,11 @@ you wish to install your newly published package in.
348344
> pip install -i https://test.pypi.org/simple/ youPackageNameHere
349345
> conda list
350346
```
347+
351348
:::
352349

353350
:::{tab-item} venv mac / Linux
351+
354352
```bash
355353
> hatch shell
356354
> pip install -i https://test.pypi.org/simple/ youPackageNameHere
@@ -412,3 +410,4 @@ You will learn how to do that in the next lesson.
412410
## Footnotes
413411
414412
[^venv]: https://docs.python.org/3/library/venv.html
413+
```

0 commit comments

Comments
 (0)