Skip to content

Commit 15e9ac8

Browse files
authored
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
1 parent 502e2d9 commit 15e9ac8

File tree

4 files changed

+166
-117
lines changed

4 files changed

+166
-117
lines changed

03_building_and_packaging/intro_slides.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@ slideOptions:
2929

3030
## Learning goals of chapter
3131

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.
3538

3639
---
3740

3841
## What is packaging?
3942

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).
4144
- 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.
4548
- 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**.
4750

4851
---
4952

@@ -52,24 +55,25 @@ slideOptions:
5255
- A bare code with many files typically has difficulties like
5356
- multiple dependencies and requirements of specific versions of dependencies.
5457
- 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.
5659

5760
---
5861

5962
## Why should we package code? 2/2
6063

61-
- Create a package of bare code to
64+
- Create a package to
6265
- benefit from a package index or package manager which is familiar for a broad audience.
6366
- benefit from automated handling of dependencies of package managers.
6467
- have ease of distribution and maintenance due to standardization.
68+
- increase overall usability and sustainability of your code.
6569

6670
---
6771

6872
## How to package code?
6973

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 ...
7377
- [CMake](https://cmake.org/) <span>: building / installation / packaging tool mostly for C, C++ projects<!-- .element: class="fragment" data-fragment-index="1" --></span>
7478
- [Spack](https://spack.io/) <span>: a package management tool mostly for supercomputing centers<!-- .element: class="fragment" data-fragment-index="1" --></span>
7579
- [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:
7882

7983
---
8084

81-
## Why do we particularly look at packaging a Python code?
85+
## Why do we look at packaging a Python code?
8286

8387
- 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 ...
8690

8791
---
8892

03_building_and_packaging/pip_demo.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `pip`: Python Packaging Tool Demo Notes
22

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
44

55
```bash
66
python -m venv env-name
@@ -9,7 +9,7 @@ source env-name/bin/activate
99

1010
## 0. Getting `pip`
1111

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
1313

1414
```bash
1515
python -m ensurepip --upgrade
@@ -18,7 +18,7 @@ python -m ensurepip --upgrade
1818
or
1919

2020
```bash
21-
apt install pip
21+
apt install python3-pip
2222
```
2323

2424
- 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
2727

2828
## 1. Installing packages with `pip`
2929

30-
Let us install the finite element library [Nutils](https://nutils.org/)
30+
Let us install the finite element library [Nutils](https://nutils.org/).
3131

3232
```bash
3333
pip install nutils
@@ -36,7 +36,7 @@ pip install nutils
3636
Install a specific version of a package
3737

3838
```bash
39-
pip install nutils==6.0.0
39+
pip install nutils==7.0.0
4040
```
4141

4242
Uninstalling a package
@@ -56,9 +56,6 @@ cd nutils
5656
pip install --user .
5757
```
5858

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-
6259
## 2. Getting information of currently installed packages
6360

6461
```bash

03_building_and_packaging/pypi_exercise.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Starting remarks
44

5-
- [Exercise repository link](https://github.com/Simulation-Software-Engineering/diffusion2d)
6-
- Deadline for submitting this exercise is **Thursday 3rd November 09:00**.
5+
- [Exercise repository link](https://github.com/Simulation-Software-Engineering/diffusion2D)
6+
- Deadline for submitting this exercise is **Wednesday 20th November 09:00**.
77
- The code in this exercise produces plots and in order to view them you need to use a GUI-based operating system or environment.
88

99
## Brief idea of the exercise
@@ -24,7 +24,7 @@ In this exercise you will convert a raw Python code into a packaged code which i
2424

2525
## Step 1 - Acquiring the raw code and getting familiar with it
2626

27-
- Fork the [exercise repository](https://github.com/Simulation-Software-Engineering/diffusion2d).
27+
- Fork the [exercise repository](https://github.com/Simulation-Software-Engineering/diffusion2D).
2828
- Open the file `diffusion2d.py` and go through the file and try to understand the code components.
2929
- Check if your system has Python version >= 3.6 and update it if it is older than 3.6.
3030
- Install pip, build, and Twine.

0 commit comments

Comments
 (0)