diff --git a/_config.yml b/_config.yml index f590cc8..244cf5d 100644 --- a/_config.yml +++ b/_config.yml @@ -12,6 +12,8 @@ exclude_patterns: - .nox - .pytest_cache - .virtual_documents + - .conda + - .ipynb_checkpoints # disable execution to start execute: diff --git a/lectures/production/environments.ipynb b/lectures/production/environments.ipynb index 11be86d..04e8a27 100644 --- a/lectures/production/environments.ipynb +++ b/lectures/production/environments.ipynb @@ -12,16 +12,15 @@ "source": [ "# Environments\n", "\n", - "\n", - "**Note:** this notebook uses the bash kernel. Intall it with `pip install bash_kernel` or run these commands in a shell.\n", - "\n", + "```{note}\n", + "This notebook uses the bash kernel. Install it with `python3 -m pip install bash_kernel` or run these commands in a shell.\n", + "```\n", "\n", "A \"virtual environment\" is a directory isolating a collection of packages.\n", - "The `venv` package in the standard library creates virtualenvs.\n", + "The `venv` package in the standard library creates virtual environments.\n", "There are various wrappers, such as `virtualenvwrapper` that can add some functionality if you use envs a lot.\n", "\n", - "\n", - "to create an env:" + "to create an env:\n" ] }, { @@ -39,44 +38,44 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: pip in ./env-1/lib/python3.11/site-packages (22.3.1)\n", + "Requirement already satisfied: pip in ./env-1/lib/python3.10/site-packages (23.0.1)\n", "Collecting pip\n", - " Using cached pip-23.2.1-py3-none-any.whl (2.1 MB)\n", + " Using cached pip-23.3.1-py3-none-any.whl (2.1 MB)\n", "Installing collected packages: pip\n", " Attempting uninstall: pip\n", - " Found existing installation: pip 22.3.1\n", - " Uninstalling pip-22.3.1:\n", - " Successfully uninstalled pip-22.3.1\n", - "Successfully installed pip-23.2.1\n", - "env-1\n", - "├── bin\n", - "│   ├── Activate.ps1\n", - "│   ├── activate\n", - "│   ├── activate.csh\n", - "│   ├── activate.fish\n", - "│   ├── pip\n", - "│   ├── pip3\n", - "│   ├── pip3.11\n", - "│   ├── python -> /Users/minrk/conda/bin/python\n", - "│   ├── python3 -> python\n", - "│   └── python3.11 -> python\n", - "├── include\n", - "│   └── python3.11\n", - "├── lib\n", - "│   └── python3.11\n", - "└── pyvenv.cfg\n", + " Found existing installation: pip 23.0.1\n", + " Uninstalling pip-23.0.1:\n", + " Successfully uninstalled pip-23.0.1\n", + "Successfully installed pip-23.3.1\n", + "\u001b[01;34menv-1\u001b[0m\n", + "├── \u001b[01;34mbin\u001b[0m\n", + "│   ├── \u001b[00mactivate\u001b[0m\n", + "│   ├── \u001b[00mactivate.csh\u001b[0m\n", + "│   ├── \u001b[00mactivate.fish\u001b[0m\n", + "│   ├── \u001b[00mActivate.ps1\u001b[0m\n", + "│   ├── \u001b[01;32mpip\u001b[0m\n", + "│   ├── \u001b[01;32mpip3\u001b[0m\n", + "│   ├── \u001b[01;32mpip3.10\u001b[0m\n", + "│   ├── \u001b[01;36mpython\u001b[0m -> \u001b[01;32mpython3\u001b[0m\n", + "│   ├── \u001b[01;36mpython3\u001b[0m -> \u001b[01;32m/home/dokken/src/mambaforge/envs/UIO-IN3110/bin/python3\u001b[0m\n", + "│   └── \u001b[01;36mpython3.10\u001b[0m -> \u001b[01;32mpython3\u001b[0m\n", + "├── \u001b[01;34minclude\u001b[0m\n", + "├── \u001b[01;34mlib\u001b[0m\n", + "│   └── \u001b[01;34mpython3.10\u001b[0m\n", + "├── \u001b[01;36mlib64\u001b[0m -> \u001b[01;34mlib\u001b[0m\n", + "└── \u001b[00mpyvenv.cfg\u001b[0m\n", "\n", - "6 directories, 11 files\n" + "5 directories, 11 files\n" ] } ], "source": [ "# --clear means delete an env if there already was one at this location\n", - "python -m venv --clear ./env-1\n", - "./env-1/bin/pip install --upgrade pip\n", + "!python3 -m venv --clear ./env-1\n", + "!./env-1/bin/pip install --upgrade pip\n", "\n", "# tree will show us a peek at what's in the env\n", - "tree -L 2 env-1" + "!tree -L 2 env-1" ] }, { @@ -89,7 +88,7 @@ "tags": [] }, "source": [ - "I have a lot of packages in my main environment!" + "I have a lot of packages in my main environment!\n" ] }, { @@ -107,17 +106,28 @@ "name": "stdout", "output_type": "stream", "text": [ - " 456\n" + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.1.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.1\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", + "314\n", + "/home/dokken/src/mambaforge/envs/UIO-IN3110/bin/python3\n" ] } ], "source": [ - "pip list | wc -l" + "!python3 -m pip list | wc -l && which python3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If we consider the new environment, we barely have any packages\n" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 7, "metadata": { "editable": true, "slideshow": { @@ -130,22 +140,47 @@ "name": "stdout", "output_type": "stream", "text": [ - "Package Version\n", - "---------- -------\n", - "pip 23.2.1\n", - "setuptools 65.5.0\n" + "env: VIRTUAL_ENV_DISABLE_PROMPT=1\n", + "Package Version\n", + "------------------------- ------------\n", + "altair 5.1.2\n", + "attrs 23.1.0\n", + "blinker 1.7.0\n", + "click 8.1.7\n", + "Flask 3.0.0\n", + "itsdangerous 2.1.2\n", + "Jinja2 3.1.2\n", + "jsonschema 4.19.2\n", + "jsonschema-specifications 2023.7.1\n", + "MarkupSafe 2.1.3\n", + "numpy 1.26.2\n", + "packaging 23.2\n", + "pandas 2.1.3\n", + "pip 23.3.1\n", + "python-dateutil 2.8.2\n", + "pytz 2023.3.post1\n", + "referencing 0.30.2\n", + "rpds-py 0.12.0\n", + "setuptools 65.5.0\n", + "six 1.16.0\n", + "toolz 0.12.0\n", + "typing_extensions 4.8.0\n", + "tzdata 2023.3\n", + "vega-datasets 0.9.0\n", + "Werkzeug 3.0.1\n", + "/home/dokken/Documents/src/UiO/UiO-IN3110.github.io/lectures/production/env-1/bin/python3\n" ] } ], "source": [ - "VIRTUAL_ENV_DISABLE_PROMPT=1\n", - "source ./env-1/bin/activate\n", - "pip list" + "# If you want to run this in the terminal, replace `%env` with `export`\n", + "%env VIRTUAL_ENV_DISABLE_PROMPT=1\n", + "!source ./env-1/bin/activate && python3 -m pip list && which python3" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "metadata": { "editable": true, "slideshow": { @@ -165,12 +200,12 @@ } ], "source": [ - "cat requirements.txt" + "!cat requirements.txt" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": { "editable": true, "slideshow": { @@ -183,84 +218,40 @@ "name": "stdout", "output_type": "stream", "text": [ - "Collecting altair (from -r requirements.txt (line 1))\n", - " Obtaining dependency information for altair from https://files.pythonhosted.org/packages/b2/20/5c3b89d6f8d9938325a9330793438389e0dc94c34d921f6da35ec62095f3/altair-5.0.1-py3-none-any.whl.metadata\n", - " Downloading altair-5.0.1-py3-none-any.whl.metadata (8.5 kB)\n", - "Collecting flask (from -r requirements.txt (line 2))\n", - " Obtaining dependency information for flask from https://files.pythonhosted.org/packages/fd/56/26f0be8adc2b4257df20c1c4260ddd0aa396cf8e75d90ab2f7ff99bc34f9/flask-2.3.3-py3-none-any.whl.metadata\n", - " Downloading flask-2.3.3-py3-none-any.whl.metadata (3.6 kB)\n", - "Collecting vega_datasets (from -r requirements.txt (line 3))\n", - " Using cached vega_datasets-0.9.0-py3-none-any.whl (210 kB)\n", - "Collecting jinja2 (from altair->-r requirements.txt (line 1))\n", - " Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)\n", - "Collecting jsonschema>=3.0 (from altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for jsonschema>=3.0 from https://files.pythonhosted.org/packages/2b/ff/af59fd34bc4d7ac3e6e0cd1f3c10317d329b6c1aee179e8b24ad9a79fbac/jsonschema-4.19.0-py3-none-any.whl.metadata\n", - " Downloading jsonschema-4.19.0-py3-none-any.whl.metadata (8.2 kB)\n", - "Collecting numpy (from altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/86/a1/b8ef999c32f26a97b5f714887e21f96c12ae99a38583a0a96e65283ac0a1/numpy-1.25.2-cp311-cp311-macosx_11_0_arm64.whl.metadata\n", - " Using cached numpy-1.25.2-cp311-cp311-macosx_11_0_arm64.whl.metadata (5.6 kB)\n", - "Collecting pandas>=0.18 (from altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for pandas>=0.18 from https://files.pythonhosted.org/packages/8f/bb/aea1fbeed5b474cb8634364718abe9030d7cc7a30bf51f40bd494bbc89a2/pandas-2.0.3-cp311-cp311-macosx_11_0_arm64.whl.metadata\n", - " Using cached pandas-2.0.3-cp311-cp311-macosx_11_0_arm64.whl.metadata (18 kB)\n", - "Collecting toolz (from altair->-r requirements.txt (line 1))\n", - " Using cached toolz-0.12.0-py3-none-any.whl (55 kB)\n", - "Collecting Werkzeug>=2.3.7 (from flask->-r requirements.txt (line 2))\n", - " Obtaining dependency information for Werkzeug>=2.3.7 from https://files.pythonhosted.org/packages/9b/59/a7c32e3d8d0e546a206e0552a2c04444544f15c1da4a01df8938d20c6ffc/werkzeug-2.3.7-py3-none-any.whl.metadata\n", - " Downloading werkzeug-2.3.7-py3-none-any.whl.metadata (4.1 kB)\n", - "Collecting itsdangerous>=2.1.2 (from flask->-r requirements.txt (line 2))\n", - " Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB)\n", - "Collecting click>=8.1.3 (from flask->-r requirements.txt (line 2))\n", - " Obtaining dependency information for click>=8.1.3 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata\n", - " Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)\n", - "Collecting blinker>=1.6.2 (from flask->-r requirements.txt (line 2))\n", - " Using cached blinker-1.6.2-py3-none-any.whl (13 kB)\n", - "Collecting MarkupSafe>=2.0 (from jinja2->altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for MarkupSafe>=2.0 from https://files.pythonhosted.org/packages/fe/09/c31503cb8150cf688c1534a7135cc39bb9092f8e0e6369ec73494d16ee0e/MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_universal2.whl.metadata\n", - " Using cached MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_universal2.whl.metadata (3.0 kB)\n", - "Collecting attrs>=22.2.0 (from jsonschema>=3.0->altair->-r requirements.txt (line 1))\n", - " Using cached attrs-23.1.0-py3-none-any.whl (61 kB)\n", - "Collecting jsonschema-specifications>=2023.03.6 (from jsonschema>=3.0->altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for jsonschema-specifications>=2023.03.6 from https://files.pythonhosted.org/packages/1c/24/83349ac2189cc2435e84da3f69ba3c97314d3c0622628e55171c6798ed80/jsonschema_specifications-2023.7.1-py3-none-any.whl.metadata\n", - " Using cached jsonschema_specifications-2023.7.1-py3-none-any.whl.metadata (2.8 kB)\n", - "Collecting referencing>=0.28.4 (from jsonschema>=3.0->altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for referencing>=0.28.4 from https://files.pythonhosted.org/packages/be/8e/56d6f1e2d591f4d6cbcba446cac4a1b0dc4f584537e2071d9bcee8eeab6b/referencing-0.30.2-py3-none-any.whl.metadata\n", - " Downloading referencing-0.30.2-py3-none-any.whl.metadata (2.6 kB)\n", - "Collecting rpds-py>=0.7.1 (from jsonschema>=3.0->altair->-r requirements.txt (line 1))\n", - " Obtaining dependency information for rpds-py>=0.7.1 from https://files.pythonhosted.org/packages/70/bc/63cd73e793ac65059ed7c72659b192e79fb91548fb49854762ce6ab9de23/rpds_py-0.9.2-cp311-cp311-macosx_11_0_arm64.whl.metadata\n", - " Using cached rpds_py-0.9.2-cp311-cp311-macosx_11_0_arm64.whl.metadata (3.7 kB)\n", - "Collecting python-dateutil>=2.8.2 (from pandas>=0.18->altair->-r requirements.txt (line 1))\n", - " Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\n", - "Collecting pytz>=2020.1 (from pandas>=0.18->altair->-r requirements.txt (line 1))\n", - " Using cached pytz-2023.3-py2.py3-none-any.whl (502 kB)\n", - "Collecting tzdata>=2022.1 (from pandas>=0.18->altair->-r requirements.txt (line 1))\n", - " Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n", - "Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas>=0.18->altair->-r requirements.txt (line 1))\n", - " Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)\n", - "Using cached altair-5.0.1-py3-none-any.whl (471 kB)\n", - "Downloading flask-2.3.3-py3-none-any.whl (96 kB)\n", - "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m96.1/96.1 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hUsing cached click-8.1.7-py3-none-any.whl (97 kB)\n", - "Using cached jsonschema-4.19.0-py3-none-any.whl (83 kB)\n", - "Using cached pandas-2.0.3-cp311-cp311-macosx_11_0_arm64.whl (10.7 MB)\n", - "Using cached numpy-1.25.2-cp311-cp311-macosx_11_0_arm64.whl (14.0 MB)\n", - "Downloading werkzeug-2.3.7-py3-none-any.whl (242 kB)\n", - "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m242.2/242.2 kB\u001b[0m \u001b[31m14.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hUsing cached jsonschema_specifications-2023.7.1-py3-none-any.whl (17 kB)\n", - "Using cached MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_universal2.whl (17 kB)\n", - "Using cached referencing-0.30.2-py3-none-any.whl (25 kB)\n", - "Using cached rpds_py-0.9.2-cp311-cp311-macosx_11_0_arm64.whl (306 kB)\n", - "Installing collected packages: pytz, tzdata, toolz, six, rpds-py, numpy, MarkupSafe, itsdangerous, click, blinker, attrs, Werkzeug, referencing, python-dateutil, jinja2, pandas, jsonschema-specifications, flask, vega_datasets, jsonschema, altair\n", - "Successfully installed MarkupSafe-2.1.3 Werkzeug-2.3.7 altair-5.0.1 attrs-23.1.0 blinker-1.6.2 click-8.1.7 flask-2.3.3 itsdangerous-2.1.2 jinja2-3.1.2 jsonschema-4.19.0 jsonschema-specifications-2023.7.1 numpy-1.25.2 pandas-2.0.3 python-dateutil-2.8.2 pytz-2023.3 referencing-0.30.2 rpds-py-0.9.2 six-1.16.0 toolz-0.12.0 tzdata-2023.3 vega_datasets-0.9.0\n" + "Requirement already satisfied: altair in ./env-1/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (5.1.2)\n", + "Requirement already satisfied: flask in ./env-1/lib/python3.10/site-packages (from -r requirements.txt (line 2)) (3.0.0)\n", + "Requirement already satisfied: vega_datasets in ./env-1/lib/python3.10/site-packages (from -r requirements.txt (line 3)) (0.9.0)\n", + "Requirement already satisfied: jinja2 in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (3.1.2)\n", + "Requirement already satisfied: jsonschema>=3.0 in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (4.19.2)\n", + "Requirement already satisfied: numpy in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (1.26.2)\n", + "Requirement already satisfied: packaging in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (23.2)\n", + "Requirement already satisfied: pandas>=0.25 in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (2.1.3)\n", + "Requirement already satisfied: toolz in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (0.12.0)\n", + "Requirement already satisfied: typing-extensions>=4.0.1 in ./env-1/lib/python3.10/site-packages (from altair->-r requirements.txt (line 1)) (4.8.0)\n", + "Requirement already satisfied: Werkzeug>=3.0.0 in ./env-1/lib/python3.10/site-packages (from flask->-r requirements.txt (line 2)) (3.0.1)\n", + "Requirement already satisfied: itsdangerous>=2.1.2 in ./env-1/lib/python3.10/site-packages (from flask->-r requirements.txt (line 2)) (2.1.2)\n", + "Requirement already satisfied: click>=8.1.3 in ./env-1/lib/python3.10/site-packages (from flask->-r requirements.txt (line 2)) (8.1.7)\n", + "Requirement already satisfied: blinker>=1.6.2 in ./env-1/lib/python3.10/site-packages (from flask->-r requirements.txt (line 2)) (1.7.0)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in ./env-1/lib/python3.10/site-packages (from jinja2->altair->-r requirements.txt (line 1)) (2.1.3)\n", + "Requirement already satisfied: attrs>=22.2.0 in ./env-1/lib/python3.10/site-packages (from jsonschema>=3.0->altair->-r requirements.txt (line 1)) (23.1.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in ./env-1/lib/python3.10/site-packages (from jsonschema>=3.0->altair->-r requirements.txt (line 1)) (2023.7.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in ./env-1/lib/python3.10/site-packages (from jsonschema>=3.0->altair->-r requirements.txt (line 1)) (0.30.2)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in ./env-1/lib/python3.10/site-packages (from jsonschema>=3.0->altair->-r requirements.txt (line 1)) (0.12.0)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in ./env-1/lib/python3.10/site-packages (from pandas>=0.25->altair->-r requirements.txt (line 1)) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in ./env-1/lib/python3.10/site-packages (from pandas>=0.25->altair->-r requirements.txt (line 1)) (2023.3.post1)\n", + "Requirement already satisfied: tzdata>=2022.1 in ./env-1/lib/python3.10/site-packages (from pandas>=0.25->altair->-r requirements.txt (line 1)) (2023.3)\n", + "Requirement already satisfied: six>=1.5 in ./env-1/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas>=0.25->altair->-r requirements.txt (line 1)) (1.16.0)\n" ] } ], "source": [ - "pip install -r requirements.txt" + "# To run this command in a terminal, simply call the source command above, as it sets the path to the correct python3 installation\n", + "!./env-1/bin/python3 -m pip install -r requirements.txt" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 10, "metadata": { "editable": true, "slideshow": { @@ -274,35 +265,37 @@ "output_type": "stream", "text": [ "Package Version\n", - "------------------------- --------\n", - "altair 5.0.1\n", + "------------------------- ------------\n", + "altair 5.1.2\n", "attrs 23.1.0\n", - "blinker 1.6.2\n", + "blinker 1.7.0\n", "click 8.1.7\n", - "Flask 2.3.3\n", + "Flask 3.0.0\n", "itsdangerous 2.1.2\n", "Jinja2 3.1.2\n", - "jsonschema 4.19.0\n", + "jsonschema 4.19.2\n", "jsonschema-specifications 2023.7.1\n", "MarkupSafe 2.1.3\n", - "numpy 1.25.2\n", - "pandas 2.0.3\n", - "pip 23.2.1\n", + "numpy 1.26.2\n", + "packaging 23.2\n", + "pandas 2.1.3\n", + "pip 23.3.1\n", "python-dateutil 2.8.2\n", - "pytz 2023.3\n", + "pytz 2023.3.post1\n", "referencing 0.30.2\n", - "rpds-py 0.9.2\n", + "rpds-py 0.12.0\n", "setuptools 65.5.0\n", "six 1.16.0\n", "toolz 0.12.0\n", + "typing_extensions 4.8.0\n", "tzdata 2023.3\n", "vega-datasets 0.9.0\n", - "Werkzeug 2.3.7\n" + "Werkzeug 3.0.1\n" ] } ], "source": [ - "pip list" + "!./env-1/bin/python3 -m pip list" ] }, { @@ -317,28 +310,30 @@ "source": [ "But what about reproducible builds? What if a new release of altair breaks my application?\n", "\n", - "Solution: Pin specific versions?\n", + "**Solution:** Pin specific versions?\n", "\n", - "```\n", + "```bash\n", "# requirements.txt\n", "altair==4.1.0\n", "vega-datasets==0.8.0\n", "flask==1.1.2\n", "```\n", "\n", - "💣 this is the works possible thing!\n", + "```{warning}\n", + "💣 this is the worst possible thing!\n", "\n", "1. it ensures that your direct dependencies are not updated (fine), but\n", "2. it **does not** ensure that their dependencies are not updated\n", + "```\n", "\n", - "This *guarantees* that your env will break when a dependency is updated. If you had left everything unpinned, it is likely your code would not break, unless the APIs your code uses change. But partial pinning is a way to *guarantee* something will break, even if your code works fine with the latest version of everything.\n", + "This _guarantees_ that your env will break when a dependency is updated. If you had left everything unpinned, it is likely your code would not break, unless the APIs your code uses change. But partial pinning is a way to _guarantee_ something will break, even if your code works fine with the latest version of everything.\n", "\n", - "If you are pinning dependencies, it should be *all or nothing*, never partial. Ideally, this should include Python itself!" + "If you are pinning dependencies, it should be _all or nothing_, never partial. Ideally, this should include Python itself!\n" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 11, "metadata": { "editable": true, "slideshow": { @@ -351,32 +346,34 @@ "name": "stdout", "output_type": "stream", "text": [ - "altair==5.0.1\n", + "altair==5.1.2\n", "attrs==23.1.0\n", - "blinker==1.6.2\n", + "blinker==1.7.0\n", "click==8.1.7\n", - "Flask==2.3.3\n", + "Flask==3.0.0\n", "itsdangerous==2.1.2\n", "Jinja2==3.1.2\n", - "jsonschema==4.19.0\n", + "jsonschema==4.19.2\n", "jsonschema-specifications==2023.7.1\n", "MarkupSafe==2.1.3\n", - "numpy==1.25.2\n", - "pandas==2.0.3\n", + "numpy==1.26.2\n", + "packaging==23.2\n", + "pandas==2.1.3\n", "python-dateutil==2.8.2\n", - "pytz==2023.3\n", + "pytz==2023.3.post1\n", "referencing==0.30.2\n", - "rpds-py==0.9.2\n", + "rpds-py==0.12.0\n", "six==1.16.0\n", "toolz==0.12.0\n", + "typing_extensions==4.8.0\n", "tzdata==2023.3\n", "vega-datasets==0.9.0\n", - "Werkzeug==2.3.7\n" + "Werkzeug==3.0.1\n" ] } ], "source": [ - "pip freeze" + "!./env-1/bin/python3 -m pip freeze" ] }, { @@ -389,15 +386,17 @@ "tags": [] }, "source": [ + "## Pip-tools\n", + "\n", "[pip-tools](https://github.com/jazzband/pip-tools) is a collection of tools to solve\n", "the \"loose vs pinned\" dependency problem.\n", "\n", - "Instead of a single `requirements.txt`, you have a human-mananged `requirements.in` with only direct, loose dependencies, and an automatically managed `requirements.txt` with a fully pinned environment, including all dependencies." + "Instead of a single `requirements.txt`, you have a human-mananged `requirements.in` with only direct, loose dependencies, and an automatically managed `requirements.txt` with a fully pinned environment, including all dependencies.\n" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "metadata": { "editable": true, "slideshow": { @@ -411,34 +410,34 @@ "output_type": "stream", "text": [ "Collecting pip-tools\n", - " Obtaining dependency information for pip-tools from https://files.pythonhosted.org/packages/e8/df/47e6267c6b5cdae867adbdd84b437393e6202ce4322de0a5e0b92960e1d6/pip_tools-7.3.0-py3-none-any.whl.metadata\n", " Using cached pip_tools-7.3.0-py3-none-any.whl.metadata (23 kB)\n", "Collecting build (from pip-tools)\n", - " Using cached build-0.10.0-py3-none-any.whl (17 kB)\n", - "Requirement already satisfied: click>=8 in ./env-1/lib/python3.11/site-packages (from pip-tools) (8.1.7)\n", - "Requirement already satisfied: pip>=22.2 in ./env-1/lib/python3.11/site-packages (from pip-tools) (23.2.1)\n", - "Requirement already satisfied: setuptools in ./env-1/lib/python3.11/site-packages (from pip-tools) (65.5.0)\n", + " Using cached build-1.0.3-py3-none-any.whl.metadata (4.2 kB)\n", + "Requirement already satisfied: click>=8 in ./env-1/lib/python3.10/site-packages (from pip-tools) (8.1.7)\n", + "Requirement already satisfied: pip>=22.2 in ./env-1/lib/python3.10/site-packages (from pip-tools) (23.3.1)\n", + "Requirement already satisfied: setuptools in ./env-1/lib/python3.10/site-packages (from pip-tools) (65.5.0)\n", "Collecting wheel (from pip-tools)\n", - " Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/b8/8b/31273bf66016be6ad22bb7345c37ff350276cfd46e389a0c2ac5da9d9073/wheel-0.41.2-py3-none-any.whl.metadata\n", - " Using cached wheel-0.41.2-py3-none-any.whl.metadata (2.2 kB)\n", - "Collecting packaging>=19.0 (from build->pip-tools)\n", - " Using cached packaging-23.1-py3-none-any.whl (48 kB)\n", + " Using cached wheel-0.41.3-py3-none-any.whl.metadata (2.2 kB)\n", + "Collecting tomli (from pip-tools)\n", + " Using cached tomli-2.0.1-py3-none-any.whl (12 kB)\n", + "Requirement already satisfied: packaging>=19.0 in ./env-1/lib/python3.10/site-packages (from build->pip-tools) (23.2)\n", "Collecting pyproject_hooks (from build->pip-tools)\n", " Using cached pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)\n", "Using cached pip_tools-7.3.0-py3-none-any.whl (57 kB)\n", - "Using cached wheel-0.41.2-py3-none-any.whl (64 kB)\n", - "Installing collected packages: wheel, pyproject_hooks, packaging, build, pip-tools\n", - "Successfully installed build-0.10.0 packaging-23.1 pip-tools-7.3.0 pyproject_hooks-1.0.0 wheel-0.41.2\n" + "Using cached build-1.0.3-py3-none-any.whl (18 kB)\n", + "Using cached wheel-0.41.3-py3-none-any.whl (65 kB)\n", + "Installing collected packages: wheel, tomli, pyproject_hooks, build, pip-tools\n", + "Successfully installed build-1.0.3 pip-tools-7.3.0 pyproject_hooks-1.0.0 tomli-2.0.1 wheel-0.41.3\n" ] } ], "source": [ - "pip install pip-tools" + "!./env-1/bin/python3 -m pip install pip-tools" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 13, "metadata": { "editable": true, "slideshow": { @@ -448,28 +447,20 @@ }, "outputs": [], "source": [ - "cp requirements.txt pip-tools/requirements.in\n", - "rm -f pip-tools/requirements.txt" + "!cp requirements.txt pip-tools/requirements.in\n", + "!rm -f pip-tools/requirements.txt" ] }, { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "cd pip-tools" + "We can now navigate into the folder with the `requirements.in` file, and call `pip-compile` (or if we want to be particular about the version, call `path/to/python/installation -m piptools compile`)\n" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 18, "metadata": { "editable": true, "slideshow": { @@ -484,22 +475,22 @@ "text": [ "\u001b[33mWARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.\u001b[0m\n", "\u001b[32m#\u001b[0m\u001b[0m\n", - "\u001b[32m# This file is autogenerated by pip-compile with Python 3.11\u001b[0m\u001b[0m\n", + "\u001b[32m# This file is autogenerated by pip-compile with Python 3.10\u001b[0m\u001b[0m\n", "\u001b[32m# by the following command:\u001b[0m\u001b[0m\n", "\u001b[32m#\u001b[0m\u001b[0m\n", "\u001b[32m# pip-compile\u001b[0m\u001b[0m\n", "\u001b[32m#\u001b[0m\u001b[0m\n", - "altair==5.0.1\n", + "altair==5.1.2\n", " \u001b[32m# via -r requirements.in\u001b[0m\u001b[0m\n", "attrs==23.1.0\n", " \u001b[32m# via\n", " # jsonschema\n", " # referencing\u001b[0m\u001b[0m\n", - "blinker==1.6.2\n", + "blinker==1.7.0\n", " \u001b[32m# via flask\u001b[0m\u001b[0m\n", "click==8.1.7\n", " \u001b[32m# via flask\u001b[0m\u001b[0m\n", - "flask==2.3.3\n", + "flask==3.0.0\n", " \u001b[32m# via -r requirements.in\u001b[0m\u001b[0m\n", "itsdangerous==2.1.2\n", " \u001b[32m# via flask\u001b[0m\u001b[0m\n", @@ -507,7 +498,7 @@ " \u001b[32m# via\n", " # altair\n", " # flask\u001b[0m\u001b[0m\n", - "jsonschema==4.19.0\n", + "jsonschema==4.19.2\n", " \u001b[32m# via altair\u001b[0m\u001b[0m\n", "jsonschema-specifications==2023.7.1\n", " \u001b[32m# via jsonschema\u001b[0m\u001b[0m\n", @@ -515,23 +506,25 @@ " \u001b[32m# via\n", " # jinja2\n", " # werkzeug\u001b[0m\u001b[0m\n", - "numpy==1.25.2\n", + "numpy==1.26.2\n", " \u001b[32m# via\n", " # altair\n", " # pandas\u001b[0m\u001b[0m\n", - "pandas==2.0.3\n", + "packaging==23.2\n", + " \u001b[32m# via altair\u001b[0m\u001b[0m\n", + "pandas==2.1.3\n", " \u001b[32m# via\n", " # altair\n", " # vega-datasets\u001b[0m\u001b[0m\n", "python-dateutil==2.8.2\n", " \u001b[32m# via pandas\u001b[0m\u001b[0m\n", - "pytz==2023.3\n", + "pytz==2023.3.post1\n", " \u001b[32m# via pandas\u001b[0m\u001b[0m\n", "referencing==0.30.2\n", " \u001b[32m# via\n", " # jsonschema\n", " # jsonschema-specifications\u001b[0m\u001b[0m\n", - "rpds-py==0.9.2\n", + "rpds-py==0.12.0\n", " \u001b[32m# via\n", " # jsonschema\n", " # referencing\u001b[0m\u001b[0m\n", @@ -539,17 +532,19 @@ " \u001b[32m# via python-dateutil\u001b[0m\u001b[0m\n", "toolz==0.12.0\n", " \u001b[32m# via altair\u001b[0m\u001b[0m\n", + "typing-extensions==4.8.0\n", + " \u001b[32m# via altair\u001b[0m\u001b[0m\n", "tzdata==2023.3\n", " \u001b[32m# via pandas\u001b[0m\u001b[0m\n", "vega-datasets==0.9.0\n", " \u001b[32m# via -r requirements.in\u001b[0m\u001b[0m\n", - "werkzeug==2.3.7\n", + "werkzeug==3.0.1\n", " \u001b[32m# via flask\u001b[0m\u001b[0m\n" ] } ], "source": [ - "pip-compile" + "!cd pip-tools && ../env-1/bin/python3 -m piptools compile" ] }, { @@ -565,21 +560,21 @@ "When you start, there is no difference between\n", "\n", "```bash\n", - "pip install -r requirements.in\n", + "python3 -m pip install -r requirements.in\n", "```\n", "\n", "and\n", "\n", "```bash\n", - "pip install -r requirements.txt\n", + "python3 -m pip install -r requirements.txt\n", "```\n", "\n", - "The distinction is: `requirements.in` will install *different things over time*, while `requirements.txt` will always install the same exact things until you change it, e.g. by running `pip-compile` again to upgrade packages, or after editing `requirements.in`.\n" + "The distinction is: `requirements.in` will install _different things over time_, while `requirements.txt` will always install the same exact things until you change it, e.g. by running `pip-compile` again to upgrade packages, or after editing `requirements.in`.\n" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 20, "metadata": { "editable": true, "slideshow": { @@ -599,12 +594,12 @@ } ], "source": [ - "cat requirements.in" + "!cat pip-tools/requirements.in" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 21, "metadata": { "editable": true, "slideshow": { @@ -618,22 +613,22 @@ "output_type": "stream", "text": [ "#\n", - "# This file is autogenerated by pip-compile with Python 3.11\n", + "# This file is autogenerated by pip-compile with Python 3.10\n", "# by the following command:\n", "#\n", "# pip-compile\n", "#\n", - "altair==5.0.1\n", + "altair==5.1.2\n", " # via -r requirements.in\n", "attrs==23.1.0\n", " # via\n", " # jsonschema\n", " # referencing\n", - "blinker==1.6.2\n", + "blinker==1.7.0\n", " # via flask\n", "click==8.1.7\n", " # via flask\n", - "flask==2.3.3\n", + "flask==3.0.0\n", " # via -r requirements.in\n", "itsdangerous==2.1.2\n", " # via flask\n", @@ -641,7 +636,7 @@ " # via\n", " # altair\n", " # flask\n", - "jsonschema==4.19.0\n", + "jsonschema==4.19.2\n", " # via altair\n", "jsonschema-specifications==2023.7.1\n", " # via jsonschema\n", @@ -649,23 +644,25 @@ " # via\n", " # jinja2\n", " # werkzeug\n", - "numpy==1.25.2\n", + "numpy==1.26.2\n", " # via\n", " # altair\n", " # pandas\n", - "pandas==2.0.3\n", + "packaging==23.2\n", + " # via altair\n", + "pandas==2.1.3\n", " # via\n", " # altair\n", " # vega-datasets\n", "python-dateutil==2.8.2\n", " # via pandas\n", - "pytz==2023.3\n", + "pytz==2023.3.post1\n", " # via pandas\n", "referencing==0.30.2\n", " # via\n", " # jsonschema\n", " # jsonschema-specifications\n", - "rpds-py==0.9.2\n", + "rpds-py==0.12.0\n", " # via\n", " # jsonschema\n", " # referencing\n", @@ -673,17 +670,19 @@ " # via python-dateutil\n", "toolz==0.12.0\n", " # via altair\n", + "typing-extensions==4.8.0\n", + " # via altair\n", "tzdata==2023.3\n", " # via pandas\n", "vega-datasets==0.9.0\n", " # via -r requirements.in\n", - "werkzeug==2.3.7\n", + "werkzeug==3.0.1\n", " # via flask\n" ] } ], "source": [ - "cat requirements.txt" + "!cat pip-tools/requirements.txt" ] }, { @@ -702,28 +701,13 @@ "\n", "- uses [Pipfile](https://github.com/pypa/pipfile) format instead of requirements.txt\n", "- Pipfile.lock for pinned versions\n", - "- includes specifying the Python version itself, and additional informat about *how* to install pacakges\n", + "- includes specifying the Python version itself, and additional informat about _how_ to install pacakges\n", "- manages environments as well\n" ] }, { "cell_type": "code", - "execution_count": 14, - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "cd ../pipfile" - ] - }, - { - "cell_type": "code", - "execution_count": 15, + "execution_count": 24, "metadata": { "editable": true, "slideshow": { @@ -747,7 +731,7 @@ } ], "source": [ - "cat Pipfile" + "!cd pipfile && cat Pipfile" ] }, { @@ -760,12 +744,12 @@ "tags": [] }, "source": [ - "Leave our earlier env" + "If we are using a terminal were we have activate the `env-1` environment with the `source ./env-1/bin/activate` command, we can deactivate it by calling `deactivate`.\n" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 25, "metadata": { "editable": true, "slideshow": { @@ -778,25 +762,51 @@ "name": "stdout", "output_type": "stream", "text": [ - "DeprecationWarning: 'source deactivate' is deprecated. Use 'conda deactivate'.\n", - "Requirement already satisfied: pipenv in /Users/minrk/conda/lib/python3.11/site-packages (2023.8.26)\n", - "Requirement already satisfied: certifi in /Users/minrk/conda/lib/python3.11/site-packages (from pipenv) (2023.7.22)\n", - "Requirement already satisfied: setuptools>=67.0.0 in /Users/minrk/conda/lib/python3.11/site-packages (from pipenv) (68.1.2)\n", - "Requirement already satisfied: virtualenv>=20.24.2 in /Users/minrk/conda/lib/python3.11/site-packages (from pipenv) (20.24.3)\n", - "Requirement already satisfied: distlib<1,>=0.3.7 in /Users/minrk/conda/lib/python3.11/site-packages (from virtualenv>=20.24.2->pipenv) (0.3.7)\n", - "Requirement already satisfied: filelock<4,>=3.12.2 in /Users/minrk/conda/lib/python3.11/site-packages (from virtualenv>=20.24.2->pipenv) (3.12.2)\n", - "Requirement already satisfied: platformdirs<4,>=3.9.1 in /Users/minrk/conda/lib/python3.11/site-packages (from virtualenv>=20.24.2->pipenv) (3.10.0)\n" + "Collecting pipenv\n", + " Downloading pipenv-2023.10.24-py3-none-any.whl (3.2 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.2/3.2 MB\u001b[0m \u001b[31m17.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: certifi in /home/dokken/src/mambaforge/envs/UIO-IN3110/lib/python3.10/site-packages (from pipenv) (2023.7.22)\n", + "Requirement already satisfied: setuptools>=67 in /home/dokken/src/mambaforge/envs/UIO-IN3110/lib/python3.10/site-packages (from pipenv) (68.1.2)\n", + "Collecting virtualenv>=20.24.2 (from pipenv)\n", + " Downloading virtualenv-20.24.6-py3-none-any.whl (3.8 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.8/3.8 MB\u001b[0m \u001b[31m29.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", + "\u001b[?25hCollecting distlib<1,>=0.3.7 (from virtualenv>=20.24.2->pipenv)\n", + " Using cached distlib-0.3.7-py2.py3-none-any.whl (468 kB)\n", + "Collecting filelock<4,>=3.12.2 (from virtualenv>=20.24.2->pipenv)\n", + " Downloading filelock-3.13.1-py3-none-any.whl (11 kB)\n", + "Collecting platformdirs<4,>=3.9.1 (from virtualenv>=20.24.2->pipenv)\n", + " Downloading platformdirs-3.11.0-py3-none-any.whl (17 kB)\n", + "Installing collected packages: distlib, platformdirs, filelock, virtualenv, pipenv\n", + " Attempting uninstall: distlib\n", + " Found existing installation: distlib 0.3.6\n", + " Uninstalling distlib-0.3.6:\n", + " Successfully uninstalled distlib-0.3.6\n", + " Attempting uninstall: platformdirs\n", + " Found existing installation: platformdirs 2.6.2\n", + " Uninstalling platformdirs-2.6.2:\n", + " Successfully uninstalled platformdirs-2.6.2\n", + " Attempting uninstall: filelock\n", + " Found existing installation: filelock 3.12.0\n", + " Uninstalling filelock-3.12.0:\n", + " Successfully uninstalled filelock-3.12.0\n", + " Attempting uninstall: virtualenv\n", + " Found existing installation: virtualenv 20.21.1\n", + " Uninstalling virtualenv-20.21.1:\n", + " Successfully uninstalled virtualenv-20.21.1\n", + "Successfully installed distlib-0.3.7 filelock-3.13.1 pipenv-2023.10.24 platformdirs-3.10.0 virtualenv-20.24.6\n", + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.1.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.1\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" ] } ], "source": [ - "deactivate\n", - "pip install pipenv" + "!python3 -m pip install pipenv" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 26, "metadata": { "editable": true, "slideshow": { @@ -810,102 +820,42 @@ "output_type": "stream", "text": [ "\u001b[1mCreating a virtualenv for this project...\u001b[0m\n", - "Pipfile: \u001b[33m\u001b[1m/Users/minrk/dev/simula/in3110/site/lectures/production/pipfile/Pipfile\u001b[0m\n", - "\u001b[1mUsing\u001b[0m \u001b[33m\u001b[1m/opt/homebrew/bin/python3.10\u001b[0m \u001b[32m(3.10.13)\u001b[0m \u001b[1mto create virtualenv...\u001b[0m\n", - "\u001b[2K\u001b[32m⠸\u001b[0m Creating virtual environment...\u001b[36mcreated virtual environment CPython3.10.13.final.0-64 in 327ms\n", - " creator CPython3Posix(dest=/Users/minrk/env/pipfile-9GkG1Y10, clear=False, no_vcs_ignore=False, global=False)\n", - " seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/minrk/Library/Application Support/virtualenv)\n", - " added seed packages: pip==23.1.2, setuptools==68.0.0, wheel==0.40.0\n", - " activators XonshActivator,BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator\n", + "Pipfile: \u001b[33m\u001b[1m/home/dokken/Documents/src/UiO/UiO-IN3110.github.io/lectures/production/Pipfile\u001b[0m\n", + "\u001b[1mUsing default python from\u001b[0m \u001b[33m\u001b[1m/home/dokken/src/mambaforge/envs/UIO-IN3110/bin/python3\u001b[0m \u001b[32m(3.10.12)\u001b[0m \u001b[1mto create virtualenv...\u001b[0m\n", + "\u001b[2K\u001b[32m⠸\u001b[0m Creating virtual environment.....\u001b[36mcreated virtual environment CPython3.10.12.final.0-64 in 639ms\n", + " creator CPython3Posix(dest=/home/dokken/.local/share/virtualenvs/production-2vyAGA3H, clear=False, no_vcs_ignore=False, global=False)\n", + " seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/dokken/.local/share/virtualenv)\n", + " added seed packages: pip==23.3.1, setuptools==68.2.2, wheel==0.41.2\n", + " activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator\n", "\u001b[0m\n", "✔ Successfully created virtual environment!\n", - "\u001b[2K\u001b[32m⠼\u001b[0m Creating virtual environment...\n", - "\u001b[1A\u001b[2K\u001b[32mVirtualenv location: /Users/minrk/env/pipfile-9GkG1Y10\u001b[0m\n", + "\u001b[2K\u001b[32m⠸\u001b[0m Creating virtual environment...\n", + "\u001b[1A\u001b[2K\u001b[32mVirtualenv location: /home/dokken/.local/share/virtualenvs/production-2vyAGA3H\u001b[0m\n", + "\u001b[1mrequirements.txt\u001b[0m found in \n", + "\u001b[1;33m/home/dokken/Documents/src/UiO/UiO-IN3110.github.io/lectures/\u001b[0m\u001b[1;33mproduction\u001b[0m instead \n", + "of \u001b[1mPipfile\u001b[0m! Converting\u001b[33m...\u001b[0m\n", + "\u001b[2K✔ Success! Importing requirements.....\n", + "\u001b[2K\u001b[32m⠸\u001b[0m Importing requirements...\n", + "\u001b[1A\u001b[2K\u001b[1;31mWarning\u001b[0m: Your \u001b[1mPipfile\u001b[0m now contains pinned versions, if your \u001b[1mrequirements.txt\u001b[0m \n", + "did. \n", + "We recommend updating your \u001b[1mPipfile\u001b[0m to specify the \u001b[1;32m\"*\"\u001b[0m version, instead.\n", "Locking\u001b[0m \u001b[33m[packages]\u001b[0m dependencies...\u001b[0m\n", "\u001b[?25lBuilding requirements\u001b[33m...\u001b[0m\n", "\u001b[2KResolving dependencies\u001b[33m...\u001b[0m\n", "\u001b[2K✔ Success! Locking...\n", - "\u001b[32m⠇\u001b[0m Locking...Warning: INFO:pipenv.patched.pip._internal.operations.prepare:Collecting flask (from -r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for flask from https://files.pythonhosted.org/packages/fd/56/26f0be8adc2b4257df20c1c4260ddd0aa396cf8e75d90ab2f7ff99bc34f9/flask-2.3.3-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading flask-2.3.3-py3-none-any.whl.metadata (3.6 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting vega-datasets (from -r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 4))\n", - "INFO:pipenv.patched.pip._internal.network.download:Using cached vega_datasets-0.9.0-py3-none-any.whl (210 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting altair (from -r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for altair from https://files.pythonhosted.org/packages/b2/20/5c3b89d6f8d9938325a9330793438389e0dc94c34d921f6da35ec62095f3/altair-5.0.1-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading altair-5.0.1-py3-none-any.whl.metadata (8.5 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting Werkzeug>=2.3.7 (from flask->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for Werkzeug>=2.3.7 from https://files.pythonhosted.org/packages/9b/59/a7c32e3d8d0e546a206e0552a2c04444544f15c1da4a01df8938d20c6ffc/werkzeug-2.3.7-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading werkzeug-2.3.7-py3-none-any.whl.metadata (4.1 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting Jinja2>=3.1.2 (from flask->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.network.download:Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting itsdangerous>=2.1.2 (from flask->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.network.download:Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting click>=8.1.3 (from flask->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for click>=8.1.3 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting blinker>=1.6.2 (from flask->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading blinker-1.6.2-py3-none-any.whl (13 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting pandas (from vega-datasets->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 4))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for pandas from https://files.pythonhosted.org/packages/4a/f6/f620ca62365d83e663a255a41b08d2fc2eaf304e0b8b21bb6d62a7390fe3/pandas-2.0.3-cp310-cp310-macosx_11_0_arm64.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading pandas-2.0.3-cp310-cp310-macosx_11_0_arm64.whl.metadata (18 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting jsonschema>=3.0 (from altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for jsonschema>=3.0 from https://files.pythonhosted.org/packages/2b/ff/af59fd34bc4d7ac3e6e0cd1f3c10317d329b6c1aee179e8b24ad9a79fbac/jsonschema-4.19.0-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading jsonschema-4.19.0-py3-none-any.whl.metadata (8.2 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting numpy (from altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/c3/ea/1d95b399078ecaa7b5d791e1fdbb3aee272077d9fd5fb499593c87dec5ea/numpy-1.25.2-cp310-cp310-macosx_11_0_arm64.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading numpy-1.25.2-cp310-cp310-macosx_11_0_arm64.whl.metadata (5.6 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting toolz (from altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.network.download:Using cached toolz-0.12.0-py3-none-any.whl (55 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting typing-extensions>=4.0.1 (from altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for typing-extensions>=4.0.1 from https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting MarkupSafe>=2.0 (from Jinja2>=3.1.2->flask->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 3))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for MarkupSafe>=2.0 from https://files.pythonhosted.org/packages/20/1d/713d443799d935f4d26a4f1510c9e61b1d288592fb869845e5cc92a1e055/MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl.metadata (3.0 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting attrs>=22.2.0 (from jsonschema>=3.0->altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading attrs-23.1.0-py3-none-any.whl (61 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting jsonschema-specifications>=2023.03.6 (from jsonschema>=3.0->altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for jsonschema-specifications>=2023.03.6 from https://files.pythonhosted.org/packages/1c/24/83349ac2189cc2435e84da3f69ba3c97314d3c0622628e55171c6798ed80/jsonschema_specifications-2023.7.1-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading jsonschema_specifications-2023.7.1-py3-none-any.whl.metadata (2.8 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting referencing>=0.28.4 (from jsonschema>=3.0->altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for referencing>=0.28.4 from https://files.pythonhosted.org/packages/be/8e/56d6f1e2d591f4d6cbcba446cac4a1b0dc4f584537e2071d9bcee8eeab6b/referencing-0.30.2-py3-none-any.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading referencing-0.30.2-py3-none-any.whl.metadata (2.6 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting rpds-py>=0.7.1 (from jsonschema>=3.0->altair->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 2))\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Obtaining dependency information for rpds-py>=0.7.1 from https://files.pythonhosted.org/packages/cc/21/ee41dbc1f624faf5bb3e1fb936810220801141ffe73c7d2aab221c6ecb4b/rpds_py-0.9.2-cp310-cp310-macosx_11_0_arm64.whl.metadata\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading rpds_py-0.9.2-cp310-cp310-macosx_11_0_arm64.whl.metadata (3.7 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting python-dateutil>=2.8.2 (from pandas->vega-datasets->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 4))\n", - "INFO:pipenv.patched.pip._internal.network.download:Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting pytz>=2020.1 (from pandas->vega-datasets->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 4))\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading pytz-2023.3-py2.py3-none-any.whl (502 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting tzdata>=2022.1 (from pandas->vega-datasets->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 4))\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n", - "INFO:pipenv.patched.pip._internal.operations.prepare:Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas->vega-datasets->-r /var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/pipenv-4z9petos-requirements/pipenv-k2jk3w_z-constraints.txt (line 4))\n", - "INFO:pipenv.patched.pip._internal.network.download:Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading flask-2.3.3-py3-none-any.whl (96 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading altair-5.0.1-py3-none-any.whl (471 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading click-8.1.7-py3-none-any.whl (97 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading jsonschema-4.19.0-py3-none-any.whl (83 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading pandas-2.0.3-cp310-cp310-macosx_11_0_arm64.whl (10.8 MB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading numpy-1.25.2-cp310-cp310-macosx_11_0_arm64.whl (14.0 MB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading werkzeug-2.3.7-py3-none-any.whl (242 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading jsonschema_specifications-2023.7.1-py3-none-any.whl (17 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl (17 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading referencing-0.30.2-py3-none-any.whl (25 kB)\n", - "INFO:pipenv.patched.pip._internal.network.download:Downloading rpds_py-0.9.2-cp310-cp310-macosx_11_0_arm64.whl (306 kB)\u001b[0m\n", - "\u001b[2K\u001b[32m⠇\u001b[0m Locking...\n", + "\u001b[2K\u001b[32m⠦\u001b[0m Locking...\n", "\u001b[1A\u001b[2KLocking\u001b[0m \u001b[33m[dev-packages]\u001b[0m dependencies...\u001b[0m\n", "\u001b[1mUpdated Pipfile.lock (644e57b07835e87b285d8338676a8bde3d24b8412120203e96731a83b770b772)!\u001b[0m\n" ] } ], "source": [ - "pipenv lock" + "!python3 -m pipenv lock" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 27, "metadata": { "editable": true, "slideshow": { @@ -925,12 +875,12 @@ } ], "source": [ - "pipenv install" + "!python3 -m pipenv install" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 29, "metadata": { "editable": true, "slideshow": { @@ -943,17 +893,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "/Users/minrk/conda\n" + "/home/dokken/src/mambaforge/envs/UIO-IN3110\n" ] } ], "source": [ - "python -c \"import sys; print(sys.prefix)\"" + "!python3 -c \"import sys; print(sys.prefix)\"" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 30, "metadata": { "editable": true, "slideshow": { @@ -966,17 +916,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "/Users/minrk/env/pipfile-9GkG1Y10\n" + "/home/dokken/.local/share/virtualenvs/production-2vyAGA3H\n" ] } ], "source": [ - "pipenv run python -c \"import sys; print(sys.prefix)\"" + "!python3 -m pipenv run python -c \"import sys; print(sys.prefix)\"" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 32, "metadata": { "editable": true, "slideshow": { @@ -990,42 +940,43 @@ "output_type": "stream", "text": [ "Package Version\n", - "------------------------- --------\n", - "altair 5.0.1\n", + "------------------------- ------------\n", + "altair 5.1.2\n", "attrs 23.1.0\n", - "blinker 1.6.2\n", + "blinker 1.7.0\n", "click 8.1.7\n", - "Flask 2.3.3\n", + "Flask 3.0.0\n", "itsdangerous 2.1.2\n", "Jinja2 3.1.2\n", - "jsonschema 4.19.0\n", + "jsonschema 4.19.2\n", "jsonschema-specifications 2023.7.1\n", "MarkupSafe 2.1.3\n", - "numpy 1.25.2\n", - "pandas 2.0.3\n", - "pip 23.1.2\n", + "numpy 1.26.2\n", + "packaging 23.2\n", + "pandas 2.1.3\n", + "pip 23.3.1\n", "python-dateutil 2.8.2\n", - "pytz 2023.3\n", + "pytz 2023.3.post1\n", "referencing 0.30.2\n", - "rpds-py 0.9.2\n", - "setuptools 68.0.0\n", + "rpds-py 0.12.0\n", + "setuptools 68.2.2\n", "six 1.16.0\n", "toolz 0.12.0\n", - "typing_extensions 4.7.1\n", + "typing_extensions 4.8.0\n", "tzdata 2023.3\n", "vega-datasets 0.9.0\n", - "Werkzeug 2.3.7\n", - "wheel 0.40.0\n" + "Werkzeug 3.0.1\n", + "wheel 0.41.2\n" ] } ], "source": [ - "pipenv run pip list" + "!python3 -m pipenv run pip list" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 33, "metadata": { "editable": true, "slideshow": { @@ -1058,12 +1009,12 @@ " \"default\": {\n", " \"altair\": {\n", " \"hashes\": [\n", - " \"sha256:087d7033cb2d6c228493a053e12613058a5d47faf6a36aea3ff60305fd8b4cb0\",\n", - " \"sha256:9f3552ed5497d4dfc14cf48a76141d8c29ee56eae2873481b4b28134268c9bbe\"\n", + " \"sha256:7219708ec33c152e53145485040f428954ed15fd09b2a2d89e543e6d111dae7f\",\n", + " \"sha256:e5f52a71853a607c61ce93ad4a414b3d486cd0d46ac597a24ae8bd1ac99dd460\"\n", " ],\n", " \"index\": \"pypi\",\n", - " \"markers\": \"python_version >= '3.7'\",\n", - " \"version\": \"==5.0.1\"\n", + " \"markers\": \"python_version >= '3.8'\",\n", + " \"version\": \"==5.1.2\"\n", " },\n", " \"attrs\": {\n", " \"hashes\": [\n", @@ -1072,21 +1023,34 @@ } ], "source": [ - "head -n 30 Pipfile.lock" + "!head -n 30 Pipfile.lock" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Bash", - "language": "bash", - "name": "bash" + "display_name": "UIO-IN3110", + "language": "python", + "name": "python3" }, "language_info": { - "codemirror_mode": "shell", - "file_extension": ".sh", - "mimetype": "text/x-sh", - "name": "bash" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/lectures/production/pip-tools/requirements.txt b/lectures/production/pip-tools/requirements.txt index f803460..342523b 100644 --- a/lectures/production/pip-tools/requirements.txt +++ b/lectures/production/pip-tools/requirements.txt @@ -1,20 +1,20 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.10 # by the following command: # # pip-compile # -altair==5.0.1 +altair==5.1.2 # via -r requirements.in attrs==23.1.0 # via # jsonschema # referencing -blinker==1.6.2 +blinker==1.7.0 # via flask click==8.1.7 # via flask -flask==2.3.3 +flask==3.0.0 # via -r requirements.in itsdangerous==2.1.2 # via flask @@ -22,7 +22,7 @@ jinja2==3.1.2 # via # altair # flask -jsonschema==4.19.0 +jsonschema==4.19.2 # via altair jsonschema-specifications==2023.7.1 # via jsonschema @@ -30,23 +30,25 @@ markupsafe==2.1.3 # via # jinja2 # werkzeug -numpy==1.25.2 +numpy==1.26.2 # via # altair # pandas -pandas==2.0.3 +packaging==23.2 + # via altair +pandas==2.1.3 # via # altair # vega-datasets python-dateutil==2.8.2 # via pandas -pytz==2023.3 +pytz==2023.3.post1 # via pandas referencing==0.30.2 # via # jsonschema # jsonschema-specifications -rpds-py==0.9.2 +rpds-py==0.12.0 # via # jsonschema # referencing @@ -54,6 +56,8 @@ six==1.16.0 # via python-dateutil toolz==0.12.0 # via altair +typing-extensions==4.8.0 + # via altair tzdata==2023.3 # via pandas vega-datasets==0.9.0