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: 03_building_and_packaging/intro_slides.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ slideOptions:
30
30
## Learning goals of chapter
31
31
32
32
- Explain why software is packaged.
33
-
- Create a distributable package of a raw Python code, publish on PyPI, and install with pip.
33
+
- Create a distributable package of a Python code, publish on PyPI, and install with pip.
34
34
- Understand the difference between static and dynamic libraries and common ways of installation on Linux.
35
35
- Build C++ software and handle dependencies with Make and CMake.
36
36
- Package C++ software with CPack and create Debian packages.
@@ -73,10 +73,10 @@ slideOptions:
73
73
74
74
- First step is finding the right standard for your code.
75
75
- There are several options:
76
-
-One of the many Linux package managers: apt, dpkg, yum, RPM and many more ...
77
-
-[CMake](https://cmake.org/) <span>: building / installation / packaging tool mostly for C, C++ projects<!-- .element: class="fragment" data-fragment-index="1" --></span>
78
-
-[Spack](https://spack.io/) <span>: a package management tool mostly for supercomputing centers<!-- .element: class="fragment" data-fragment-index="1" --></span>
79
-
-[Conan](https://conan.io/) <span>: open-source package manager for C and C++ development<!-- .element: class="fragment" data-fragment-index="1" --></span>
76
+
- Linux package managers: apt, dpkg, yum, RPM, etc.
77
+
-[CMake](https://cmake.org/)
78
+
-[Spack](https://spack.io/)
79
+
-[Conan](https://conan.io/)
80
80
-[pip](https://pypi.org/project/pip/)
81
81
-[Conda](https://docs.conda.io/en/latest/)
82
82
- and many more ...
@@ -87,7 +87,7 @@ slideOptions:
87
87
88
88
- Python is easy to understand and widely used in research software.
89
89
- Well established package managers and packaging tools already exist in the Python community.
90
-
- Several examples of packaged codes: [NumPy](https://pypi.org/project/numpy/), [SciPy](https://pypi.org/project/scipy/), [PyTorch](https://pypi.org/project/torch/) and more ...
90
+
- Several examples of packaged codes: [NumPy](https://pypi.org/project/numpy/), [SciPy](https://pypi.org/project/scipy/), [PyTorch](https://pypi.org/project/torch/).
Copy file name to clipboardExpand all lines: 03_building_and_packaging/pypi_slides.md
+59-46Lines changed: 59 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,7 @@ slideOptions:
33
33
34
34
## Python Package Managers 1/3
35
35
36
-
The most significant package managers:
37
-
38
-
- pip
39
-
- Conda
40
-
- Poetry
41
-
- uv
36
+
Many package managers out there: **pip**, **Conda**, **Poetry**, **uv**, and more.
42
37
43
38
---
44
39
@@ -58,41 +53,35 @@ Poetry and uv are newer variants with better functionality and speed.
58
53
59
54
## Python Package Managers 3/3
60
55
61
-
In this lecture, we work with pip, because ...
56
+
In this lecture we work with pip, because ...
62
57
63
58
- ... of its wide use in the Python community.
64
-
- ... the package repository PyPI is large.
65
-
- ... it is still the fundamental way to package Python code.
59
+
- ... the packaging index PyPI is large.
60
+
- ... it is still the go-to solution to package Python code.
66
61
- ... it is easy to understand and use.
67
62
68
63
---
69
64
70
65
## Python Enhancement Proposals (PEPs)
71
66
72
-
- PEP is an evolving design document which provides information regarding new features, processes and new environments.
73
-
- PEPs typically involve concise technical information, which also acts as standardizations.
67
+
- PEP is an evolving design document which guides Python development.
68
+
- PEPs typically involve concise technical information, which also act as standards.
74
69
- Packaging is standardized by [Packaging PEPs](https://peps.python.org/topic/packaging/).
75
70
- Example of a Packaging PEP: [PEP 427 – The Wheel Binary Package Format 1.0](https://peps.python.org/pep-0427/).
76
71
77
72
---
78
73
79
74
## Distribution Package vs. Import Package
80
75
81
-
Distribution package
82
-
83
-
- Something you can install.
84
-
-`pip install pkg`.
85
-
- Directly acquired from a packaging index.
86
-
87
-
Import package
88
-
89
-
- An import package is a Python module which typically contains submodules.
90
-
- Writing `import pkg` in a file. Potentially also `from pkg import xyz`.
91
-
- Import package is available when its distribution package is installed.
92
-
93
-
Distribution package name and import package need not be the same, but usually is.
76
+
- Distribution package is ...
77
+
- ... something you can install, like `pip install pkg`.
78
+
- ... directly acquired from a packaging index.
79
+
- Import package
80
+
- ... is a Python module which typically contains submodules.
81
+
- ... is used within a file: `import pkg` or `from pkg import xyz`.
82
+
- ... is available when its distribution package is installed.
94
83
95
-
Read more about [distribution package vs. import package](https://packaging.python.org/en/latest/discussions/distribution-package-vs-import-package/#distribution-package-vs-import-package).
84
+
Distribution package name and import package need not be the same, but usually is. Read more about [distribution package vs. import package](https://packaging.python.org/en/latest/discussions/distribution-package-vs-import-package/#distribution-package-vs-import-package).
96
85
97
86
---
98
87
@@ -101,7 +90,7 @@ Read more about [distribution package vs. import package](https://packaging.pyth
101
90
1. Get or create a source tree of the code.
102
91
2. Write a packaging configuration file, typically `pyproject.toml`.
103
92
3. Create build artifacts.
104
-
4. Upload the build artifacts to the package distribution service (PyPI).
93
+
4. Upload the build artifacts to a packaging index.
105
94
106
95
---
107
96
@@ -147,7 +136,7 @@ Four places where naming is relevant:
147
136
- Name of the distribution package.
148
137
- Name of the import package.
149
138
150
-
**All names are independent of each other, but try to have one name.**
139
+
**All names are independent of each other, but try to have a single name.**
151
140
152
141
---
153
142
@@ -187,51 +176,69 @@ What happened to the files `setup.py` and `setup.cfg`?
187
176
188
177
-`setup.py` is a configuration file for the build backend `setuptools`.
189
178
- It still remains a valid configuration file.
190
-
- Using `setup.py` as a command line tool is **deprecated**, avoid `python setup.py`.
179
+
- Using `setup.py` as a command line tool is **deprecated**.
191
180
-`setup.cfg` is yet another valid configuration file for `setuptools`.
192
-
- These files are necessary if the Python package as C extensions.
181
+
- These files are necessary if the Python package has C extensions.
193
182
194
183
Read more in [is setup.py deprecated?](https://packaging.python.org/en/latest/discussions/setup-py-deprecated/#setup-py-deprecated).
195
184
196
185
---
197
186
198
187
## Create Build Artifacts 1/3
199
188
200
-
Source distribution (sdist) vs. built distribution (wheel)
189
+
Source distribution (sdist) vs. built distribution (wheel).
201
190
202
-
Base command is `python3 -m build`.
191
+
Base command
192
+
193
+
```bash
194
+
python3 -m build
195
+
```
203
196
204
197
---
205
198
206
199
## Create Build Artifacts 2/3
207
200
208
201
Source distribution (sdist)
209
202
210
-
- Contains files enough to install the package from source at end location.
211
-
- Run `python3 -m build --sdist source-tree-directory`.
203
+
- Contains files enough to install the package from source.
204
+
- Run
205
+
206
+
```bash
207
+
python3 -m build --sdist source-tree-directory
208
+
```
212
209
213
210
---
214
211
215
212
## Create Build Artifacts 3/3
216
213
217
214
Built distribution (wheel)
218
215
219
-
- Contains files needed only to run package at end location.
220
-
- No compilation done, just a copy paste into a directory at end location.
216
+
- Contains files needed only to run package.
217
+
- No compilation done, just a copy paste into a directory.
221
218
- In most cases only one generic wheel is required. Exceptions are different Python interpreters, different OS configurations.
222
-
- Run `python3 -m build --wheel source-tree-directory`.
219
+
- Run
220
+
221
+
```bash
222
+
python3 -m build --wheel source-tree-directory
223
+
```
224
+
223
225
- If no wheel is available, pip falls back to source distribution.
224
226
225
227
---
226
228
227
229
## Uploading Build Artifacts
228
230
229
-
- The [twine](https://twine.readthedocs.io/en/latest/) is a tool to upload the build artifacts.
230
-
- Run `twine upload dist/package-name-version.tar.gz dist/package-name-version-py3-none-any.whl`.
231
-
- Why Twine?
232
-
- Secure authentication of the user over HTTPS using a verified connection.
233
-
- Its predecessor `python setup.py upload` required careful configuration, and is deprecated.
234
-
- Encourages users to create distribution files to promote testing before releasing.
231
+
-[twine](https://twine.readthedocs.io/en/latest/) is a tool to upload the build artifacts.
0 commit comments