From 0e76356043e3ed28a74ecb5c8f64094bc18f2115 Mon Sep 17 00:00:00 2001
From: Prabhu Ramachandran
Date: Sun, 22 Aug 2021 17:36:38 +0530
Subject: Slides on virtualenv and pip.
---
slides/devtools/venv.md | 247 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 247 insertions(+)
create mode 100644 slides/devtools/venv.md
diff --git a/slides/devtools/venv.md b/slides/devtools/venv.md
new file mode 100644
index 0000000..3c57f2c
--- /dev/null
+++ b/slides/devtools/venv.md
@@ -0,0 +1,247 @@
+---
+jupyter:
+ jupytext:
+ text_representation:
+ extension: .md
+ format_name: markdown
+ format_version: '1.2'
+ jupytext_version: 1.3.2
+ kernelspec:
+ display_name: Python 3
+ language: python
+ name: python3
+---
+
+
+venv and pip: an introduction
+======================
+
+
+
+
+
+
+
+August 22, 2021
+
+
+
+Department of Aerospace Engineering, IIT Bombay
+
+
+
+Prabhu Ramachandran
+
+
+
+
+
+Agenda
+------
+
+- Introduction to venv and pip
+- Basic usage and practices
+- Using with conda
+
+
+
+
+Why
+------
+
+- The default option for Python
+- Similar to conda but predates it
+
+
+
+
+Installation
+-------------
+
+- Part of your default Python install!
+- Built-in usually
+
+
+
+
+Getting started
+---------
+
+- Create an environments
+
+```bash
+$ python -m venv --help
+```
+
+```bash
+$ python -m venv myenv
+```
+
+- Creates a directory `myenv`
+- Is not self-contained but is isolated
+
+
+
+
+
+Activation/Deactivation
+-------------------------
+
+- On Linux/MacOS
+```bash
+$ source myenv/bin/activate
+```
+
+- On Windows
+```bash
+> .\myenv\Scripts\activate
+```
+
+```bash
+$ python
+>>> import sys
+>>> sys.prefix
+```
+
+```bash
+$ deactivate
+
+$ rm -rf myenv
+```
+
+
+
+
+Other options
+---------
+
+- Inherit parent packages
+
+```bash
+$ python -m venv myenv --system-site-packages
+```
+
+- Can also upgrade using `--upgrade`
+
+
+
+
+
+Installation of packages
+------------------
+
+```bash
+$ python -m pip install numpy ipython
+```
+
+- Specific versions
+
+```bash
+$ python -m pip install vtk==9.0.1
+```
+
+- Remove
+
+```bash
+$ python -m pip uninstall vtk
+```
+
+
+
+
+More on installation
+------------------
+
+- Install from source directory
+```bash
+$ python -m pip install .
+```
+
+- Editable installation
+
+```bash
+$ python -m pip install --editable .
+```
+- Or `-e`
+- `--no-cache-dir`: Do not use the cached wheels
+- `--force-reinstall`: what it says
+- `--no-binary`: use if binary wheel is busted
+- The last will force a source build
+
+
+
+
+
+
+More commands
+------------------
+
+```bash
+$ python -m pip help
+```
+
+```bash
+$ python -m pip list
+```
+
+```bash
+$ python -m pip show numpy
+```
+
+
+
+
+Requirements
+--------------
+
+- Create a requirements
+```bash
+$ python -m pip freeze
+```
+
+- Use this to install
+
+```bash
+$ python -m pip install -r requirements.txt
+```
+
+
+
+
+
+Conda + requirements?
+-----------------
+
+```bash
+$ cat environment.yml
+name: myenv
+...
+dependencies:
+ - python=3.8
+ - ipython
+ - pip
+ - pip:
+ - vtk
+ - mayavi
+
+```
+
+- Use this directly with conda
+
+```bash
+$ conda env create
+```
+
+- `--file fname.yml` if not `environment.yml`
+
+
+
+
+
+More information
+------------------
+
+- https://packaging.python.org/guides/
+- https://realpython.com/python-wheels/
+
+
--
cgit