You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/add-license-coc.md
+37-24Lines changed: 37 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@ In this lesson you will learn:
20
20
21
21
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.
22
22
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/).
24
25
25
26
:::{admonition} Licenses for the scientific Python ecosystem
26
27
[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
29
30
### Where should the LICENSE file live & how do you add it?
30
31
31
32
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
+
<imgsrc="../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
+
:::
32
45
33
46
There are several ways to add a license file:
34
47
@@ -57,6 +70,7 @@ If you don't already have a LICENSE file, and you are not yet using a platform s
57
70
# Create a license file in your shell
58
71
> touch LICENSE
59
72
```
73
+
60
74
1. Go to [choosealicense.com](https://choosealicense.com/)
61
75
2. Select permissive license
62
76
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
70
84
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)
71
85
:::
72
86
73
-
74
87
::::::{dropdown} Instructions for adding a license files within the GitHub interface
75
88
:color: primary
76
89
@@ -89,13 +102,12 @@ Image showing the GitHub interface that allows you to add a LICENSE and README f
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.
96
108
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.
@@ -110,7 +122,9 @@ You can also view a summary of the license on its GitHub landing page.```
110
122
(add-coc)=
111
123
## Add a CODE_OF_CONDUCT file to your repo
112
124
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
114
128
grows. The `CODE_OF_CONDUCT`:
115
129
116
130
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.
* 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.
133
145
134
146
:::{admonition} Additional Code of Conduct resources
Copy file name to clipboardExpand all lines: tutorials/publish-pypi.md
+23-24Lines changed: 23 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
# Publish your Python package to PyPI
2
2
3
3
:::{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?
8
9
9
10
```bash
10
11
pipx install hatch
@@ -51,7 +52,6 @@ You will learn how to publish to conda-forge in the [next lesson](7-publish-cond
51
52
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.
52
53
:::
53
54
54
-
55
55
## Test PyPI vs PyPI
56
56
57
57
There are two "warehouses" that you can use to publish
@@ -76,13 +76,13 @@ to PyPI. You need to:
76
76
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.
77
77
1.**Publish to PyPI using `hatch publish`**
78
78
79
-
80
79
In a future lesson, you will learn how to create an automated
81
80
GitHub action workflow that publishes an updated
82
81
version of your package to PyPI every time you create a GitHub release.
83
82
84
83
:::{admonition} Learn more about building Python packages in our guide
85
84
:class: tip
85
+
86
86
-[Learn more about what building a Python package is](../package-structure-code/python-package-distribution-files-sdist-wheel)
87
87
-[Learn more about package distribution file that PyPI needs called the wheel](#python-wheel)
88
88
-[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
139
139
tzdata 2023.4
140
140
```
141
141
142
-
143
142
At any time you can exit the environment using `exit`.
144
143
145
144
```bash
@@ -154,13 +153,13 @@ pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv took 43s
154
153
➜
155
154
```
156
155
157
-
158
156
### Hatch and environments
159
157
160
158
Behind the scenes when hatch creates a new virtual environment,
161
159
by default it uses venv[^venv] which is the default environment management tool that comes with Python installations.
162
160
163
161
Hatch will:
162
+
164
163
1. Create a new virtualenv (venv) that is located on your computer.
165
164
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.
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
+
:::
237
236
238
237
:::{figure-md} build-workflow-tutorial
239
238
<imgsrc="../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
242
241
the search box at the top of the test PyPI website.
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
268
266
269
267
### Follow the steps below to create your token.
270
268
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.
277
274
278
275
Your token should look something like this:
279
276
@@ -286,12 +283,12 @@ It should start with `pypi` followed by a dash and a bunch of characters.
286
283
Once you have your token, you are ready to publish to
287
284
PyPI.
288
285
289
-
* Run `hatch publish -r test`
286
+
- Run `hatch publish -r test`
290
287
291
288
`-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.
292
289
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:
295
292
296
293
```bash
297
294
❯ hatch publish -r test
@@ -321,7 +318,6 @@ landing page for your newly uploaded package.
321
318
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.
322
319
:::
323
320
324
-
325
321
As an example, [check out our pyOpenSci pyosPackage landing page on test PyPI](https://test.pypi.org/project/pyosPackage/). Notice that
326
322
the page has information about the current package version and also
327
323
installation instructions as follows:
@@ -335,9 +331,9 @@ testPyPI as a permanent way to install your package. Test PyPi is a perfect plac
335
331
336
332
### Time to install your package
337
333
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.
341
337
342
338
::::{tab-set}
343
339
@@ -348,9 +344,11 @@ you wish to install your newly published package in.
0 commit comments