Skip to content

Commit e237012

Browse files
committed
Fix: review feedback
1 parent e9af215 commit e237012

File tree

2 files changed

+51
-25
lines changed

2 files changed

+51
-25
lines changed

package-structure-code/intro.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,62 @@ best fitted for your workflow.
1414
:gutter: 3
1515

1616
:::{grid-item-card}
17-
:link: python-package-build-tools
17+
:link: python-package-structure
1818
:link-type: doc
1919

20-
Finding the right packaging tool(s)
20+
1. Package file structure
2121
^^^
22-
23-
Learn more about the suite of packaging tools out there.
24-
And learn which tool might be best for you.
22+
src layout, flat layout and where should tests folders live? No matter what your level of packaging knowledge is, this page will help you decide upon a package structure that follows modern python best practices.
2523
:::
2624

2725
:::{grid-item-card}
2826
:link: python-package-structure
2927
:link-type: doc
3028

31-
Package file structure
29+
2. Learn about building your package
3230
^^^
33-
src layout, flat layout and where should tests folders live? No matter what your level of packaging knowledge is, this page will help you decide upon a package structure that follows modern python best practices.
31+
Building a Python package refers to the process of placing your package code
32+
metadata (and tests) into a specific format that PyPI can read and that
33+
your users can install. Learn more about building a Python package here.
3434
:::
3535

3636
:::{grid-item-card}
3737
:link: python-package-build-tools
3838
:link-type: doc
3939

40-
✨ Publish to PyPI and Conda ✨
40+
✨ 3. What Python package tool should you use? ✨
41+
^^^
42+
43+
Learn more about the suite of packaging tools out there.
44+
And learn which tool might be best for you.
45+
:::
46+
47+
:::{grid-item-card}
48+
:link: python-package-build-tools
49+
:link-type: doc
50+
51+
✨ 4. Publish your package to PyPI and Conda ✨
4152
^^^
4253
If you have a pure python package, it's a straight forward
4354
process to publish to both PyPI and then a Conda channel such as
4455
conda-forge. Learn more here.
4556
:::
4657

58+
:::{grid-item-card}
59+
:link: python-package-versions
60+
:link-type: doc
61+
62+
✨ 5. Setup package versioning ✨
63+
^^^
64+
Semver (numeric versioning) and Calver (versioning using the date) are 2
65+
common ways to version a package. Which one should you pick? Learn more here.
66+
:::
67+
4768
:::{grid-item-card}
4869
:link: code-style-linting-format
4970
:link-type: doc
5071

51-
✨ Code style & linters ✨
72+
6. Code style & linters ✨
5273
^^^
5374
Black, blue, flake8, Ruff - which tools can help you ensure your
5475
package follows best practices for code format? Learn more about the options and why this is important here.
@@ -134,8 +155,8 @@ if you are looking for pyOpenSci's Python package review requirements!
134155
Intro <self>
135156
136157
Python package structure <python-package-structure>
137-
pyproject.toml Package Metadata <pyproject-toml-python-package-metadata>
138-
What are SDist & Wheel Files? <python-package-distribution-files-sdist-wheel>
158+
pyproject.toml Package Metadata <pyproject-toml-python-package-metada>
159+
Build Your Package <python-package-distribution-files-sdist-wheel>
139160
Package Build Tools <python-package-build-tools>
140161
Complex Builds <complex-python-package-builds>
141162
```

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
# The Python Package Source and Wheel Distributions
1+
# Learn about Building a Python Package
22

3-
```{figure} ../images/python-package-development-process.png
4-
:align: center
5-
:alt: Image showing the left side bar of PiPy for the package xclim. The section at the top says Classifier. Below there is a list of items including Development status, intended audience, License, natural language, operating system, programming language and topic. Below each of those sections are various classifier options." width="300px">
3+
:::{figure-md} build-workflow
4+
<img src="/images/python-package-development-process.png" alt="Alt tag to be added when image is final" width="700px">
65

7-
Notice the metadata printed on the PyPI page for xclim. When you add the classifier section to your pyproject.toml
8-
and your package is built, the build tool organizes the metadata into a format that PyPI can understand and
9-
represent on your pypi landing page. These classifiers also allow users to sort through packages by version of python they support, categories and more.
10-
```
6+
You need to build your Python package in order to publish it to PyPI or Conda. For PyPI, the build process essentially organizes your code and metadata into a distribution format that PyPI can read and provide to potential users.
7+
:::
118

129
## What is building a Python package?
1310

14-
In Python, if you want to publish your code in a way that can be
15-
installed by both yourself and others, your code, tests and associated
16-
metadata need to be organized in a specific way. This specific
17-
organization and structure is important because it's the structure
18-
that both `PyPI` and any installer that you use like `pip` can
19-
understand and parse. This process of organizing and formatting your
11+
To [publish your Python package](build-workflow) and make it easy for anyone to install, you first need to build it.
12+
13+
But, what does it mean to build a Python package?
14+
15+
[As shown in the figure above](build-workflow), when you build your Python package, you convert the source files into something called a distribution package. A distribution package contains your source code and metadata about the package, in the format required by the Python Package Index, so that it can be installed by tools like pip.
16+
17+
:::{note}
18+
The term package used to mean many different things in Python and other languages. On this page, we adapt the convention of the [Python Packaging Authority](https://www.pypa.io/en/latest/) and refer to the product of the
19+
build step as a **distribution package**.
20+
:::
21+
22+
This process of organizing and formatting your
2023
code, documentation, tests and metadata into a format that both pip
2124
and PyPI can use, is called a build step.
2225

26+
### Project metadata and PyPI
27+
2328
For instance, when you publish to PyPI, you will notice that each package has metadata listed. Let’s have a look at [xclim](https://pypi.org/project/xclim/), one of our [pyOpenSci packages](https://www.pyopensci.org/python-packages.html). Notice that on the PyPI landing page you see some metadata about the package including python, maintainer information and more. PyPI is able to populate this metadata because it was defined using correct syntax and classifiers by Xclim's maintainers, [pyproject.toml file](https://github.com/Ouranosinc/xclim/blob/master/pyproject.toml). This metadata when the xclim package is built, is translated into a distribution file that allows PyPI to read the metadata and print it out on their website.
2429

2530
```{figure} ../images/python-build-package/pypi-metadata-classifiers.png

0 commit comments

Comments
 (0)