|
10 | 10 | "source": [
|
11 | 11 | "\n",
|
12 | 12 | "\n",
|
13 |
| - "# Sessions 4 & 5: pip vs conda\n", |
| 13 | + "# Sessions 5 & 6: pip vs conda\n", |
14 | 14 | "\n",
|
15 | 15 | "### Juan Luis Cano Rodríguez <jcano@faculty.ie.edu> - Master in Business Analytics and Big Data (2019-04-05)"
|
16 | 16 | ]
|
|
247 | 247 | " - <8.x (avoid like the plague!)\n",
|
248 | 248 | "* As a general rule, _don't upgrade straight away_ - the developers iron the issues after each release"
|
249 | 249 | ]
|
| 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 | + ] |
250 | 294 | }
|
251 | 295 | ],
|
252 | 296 | "metadata": {
|
|
0 commit comments