Skip to content

Commit 9ce4bc1

Browse files
merge main
2 parents 15f6040 + 6a58271 commit 9ce4bc1

17 files changed

+224
-90
lines changed

.all-contributorsrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,17 @@
461461
"review",
462462
"tutorial"
463463
]
464+
},
465+
{
466+
"login": "tomalrussell",
467+
"name": "Tom Russell",
468+
"avatar_url": "https://avatars.githubusercontent.com/u/2762769?v=4",
469+
"profile": "https://github.com/tomalrussell",
470+
"contributions": [
471+
"code",
472+
"review",
473+
"tutorial"
474+
]
464475
}
465476
],
466477
"contributorsPerLine": 7,

.zenodo.json

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@
109109
"affiliation": "",
110110
"name": "Van der Walt, Stéfan"
111111
},
112-
{
113-
"type": "Other",
114-
"affiliation": "",
115-
"name": "Schwartz, Eli"
116-
},
117112
{
118113
"type": "Other",
119114
"affiliation": "Quansight",
@@ -201,6 +196,36 @@
201196
"affiliation": "",
202197
"name": "Knorps, Maria"
203198
},
199+
{
200+
"type": "Other",
201+
"affiliation": "",
202+
"name": "Schwartz, Eli"
203+
},
204+
{
205+
"type": "Other",
206+
"affiliation": "",
207+
"name": "Burns, Jackson"
208+
},
209+
{
210+
"type": "Other",
211+
"affiliation": "",
212+
"name": "Jaimergp"
213+
},
214+
{
215+
"type": "Other",
216+
"affiliation": "",
217+
"name": "h-vetinari"
218+
},
219+
{
220+
"type": "Other",
221+
"affiliation": "",
222+
"name": "Ogasawara, Ivan"
223+
},
224+
{
225+
"type": "Other",
226+
"affiliation": "",
227+
"name": "Russell, Tom"
228+
},
204229
{
205230
"type": "Other",
206231
"affiliation": "",

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <img src="https://www.pyopensci.org/images/logo.png" width=100 /> pyOpenSci scientific Python Packaging Guide
22
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
3-
[![All Contributors](https://img.shields.io/badge/all_contributors-44-orange.svg?style=flat-square)](#contributors-)
3+
[![All Contributors](https://img.shields.io/badge/all_contributors-45-orange.svg?style=flat-square)](#contributors-)
44
<!-- ALL-CONTRIBUTORS-BADGE:END -->
55

66
![GitHub release (latest by date)](https://img.shields.io/github/v/release/pyopensci/python-package-guide?color=purple&display_name=tag&style=plastic)
@@ -131,6 +131,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
131131
<tr>
132132
<td align="center" valign="top" width="14.28%"><a href="https://github.com/h-vetinari"><img src="https://avatars.githubusercontent.com/u/33685575?v=4?s=100" width="100px;" alt="h-vetinari"/><br /><sub><b>h-vetinari</b></sub></a><br /><a href="https://github.com/pyOpenSci/python-package-guide/commits?author=h-vetinari" title="Code">💻</a> <a href="https://github.com/pyOpenSci/python-package-guide/pulls?q=is%3Apr+reviewed-by%3Ah-vetinari" title="Reviewed Pull Requests">👀</a> <a href="#tutorial-h-vetinari" title="Tutorials">✅</a></td>
133133
<td align="center" valign="top" width="14.28%"><a href="https://xmnlab.github.io"><img src="https://avatars.githubusercontent.com/u/5209757?v=4?s=100" width="100px;" alt="Ivan Ogasawara"/><br /><sub><b>Ivan Ogasawara</b></sub></a><br /><a href="https://github.com/pyOpenSci/python-package-guide/commits?author=xmnlab" title="Code">💻</a> <a href="https://github.com/pyOpenSci/python-package-guide/pulls?q=is%3Apr+reviewed-by%3Axmnlab" title="Reviewed Pull Requests">👀</a> <a href="#tutorial-xmnlab" title="Tutorials">✅</a></td>
134+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tomalrussell"><img src="https://avatars.githubusercontent.com/u/2762769?v=4?s=100" width="100px;" alt="Tom Russell"/><br /><sub><b>Tom Russell</b></sub></a><br /><a href="https://github.com/pyOpenSci/python-package-guide/commits?author=tomalrussell" title="Code">💻</a> <a href="https://github.com/pyOpenSci/python-package-guide/pulls?q=is%3Apr+reviewed-by%3Atomalrussell" title="Reviewed Pull Requests">👀</a> <a href="#tutorial-tomalrussell" title="Tutorials">✅</a></td>
134135
</tr>
135136
</tbody>
136137
</table>

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ by the community now! Join our community review process or watch development of
7171
:class-card: left-aligned
7272

7373
* [What is a Python package?](/tutorials/intro)
74-
* [Make your code installable](/tutorials/1-installable-code)
74+
* [Make your code installable](/tutorials/installable-code)
7575
* [Publish your package to (test) PyPi](/tutorials/publish-pypi)
7676
* [Publish your package to conda-forge](/tutorials/publish-conda-forge)
7777

package-structure-code/publish-python-package-pypi-conda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Below you will learn more specifics about the differences between PyPI and conda
1919
:::
2020

2121

22-
:::{figure-md} pypi-conda-channels
22+
:::{figure-md} upload-conda-forge
2323

2424
<img src="../images/publish-python-package-pypi-conda.png" alt="Image showing the progression of creating a Python package, building it and then publishing to PyPI and conda-forge. You take your code and turn it into distribution files (sdist and wheel) that PyPI accepts. then there is an arrow towards the PyPI repository where ou publish both distributions. From PyPI if you create a conda-forge recipe you can then publish to conda-forge. " width="700px">
2525

package-structure-code/python-package-build-tools.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ Build your sdist and wheel distributions|✅|Poetry will build your sdist and wh
403403

404404
<!-- TODO: responses here on poetry's future dev work: https://github.com/python-poetry/poetry/discussions/7525 -->
405405

406+
(challenges-with-poetry)=
406407
### Challenges with Poetry
407408

408409
Some challenges of Poetry include:

package-structure-code/python-package-distribution-files-sdist-wheel.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Learn about Building a Python Package
22

33

4-
:::{figure-md} pypi-conda-channels
4+
:::{figure-md} pypi-conda-overview
55

66
<img src="../images/publish-python-package-pypi-conda.png" alt="Image showing the progression of creating a Python package, building it and then publishing to PyPI and conda-forge. You take your code and turn it into distribution files (sdist and wheel) that PyPI accepts. then there is an arrow towards the PyPI repository where ou publish both distributions. From PyPI if you create a conda-forge recipe you can then publish to conda-forge. " width="700px">
77

88
Once you have published both package distributions (the source distribution and the wheel) to PyPI, you can then publish to conda-forge. conda-forge requires an source distribution on PyPI in order to build your package on conda-forge. You do not need to rebuild your package to publish to conda-forge.
99
:::
1010

1111
You need to build your Python package in order to publish it to PyPI (or a conda channel). 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. NOTE: you need to publish a sdist to PyPI in order for conda-forge to properly build your package automatically.
12-
:::
1312

1413
(build-package)=
1514
## What is building a Python package?

tests/run-tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Python versions.
1616

1717

1818

19-
### Tools to run your tests
19+
## Tools to run your tests
2020

2121
There are three categories of tools that will make is easier to setup
2222
and run your tests in various environments:
@@ -80,7 +80,7 @@ extensions that can be used to add functionality such as:
8080
- [pytest-cov](https://pytest-cov.readthedocs.io/en/latest/) allows you to analyze the code coverage of your package during your tests, and generates a report that you can [upload to codecov](https://codecov.io/).
8181

8282
:::{todo}
83-
[Learn more about code coverage here.](code-cov)
83+
Learn more about code coverage here. (add link)
8484
:::
8585

8686
```{note}

tests/tests-ci.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CI can also be triggered for pull requests and pushes to your repository. This m
66

77
::::{todo}
88
```{note}
9-
[Learn more about Continuous Integration and how it can be used, here.](ci)
9+
Learn more about Continuous Integration and how it can be used, here. (add link)
1010
```
1111
::::
1212

tutorials/add-license-coc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ There are several ways to add a LICENSE file:
6262
:::{tip}
6363
If you completed the past lessons including
6464

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

6868
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.
@@ -153,7 +153,7 @@ You can use your code of conduct as a tool that can be referenced when moderatin
153153
If you are unsure of what language to add to your `CODE_OF_CONDUCT`
154154
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.
155155

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

158158
The `CODE_OF_CONDUCT.md` should be placed at the root of your project directory, similar to the LICENSE file.
159159

tutorials/add-readme.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
In the previous lessons you learned:
44

55
1. [What a Python package is](intro.md)
6-
2. [How to make your code installable](1-installable-code)
6+
2. [How to make your code installable](installable-code)
77
3. [How to publish your package to (test) PyPI](publish-pypi.md)
88
4. [How to publish your package to conda-forge](publish-conda-forge.md)
99

@@ -196,6 +196,10 @@ Short description here using non-technical language that describes what your pac
196196

197197
## How to install pyosPackage
198198

199+
:::{todo}
200+
- when i add more to the pyos package this can use that readme>
201+
:::
202+
199203
To install this package run:
200204

201205
`pip install pyosPackage`
@@ -217,11 +221,14 @@ You can also add any links to tutorials in your documentation here.
217221

218222
## Community
219223

220-
Add information here about contributing to your package. Be sure to add links to your `CODE_OF_CONDUCT.md` file and your development guide. For now this section might be empty. You can go back and fill it in later.
224+
Add information here about contributing to your package. Be sure to add links to your
225+
`CODE_OF_CONDUCT.md` file and your development guide. For now this section might be
226+
empty. You can go back and fill it in later.
221227

222228
## How to cite pyosPackage
223229

224230
citation information here
231+
````
225232

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

tutorials/get-to-know-hatch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ hatch config show will print out the contents of your config.toml file in your s
111111
Hatch offers a suite of features that will make creating, publishing
112112
and maintaining your Python package easier.
113113

114-
:::{admonition}
114+
:::{admonition} Comparison to other tools
115115
:class: tip
116116
[We compared hatch to several of the other popular packaging tools in the ecosystem including flit, pdm and poetry. Learn more here](package-features)
117117
:::

tutorials/1-installable-code.md renamed to tutorials/installable-code.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,9 @@ pyospackage # This is your project directory
229229

230230
```
231231

232-
## Step 2: Add code to your package
232+
## Step 2: Add module to your package
233233

234-
Within the `pyospackage` subdirectory, add one or more Python modules.
235-
A Python module refers to a `.py` file containing the code that you want your package to access and run.
234+
A Python module refers to a `.py` file containing the code that you want your package to access and run. Within the `pyospackage` subdirectory, add at least one Python modules (.py files).
236235

237236
If you don't have code already and are just learning how to create a Python package, then create an empty `add_numbers.py` file. You will
238237
populate the `add_numbers.py` file with code provided below.
@@ -258,7 +257,7 @@ pyospackage/
258257
├── add_numbers.py
259258
```
260259

261-
## Step 3. Add code to your `add_numbers.py` module
260+
## Step 3: Add code to your module
262261

263262
If you are following along and making a Python package from scratch then you can add the code below to your `add_numbers.py` module. The function below adds two integers together and returns the result. Notice that the code below has a few features that we will review in future tutorials:
264263

@@ -298,7 +297,7 @@ def add_num(a: int, b: int) -> int:
298297
return a + b
299298
```
300299

301-
## Step 4. Modify metadata in your `pyproject.toml` file
300+
## Step 4: Modify metadata in your `pyproject.toml` file
302301

303302
Next, you will modify some of the metadata (information) that
304303
Hatch adds to your `pyproject.toml` file. You are
@@ -404,18 +403,28 @@ You will learn how to automate defining a package
404403
version using git tags in the version and release your package lesson.
405404
:::
406405

407-
### Step 3: Adjust your project classifiers
406+
### OPTIONAL: Adjust project classifiers
408407

409408
Hatch by default provides a list of classifiers that define what
410-
Python versions your package supports. While this won't impact your package build, let's remove some of them that you likely don't need.
409+
Python versions your package supports. These classifiers do not
410+
in any way impact your package's build and are primarily
411+
intended to be used when you publish your package to PyPI.
411412

412-
* Remove support for python 3.8
413+
If you don't plan on publishing to PyPI, you can skip this section.
414+
However, if you wish, you can clean it up a bit.
413415

414-
Also because we are assuming you're creating a pure Python package, you can remove the following classifiers:
416+
To begin:
417+
418+
* Remove support for Python 3.8
419+
420+
Also because you are creating a pure Python package, you can
421+
in this lesson, you can remove the following classifiers:
415422

416423
```toml
424+
classifiers = [
417425
"Programming Language :: Python :: Implementation :: CPython",
418426
"Programming Language :: Python :: Implementation :: PyPy",
427+
]
419428
```
420429

421430
Your new pyproject.toml file should now look something like this:
@@ -462,7 +471,7 @@ Once you have your project metadata in the pyproject.toml file, you will
462471
rarely update it. In the next lesson you’ll add more metadata and structure to this file.
463472
:::
464473

465-
## Step 5. Install your package locally
474+
## Step 5: Install your package locally
466475

467476
At this point you should have:
468477

@@ -480,7 +489,7 @@ While you can do this using hatch, we are going to use pip for this lesson, so y
480489

481490
:::{todo}
482491
Add this back in when the lesson is published
483-
- Activate the Python environment that you wish to use. If you need help with working with virtual environments [check out this lesson](extras/1-create-environment.md).
492+
- Activate the Python environment that you wish to use. If you need help with working with virtual environments check out this lesson (add link).
484493
:::
485494

486495
```bash
@@ -562,7 +571,7 @@ pyosPackage 0.1.0 /Users/yourusername/path/here/pyosP
562571
...
563572
```
564573
565-
## 6. Test out your new package
574+
## Step 6: Test out your new package
566575
567576
After installing your package, type “python” at the command prompt in your chosen terminal to start
568577
a Python session in your active Python environment.
@@ -613,13 +622,11 @@ In the upcoming lessons you will:
613622
* Add more metadata to your `pyproject.toml` file to support PyPI publication.
614623
* learn how to publish to **conda-forge** from **PyPI**.
615624
616-
617625
* Add a [README file](add-readme.md) and [LICENSE](add-license-coc.md) to your package
618-
* [Add more metadata to your `pyproject.toml`](5-pyproject-toml.md) file to support PyPI publication.
626+
* [Add more metadata to your `pyproject.toml`](pyproject-toml.md) file to support PyPI publication.
619627
* [Learn how to build your package distribution](publish-pypi) files (**sdist** and **wheel**) and publish to **test PyPI**.
620628
* Finally you will learn how to [publish to **conda-forge**](publish-conda-forge) from **PyPI**.
621629
622-
623630
## Footnotes
624631
625632
[^shell-lesson]: [Carpentries shell lesson](https://swcarpentry.github.io/shell-novice/)

tutorials/intro.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Get to know Hatch <get-to-know-hatch>
3636
:caption: Create and publish a Python Package
3737

3838
What is a Python package? <self>
39-
Make your code installable <1-installable-code>
39+
Make your code installable <installable-code>
4040
Publish to PyPI <publish-pypi>
4141
Publish to conda-forge <publish-conda-forge>
4242
:::
@@ -290,7 +290,7 @@ You can install a Python package into a Python environment in the same way
290290
you might install NumPy or Pandas. Installing your package into an environment
291291
allows you to access it from any code run with that specific Python environment activated.
292292

293-
:::{figure-md} packages-environment
293+
:::{figure-md} packages-environment-install
294294

295295
<img src="../images/tutorials/environment-package-install.png" alt="Diagram showing the steps associated with creating a package and then installing it. The first arrow says your package and the second says pip install package. The second arrow leads to a box that represents a Python environment that already has some packages installed such as Pandas and NumPy. Your package will also get installed into that same environment when you pip install it." width="700px">
296296

@@ -315,11 +315,11 @@ Then you can create a conda-forge recipe using the [Grayskull](https://github.co
315315

316316
[You will learn more about the conda-forge publication process here.](publish-conda-forge.md)
317317

318-
:::{figure-md} build-workflow-tutorial
318+
:::{figure-md} publish-package-pypi-conda-overview
319319
<img src="../images/tutorials/publish-package-pypi-conda.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. Those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testPyPI or the real PyPI. From PyPI you can then connect to conda-forge for an automated build that sends distributions from PyPI to conda-forge." width="700px">
320320

321321
In the image above, you can see the steps associated with publishing
322-
your package on PyPI and conda-forge. Note that the distribution files that PyPI requires are the [sdist](#python-source-distribution) and [wheel](#python-wheel) files. Once you are ready to make your code publicly installable, you can publish it on PyPI. Once your code is on PyPI it is straight forward to then publish to conda-forge. You create a recipe using the Grayskull package and then you open a pr in the conda-forge recipe repository. You will learn more about this process in the [conda-forge lesson](#).
322+
your package on PyPI and conda-forge. Note that the distribution files that PyPI requires are the [sdist](#python-source-distribution) and [wheel](#python-wheel) files. Once you are ready to make your code publicly installable, you can publish it on PyPI. Once your code is on PyPI it is straight forward to then publish to conda-forge. You create a recipe using the Grayskull package and then you open a pr in the conda-forge recipe repository. You will learn more about this process in the [conda-forge lesson](/tutorials/publish-conda-forge).
323323
:::
324324

325325
## Yay, your package has users! Now what?
@@ -346,5 +346,5 @@ The elements above are also important for future maintenance of your package. In
346346
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.
347347

348348
In this next lesson you will learn how to create a basic installable Python package.
349-
Make your code pip installable <1-installable-code>
349+
Make your code pip installable <installable-code>
350350
:::

0 commit comments

Comments
 (0)