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/intro.md
+42-38Lines changed: 42 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,6 @@ You might also hear people use the term "library" the same way.
53
53
54
54
## What is a Python package?
55
55
56
-
57
56
At a high level, you can think about a Python package as a toolbox
58
57
that you can use to perform various tasks.
59
58
@@ -87,6 +86,27 @@ Installing a package into an environment makes it easier
87
86
to manage and reuse your code across different projects.
88
87
Structuring your code as a package is the first step you need to take so you can share the tools in the toolbox you've created and let others build with it.
89
88
89
+
## Why create a Python package?
90
+
91
+
There are numerous reasons why you might create a Python package:
92
+
93
+
-**Use your code across multiple projects:** At its most basic level, creating a package allows you to install your code into a Python environment. This allows you to then import functions and classes into any workflows both locally and in the cloud..
94
+
-**Share your code:** Sharing your code with others is often a common reason to create a package. If you publish a package on a public repository such as PyPI or conda, immediately your package can be installed on any machine using pip or conda with a single command.
95
+
-**Build community around your code:** Packages make it easier for multiple people to work on the same project (particularly when published on Github). A version platform such as git (the version control system used by GitHub), further makes it easier to track changes to the codebase over time. Tools such as issues and pull requests make it easier for outside users to contribute bug fixes and to establish review processes for accepting changes to the code base..
96
+
-**Organize your code:** Packages can be used to organize large code projects, dividing them into smaller, more manageable components. This structure can help with both maintaining the codebase and with making it easier to understand.
97
+
98
+
### What to consider before you create a package
99
+
100
+
Creating a Python package that others use takes considerable
101
+
time and effort. Before you begin, think about your goals including:
102
+
103
+
- Who you think will use your package
104
+
- How people might use your package and on what data (if data are relevant)
105
+
- Whether you have time to add things such as documentation and tests
106
+
- How long you might be able to maintain it: remember that once people begin using your package they will depend on your maintainer team to update it, fix bugs and answer questions.
107
+
108
+
Before creating a package that is user-facing, it's important to consider all of the above!
109
+
90
110
## The elements of a Python package
91
111
92
112
:::{figure-md} package-components
@@ -106,7 +126,7 @@ The core elements of Python package include:
106
126
- Contributor Documentation in the form of a **CONTRIBUTING.md** file is useful to help people to contribute to your package.
107
127
- Development documentation helps both maintainers and contributors understand how to maintain a package's infrastructure.
108
128
-**Tests:** that makes sure your code works as it should and makes it easier for you and others to contribute to, modify and update the code in the future
109
-
-**License:** An open source license, or license that is [OSI approved](https://opensource.org/licenses/) refers to an licence that allows others to both use your package. It also provides legal direction regarding how elements of the package can and can't be reused.
129
+
-**License:** An open source license, or license that is [OSI approved](https://opensource.org/licenses/) refers to an license that allows others to both use your package. It also provides legal direction regarding how elements of the package can and can't be reused.
110
130
-**Infrastructure** that automates updates, publication workflows and runs test suites. Infrastructure includes a suite of things such as platforms like GitHub and GitLab, tools to run tests and tools locally such as nox and tox and continuous integration that automates package maintenance steps.
111
131
112
132
:::{admonition} What pyOpenSci looks for in a package
@@ -264,27 +284,36 @@ allows you to access it from any code run with that specific Python environment
264
284
<imgsrc="../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">
265
285
266
286
You don't have to publish to PyPI in order to make your code installable.
267
-
WIth the correct file structure and project metadata you can make your code
287
+
With the correct file structure and project metadata you can make your code
268
288
installable locally on your computer and use it for projects that you are working
269
289
on without having to ever publish to PyPI. Publishing to PyPI is useful when you
270
290
want to make your code public-facing and share it with others.
271
291
:::
272
292
273
-
### Publishing a package
293
+
### Publishing a package to PyPI / Conda-Forge
294
+
295
+
If you want to make your package directly installable without having
296
+
to download the code to your computer locally then you need to
297
+
publish it in a repository such as **PyPI** or **conda-forge**.
298
+
299
+
:::{todo}
300
+
The links below won't work until those lessons (which are written) are published.
301
+
:::
274
302
275
-
If you want to make your package installable using `pip` you need to
276
-
publish it in a repository such as PyPI or conda-forge. If you package is a
277
-
pure python package, then publishing to both PyPI and conda-forge only takes just a few steps.
303
+
In this tutorial, you will learn [how to publish to PyPI.](6-publish-pypi.md)
278
304
279
-
In these tutorials, you will learn [how to publish to PyPI using twine.](6-publish-pypi.md)
305
+
:::{todo}
306
+
This lesson is also not published - yet but will be reviewed soon.
307
+
:::
280
308
281
309
Then you can create a conda-forge recipe using the [grayskull](https://github.com/conda/grayskull) tool. This recipe can then be submitted to conda-forge. [You will learn more about the conda-forge publication process here.](7-publish-conda-forge.md)
282
310
283
311
284
312
:::{figure-md} build-workflow-tutorial
285
-
<imgsrc="../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">
313
+
<imgsrc="../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">
286
314
287
-
Once you are ready to make your code public, you can publish it on PyPI. Once the code is on PyPI it's a simple set of steps to publish to conda forge. You create a recipe using the grayskull package and then you open a pr in the conda-forge recipe repo. You will learn more about this process in the [conda-forge lesson](#).
315
+
In the above image you can see the steps associated with publishing
316
+
your package on PyPI and conda forge. Note that the distribution files that PyPI requires are the [sdist](#sdist) and [wheel](#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 repo. You will learn more about this process in the [conda-forge lesson](#).
288
317
:::
289
318
290
319
## Yay, your package has users! Now what?
@@ -293,12 +322,9 @@ As the community using your package grows, you may also find yourself managing u
293
322
294
323
To support your community, you'll want to add things like:
295
324
296
-
* development guide
297
-
* code of conduct
298
-
* contributing guide
299
-
300
-
301
-
325
+
*[a development guide that documents your maintainer workflow process ](/documentation/repository-files/development-guide.md)
326
+
*[a code of conduct to defines community interaction standards and expectations](/documentation/repository-files/code-of-conduct-file.md)
327
+
*[a contributing guide that helps users understand expectations associated with making contributions to your project](/documentation/repository-files/contributing-file.md)
302
328
303
329
:::{admonition} Support for contributors and maintainers
304
330
@@ -307,28 +333,6 @@ If you intend for others to use and contribute to your code, consider who will m
307
333
The elements above are also important for future maintenance of your package. In the case that you are no long able to maintain it or simply want extra help, development and contributing documentation will help you onboard new maintainers.
308
334
:::
309
335
310
-
<!--
311
-
Are the sections below useful??
312
-
313
-
*********
314
-
## Why create a package?
315
-
316
-
There are numerous reasons why you might create a Python package:
317
-
318
-
- **Use your code across multiple projects:** At its most basic level, creating a package allows you to install your code into a Python environment. This allows you to then import functions and classes into any workflows both locally and in the cloud..
319
-
- **Share your code:** Sharing your code with others is often a common reason to create a package.If you publish a package on a public repository such as PyPI or conda, immediately your package can be installed on any machine using pip or conda with a single command.
320
-
- **Build community around your code:** Packages make it easier for multiple people to work on the same project (particularly when published on Github). A version platform such as git (the version control system used by GitHub), further makes it easier to track changes to the codebase over time. Tools such as issues and pull requests make it easier for outside users to contribute bug fixes and to establish review processes for accepting changes to the code base..
321
-
- **Organize your code:** Packages can be used to organize large code projects, dividing them into smaller, more manageable components. This structure can help with both maintaining the codebase and with making it easier to understand.
322
-
323
-
## What to consider before you create a package
324
-
325
-
Creating a Python package that others use takes considerable time and effort.
326
-
Before you begin, think about your goals including:
327
-
328
-
- Who you think will use your package
329
-
- Whether you have time to add things such as documentation and tests
0 commit comments