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
Rework Packaging lecture slides and exercise (#203)
* Rework Python packaging slides and update the exercise
* Rework Packaging introduction slides
* Further reworking of the Python packaging slides
* Remove loading bar symbols from PyPI uoload snap because the PDF creator throws warnings
Copy file name to clipboardExpand all lines: 03_building_and_packaging/intro_slides.md
+20-16Lines changed: 20 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -29,21 +29,24 @@ slideOptions:
29
29
30
30
## Learning goals of chapter
31
31
32
-
- What is code packaging and which technologies are available to package code
33
-
- What are the various ways in which a Python code can be packaged
34
-
- How is the Python Package Index (PyPI) used to distribute Python packages
32
+
- Explain why software is packaged.
33
+
- Create Python packages, publish on PyPI, and install with pip.
34
+
- Understand the difference between static and dynamic libraries and common ways of installation on Linux.
35
+
- Build C++ software and handle dependencies with Make and CMake.
36
+
- Package C++ software with CPack and create Debian packages.
37
+
- Create Spack packages, e.g., for high-performance computing systems with restricted access rights.
35
38
36
39
---
37
40
38
41
## What is packaging?
39
42
40
-
- Bare code is often hard to understand for everyone except the developer.
43
+
- Bare code is often hard to understand for everyone except the developer(s).
41
44
- Packaging is a workflow to convert a code into a standardized distributable software.
42
-
-Broadly code can be standardized in various ways. Some examples are
43
-
- creating a package according to some standardization.
44
-
- providing an installation recipe, for example, using CMake / make (`make install`).
45
+
-A code can be standardized in various ways. Some examples are
46
+
- creating a compact form by following a standardization.
47
+
- providing an installation recipe, for example, using CMake / make.
45
48
- bundling code into an app or software with some UI.
46
-
-In this first lecture you will learn about **creating a package according to some standardization**.
49
+
-We discuss **creating a compact form by following a standardization**.
47
50
48
51
---
49
52
@@ -52,24 +55,25 @@ slideOptions:
52
55
- A bare code with many files typically has difficulties like
53
56
- multiple dependencies and requirements of specific versions of dependencies.
54
57
- intricate compilation / installation steps which are hard to get right.
55
-
- missing or limited starting information / documentation which means a high entry barrier.
58
+
- missing or limited starting information / documentation, which means a high entry barrier.
56
59
57
60
---
58
61
59
62
## Why should we package code? 2/2
60
63
61
-
- Create a package of bare code to
64
+
- Create a package to
62
65
- benefit from a package index or package manager which is familiar for a broad audience.
63
66
- benefit from automated handling of dependencies of package managers.
64
67
- have ease of distribution and maintenance due to standardization.
68
+
- increase overall usability and sustainability of your code.
65
69
66
70
---
67
71
68
72
## How to package code?
69
73
70
-
- First step is finding the right type of packaging standard that fits best for your code.
71
-
- There are several (overlapping) options:
72
-
- One of the many Linux package managers: apt, dpkg, yum, RPM Package Manager and many more ...
74
+
- First step is finding the right standard for your code.
75
+
- There are several options:
76
+
- One of the many Linux package managers: apt, dpkg, yum, RPM and many more ...
73
77
-[CMake](https://cmake.org/) <span>: building / installation / packaging tool mostly for C, C++ projects<!-- .element: class="fragment" data-fragment-index="1" --></span>
74
78
-[Spack](https://spack.io/) <span>: a package management tool mostly for supercomputing centers<!-- .element: class="fragment" data-fragment-index="1" --></span>
75
79
-[Conan](https://conan.io/) <span>: open-source package manager for C and C++ development<!-- .element: class="fragment" data-fragment-index="1" --></span>
@@ -78,11 +82,11 @@ slideOptions:
78
82
79
83
---
80
84
81
-
## Why do we particularly look at packaging a Python code?
85
+
## Why do we look at packaging a Python code?
82
86
83
87
- Python is easy to understand and widely used in research software.
84
-
- A finetuned packaging workflow is already well established in the Python community.
85
-
- Various examples of packaged codes already exist: [NumPy](https://pypi.org/project/numpy/), [PyMOR](https://pypi.org/project/pymor/), [fenicsprecice](https://pypi.org/project/fenicsprecice/) and more ...
88
+
- A well established packaging workflow already exists in the Python community.
89
+
- Various examples of packaged codes already exist: [NumPy](https://pypi.org/project/numpy/), [SciPy](https://pypi.org/project/scipy/), [PyTorch](https://pypi.org/project/torch/) and more ...
Copy file name to clipboardExpand all lines: 03_building_and_packaging/pip_demo.md
+5-8Lines changed: 5 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# `pip`: Python Packaging Tool Demo Notes
2
2
3
-
**Note**: Maybe run everything in a fresh Ubuntu Docker container. Launch such a container using `docker run --rm -it ubuntu:jammy`. The other option is to work in a Python virtual environment. An environment can be created as follows
3
+
**Note**: It is recommended run everything in a Ubuntu Docker container or a virtual environment. Launch a container using `docker run --rm -it ubuntu:jammy`. A virtual environment can be created as follows
4
4
5
5
```bash
6
6
python -m venv env-name
@@ -9,7 +9,7 @@ source env-name/bin/activate
9
9
10
10
## 0. Getting `pip`
11
11
12
-
If Python has been installed using a system package manager like `apt`, it will not come with `pip`. `pip`can be installed in several ways
12
+
A clean Docker container may not have Python installed. Install Python using `apt`: `apt install python3`. If Python has been installed using a package manager like `apt`, it will not come with `pip`. `pip`can be installed in several ways
13
13
14
14
```bash
15
15
python -m ensurepip --upgrade
@@ -18,7 +18,7 @@ python -m ensurepip --upgrade
18
18
or
19
19
20
20
```bash
21
-
apt install pip
21
+
apt install python3-pip
22
22
```
23
23
24
24
- If installed with Python, the Python version is used to determine which `pip` is installed. So Python 3.8 will install a `pip` by the name of `pip3.8` which will be compatible with Python 3.8.
@@ -27,7 +27,7 @@ apt install pip
27
27
28
28
## 1. Installing packages with `pip`
29
29
30
-
Let us install the finite element library [Nutils](https://nutils.org/)
30
+
Let us install the finite element library [Nutils](https://nutils.org/).
31
31
32
32
```bash
33
33
pip install nutils
@@ -36,7 +36,7 @@ pip install nutils
36
36
Install a specific version of a package
37
37
38
38
```bash
39
-
pip install nutils==6.0.0
39
+
pip install nutils==7.0.0
40
40
```
41
41
42
42
Uninstalling a package
@@ -56,9 +56,6 @@ cd nutils
56
56
pip install --user .
57
57
```
58
58
59
-
- A `build` folder is created and the package files are copied into it.
60
-
- But now `pip uninstall package-name` does not work as `pip` looks in the home path. Removal of package can be done by deleting the `build` folder or using manually using `setup.py`.
61
-
62
59
## 2. Getting information of currently installed packages
0 commit comments