Skip to content

Commit

Permalink
Further reworking of the Python packaging slides
Browse files Browse the repository at this point in the history
  • Loading branch information
IshaanDesai committed Nov 12, 2024
1 parent 5359040 commit 399caa4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions 03_building_and_packaging/pip_demo.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `pip`: Python Packaging Tool Demo Notes

**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
**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

```bash
python -m venv env-name
Expand All @@ -9,7 +9,7 @@ source env-name/bin/activate

## 0. Getting `pip`

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

```bash
python -m ensurepip --upgrade
Expand All @@ -18,7 +18,7 @@ python -m ensurepip --upgrade
or

```bash
apt install pip
apt install python3-pip
```

- 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.
Expand All @@ -27,7 +27,7 @@ apt install pip

## 1. Installing packages with `pip`

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

```bash
pip install nutils
Expand All @@ -36,7 +36,7 @@ pip install nutils
Install a specific version of a package

```bash
pip install nutils==6.0.0
pip install nutils==7.0.0
```

Uninstalling a package
Expand All @@ -56,9 +56,6 @@ cd nutils
pip install --user .
```

- A `build` folder is created and the package files are copied into it.
- 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`.

## 2. Getting information of currently installed packages

```bash
Expand Down
2 changes: 1 addition & 1 deletion 03_building_and_packaging/pypi_exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In this exercise you will convert a raw Python code into a packaged code which i

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

- Fork the [exercise repository](https://github.com/Simulation-Software-Engineering/diffusion2d).
- Fork the [exercise repository](https://github.com/Simulation-Software-Engineering/diffusion2D).
- Open the file `diffusion2d.py` and go through the file and try to understand the code components.
- Check if your system has Python version >= 3.6 and update it if it is older than 3.6.
- Install pip, build, and Twine.
Expand Down
2 changes: 1 addition & 1 deletion 03_building_and_packaging/pypi_slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ setup(

## Additional options in setup.py 3/3

The option `entry_points` provide metadata which are exposed after installation. For example: executable functions from a terminal.
The option `entry_points` exposes code for direct use. For example: executable functions from a terminal.

```python
from setuptools import setup
Expand Down

0 comments on commit 399caa4

Please sign in to comment.