Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit bc45efc

Browse files
committed
Third session fixes and additions
1 parent c70177d commit bc45efc

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

sessions/03_pip-vs-conda.ipynb

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"source": [
1111
"![IE](../img/ie.png)\n",
1212
"\n",
13-
"# Sessions 4 & 5: pip vs conda\n",
13+
"# Sessions 5 & 6: pip vs conda\n",
1414
"\n",
1515
"### Juan Luis Cano Rodríguez <jcano@faculty.ie.edu> - Master in Business Analytics and Big Data (2019-04-05)"
1616
]
@@ -247,6 +247,50 @@
247247
" - <8.x (avoid like the plague!)\n",
248248
"* As a general rule, _don't upgrade straight away_ - the developers iron the issues after each release"
249249
]
250+
},
251+
{
252+
"cell_type": "markdown",
253+
"metadata": {},
254+
"source": [
255+
"## Project requirements\n",
256+
"\n",
257+
"We saw in the previous session how to make a project pip-installable. Sometimes our project will depend on third-party libraries (pandas, scikit-learn). To make pip install those dependencies automatically, we can add them to our `setup.cfg` under the `options` section, using the `install_requires` option:\n",
258+
"\n",
259+
"```\n",
260+
"[metadata]\n",
261+
"name = my_package\n",
262+
"version = 0.1.dev0\n",
263+
"\n",
264+
"# Remember not to touch package_dir, packages, and where\n",
265+
"[options]\n",
266+
"install_requires=\n",
267+
" pandas\n",
268+
" matplotlib>=2\n",
269+
"package_dir=\n",
270+
" =src\n",
271+
"packages=find:\n",
272+
"\n",
273+
"[options.packages.find]\n",
274+
"where=src\n",
275+
"```\n",
276+
"\n",
277+
"On the other hand, we might want to specify _optional_ dependencies that should only be installed upon request, or for some specific purposes. A typical example will be development dependencies: we will need things like pytest and black, but we don't want the user to install them as part as our library. To do that, we can specify *groups* of optional dependencies under the `options.extras_require` section:\n",
278+
"\n",
279+
"```\n",
280+
"[options.extras_require]\n",
281+
"dev=\n",
282+
" black\n",
283+
" pytest\n",
284+
"```\n",
285+
"\n",
286+
"That way, they will only get installed when `[dev]` is added after the name of our library:\n",
287+
"\n",
288+
"```\n",
289+
"$ pip install --editable .[dev]\n",
290+
"$ # pip install --editable /path/to/library/[dev] # Absolute instead of relative paths\n",
291+
"$ # pip install library[dev] # Libraries already available in pypi.org\n",
292+
"```"
293+
]
250294
}
251295
],
252296
"metadata": {

0 commit comments

Comments
 (0)