├── setup.cfg ├── pylib ├── suba │ ├── __init__.py │ └── two.py ├── subb │ ├── __init__.py │ └── three.py ├── __init__.py └── mod.py ├── _static └── finaince_visual_low.png ├── the_modules.rst ├── pylib.rst ├── setup.py ├── Makefile ├── make.bat ├── install.sh ├── jupyter_shortcuts.json ├── .gitignore ├── README.md ├── the_readme.ipynb ├── conf.py └── the_package.ipynb /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | 4 | -------------------------------------------------------------------------------- /pylib/suba/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # pylib Example (Documentation) 3 | # 4 | from .two import two -------------------------------------------------------------------------------- /pylib/subb/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # pylib Example (Documentation) 3 | # 4 | from .three import three -------------------------------------------------------------------------------- /_static/finaince_visual_low.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yhilpisch/documentation/master/_static/finaince_visual_low.png -------------------------------------------------------------------------------- /pylib/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # pylib Example (Documentation) 3 | # 4 | __all__ = ['one', 'two', 'three'] 5 | from .mod import one 6 | from .suba import two 7 | from .subb import three -------------------------------------------------------------------------------- /the_modules.rst: -------------------------------------------------------------------------------- 1 | The Modules 2 | =========== 3 | 4 | This part of the documentation is automatically generated. 5 | 6 | Of course, custom content can be added. 7 | 8 | .. image:: _static/finaince_visual_low.png 9 | :width: 400 10 | 11 | one.py 12 | ------ 13 | 14 | .. automodule:: pylib.mod 15 | :members: 16 | 17 | two.py 18 | ------ 19 | 20 | .. automodule:: pylib.suba.two 21 | :members: 22 | 23 | three.py 24 | -------- 25 | 26 | .. automodule:: pylib.subb.three 27 | :members: 28 | -------------------------------------------------------------------------------- /pylib.rst: -------------------------------------------------------------------------------- 1 | .. pylib documentation master file 2 | You can adapt this file completely to your liking, but it should at least 3 | contain the root `toctree` directive. 4 | 5 | pylib --- Documentation Example 6 | =============================== 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | :caption: Contents: 11 | 12 | the_package.ipynb 13 | the_readme.ipynb 14 | the_modules.rst 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # 2 | # Setup file for 3 | # pylib example 4 | # 5 | # The Python Quants GmbH 6 | # 7 | from setuptools import setup 8 | 9 | with open('README.md', 'r') as f: 10 | long_description = f.read() 11 | 12 | setup(name='pylib', 13 | version='0.19', 14 | description='pylib Tools & Skills', 15 | long_description=long_description, 16 | long_description_content_type='text/markdown', 17 | author='Yves Hilpisch', 18 | author_email='training@tpq.io', 19 | url='http://certificate.tpq.io', 20 | packages=['pylib', 'pylib.suba', 'pylib.subb'], 21 | ) 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = pylib 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | 13 | help: 14 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 15 | 16 | .PHONY: help Makefile 17 | 18 | # Catch-all target: route all unknown targets to Sphinx using the new 19 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 20 | %: Makefile 21 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /pylib/subb/three.py: -------------------------------------------------------------------------------- 1 | # 2 | # pylib Example (Documentation) 3 | # 4 | # The Python Quants GmbH 5 | # 6 | import doctest 7 | 8 | def three(x): 9 | ''' Simple function. 10 | 11 | :Parameters: 12 | x: float 13 | input number 14 | 15 | :Returns: 16 | y: float 17 | output number, 3 * x 18 | 19 | :Raise: 20 | TypeError 21 | if x is not a number 22 | 23 | :Examples: 24 | >>> three(10) 25 | 30 26 | >>> three(20) 27 | 60 28 | >>> three('python') 29 | Traceback (most recent call last): 30 | ... 31 | TypeError: x must be of type int or float. 32 | ''' 33 | if type(x) not in [int, float]: 34 | raise TypeError('x must be of type int or float.') 35 | return 3 * x 36 | 37 | 38 | if __name__ == '__main__': 39 | doctest.testmod() 40 | 41 | -------------------------------------------------------------------------------- /pylib/suba/two.py: -------------------------------------------------------------------------------- 1 | # 2 | # pylib Example (Documentation) 3 | # two.py 4 | # 5 | # The Python Quants GmbH 6 | # 7 | import doctest 8 | 9 | 10 | def two(x): 11 | ''' Simple function. 12 | 13 | :Parameters: 14 | x: float 15 | input number 16 | 17 | :Returns: 18 | y: float 19 | output number 20 | 21 | :Raise: 22 | TypeError 23 | if x is not a number 24 | 25 | :Examples: 26 | >>> two(10) 27 | 20 28 | >>> two(20) 29 | 40 30 | >>> two('python') 31 | Traceback (most recent call last): 32 | ... 33 | TypeError: x must be of type int or float. 34 | ''' 35 | if type(x) not in [int, float]: 36 | raise TypeError('x must be of type int or float.') 37 | y = 2 * x 38 | return y 39 | 40 | 41 | if __name__ == '__main__': 42 | doctest.testmod() 43 | 44 | -------------------------------------------------------------------------------- /pylib/mod.py: -------------------------------------------------------------------------------- 1 | # 2 | # pylib Example 3 | # mod.py 4 | # 5 | # The Python Quants GmbH 6 | # 7 | import doctest 8 | 9 | 10 | def one(x): 11 | ''' Simple function. 12 | 13 | :Parameters: 14 | x: float 15 | input number 16 | 17 | :Returns: 18 | y: float 19 | output number 20 | 21 | :Raise: 22 | TypeError 23 | if x is not a number 24 | 25 | :Examples: 26 | >>> # from pylib import * 27 | >>> one(10) 28 | 10 29 | >>> one(20) 30 | 20 31 | >>> one('python') 32 | Traceback (most recent call last): 33 | ... 34 | TypeError: x must be of type int or float. 35 | ''' 36 | if type(x) not in [int, float]: 37 | raise TypeError('x must be of type int or float.') 38 | y = x 39 | return y 40 | 41 | if __name__ == '__main__': 42 | doctest.testmod() 43 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=pylib 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | 38 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Script to Install 3 | # Linux Tools 4 | # 5 | # The Python Quants GmbH 6 | # 7 | apt-get update 8 | apt-get upgrade -y 9 | 10 | # Linux System Tools 11 | apt-get install -y pandoc 12 | apt-get install -y wget screen htop 13 | apt-get install -y tree vim git man less 14 | 15 | # Python3 via Linux 16 | apt-get install -y python3 python3-pip 17 | apt-get install python-is-python3 18 | pip3 install pip --upgrade 19 | # pip install numpy pandas scipy 20 | # pip install matplotlib xarray 21 | pip install sphinx nbsphinx 22 | pip install twine q 23 | pip install setuptools wheels 24 | pip install ipython jupyterlab 25 | 26 | # Configuration 27 | wget https://certificate.tpq.io/.vimrc -O ~/.vimrc 28 | mkdir /root/.jupyter 29 | mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension/ 30 | cp jupyter_shortcuts.json /root/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings 31 | 32 | # JupyterLab 33 | jupyter server password 34 | # jupyter lab --allow-root --ip 0.0.0.0 --port 9999 35 | -------------------------------------------------------------------------------- /jupyter_shortcuts.json: -------------------------------------------------------------------------------- 1 | { 2 | "shortcuts": [ 3 | {"command": "kernelmenu:restart-and-clear", 4 | "keys": [ 5 | "Ctrl Shift R" 6 | ], 7 | "selector": "body"}, 8 | 9 | {"command": "runmenu:run-all", 10 | "keys": [ 11 | "Ctrl Shift A" 12 | ], 13 | "selector": "body"}, 14 | 15 | {"command": "runmenu:restart-and-run-all", 16 | "keys": [ 17 | "Ctrl Shift N" 18 | ], 19 | "selector": "body"}, 20 | 21 | {"command": "notebook:run-all-above", 22 | "keys": [ 23 | "Ctrl Shift Y" 24 | ], 25 | "selector": "body"}, 26 | 27 | 28 | {"command": "application:activate-next-tab", 29 | "keys": [ 30 | "Ctrl Shift ]" 31 | ], 32 | "selector": "body", 33 | "disabled": true 34 | }, 35 | {"command": "application:activate-previous-tab", 36 | "keys": [ 37 | "Ctrl Shift [" 38 | ], 39 | "selector": "body", 40 | "disabled": true 41 | }, 42 | {"command": "application:activate-next-tab", 43 | "keys": [ 44 | "Ctrl Shift L" 45 | ], 46 | "selector": "body" 47 | }, 48 | {"command": "application:activate-previous-tab", 49 | "keys": [ 50 | "Ctrl Shift K" 51 | ], 52 | "selector": "body" 53 | }, ] 54 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifics 2 | dx/ 3 | *.swp 4 | _build/ 5 | 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | *$py.class 10 | 11 | # C extensions 12 | *.so 13 | 14 | # Distribution / packaging 15 | .Python 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | .eggs/ 22 | lib/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | wheels/ 28 | *.egg-info/ 29 | .installed.cfg 30 | *.egg 31 | MANIFEST 32 | 33 | # PyInstaller 34 | # Usually these files are written by a python script from a template 35 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 36 | *.manifest 37 | *.spec 38 | 39 | # Installer logs 40 | pip-log.txt 41 | pip-delete-this-directory.txt 42 | 43 | # Unit test / coverage reports 44 | htmlcov/ 45 | .tox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | .hypothesis/ 53 | .pytest_cache/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # SageMath parsed files 87 | *.sage.py 88 | 89 | # Environments 90 | .env 91 | .venv 92 | env/ 93 | venv/ 94 | ENV/ 95 | env.bak/ 96 | venv.bak/ 97 | 98 | # Spyder project settings 99 | .spyderproject 100 | .spyproject 101 | 102 | # Rope project settings 103 | .ropeproject 104 | 105 | # mkdocs documentation 106 | /site 107 | 108 | # mypy 109 | .mypy_cache/ 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Tools & Skills 2 | 3 | **Distribution (Documentation)** 4 | 5 | Dr. Yves J. Hilpisch | The Python Quants GmbH 6 | 7 | Certificate Programs, November 2021 8 | 9 | (short link to this Git repository: http://bit.ly/ts_docu) 10 | 11 | 12 | 13 | 14 | 15 | ## Slides 16 | 17 | You find the slides under: 18 | 19 | https://certificate.tpq.io/tools_skills_dist.pdf 20 | 21 | 22 | ## Docker Container 23 | 24 | Using a Docker container should simplify working with the tools presented in this part of the class. You should clone the Git repository via 25 | 26 | git clone --depth=1 https://github.com/yhilpisch/documentation 27 | 28 | Then navigate to the folder of the Git repository (`documentation`) and run: 29 | 30 | docker run -ti -h tools -p 9999:9999 -v $(pwd):/root/git ubuntu:latest /bin/bash 31 | 32 | In the Docker container, to install the tools required execute: 33 | 34 | cd /root/git 35 | bash install.sh 36 | 37 | 38 | ## pylib — Documentation 39 | 40 | This is the rather simplistic documentation example from the Tools & Skills class of The Python Quants. 41 | 42 |
43 | 44 | 45 | 46 | ## Package 47 | 48 | The package documented contains a total of three simple Python files, two of which are in sub-folders/sub-packages, with a single function each. 49 | 50 | ## Training 51 | 52 | In addition to the package files, the Git repository contains also other files used for the training session. 53 | 54 | Slides are found under http://hilpisch.com/tools_skills_dist.pdf. 55 | 56 | ## Documentation 57 | 58 | ### Sphinx 59 | 60 | The `Sphinx` package represents a standard in Python documentation. See e.g. http://www.sphinx-doc.org and http://www.sphinx-doc.org/en/stable/tutorial.html. 61 | 62 | A valuable add-on is the `nbsphinx` extension which allows you to directly include Jupyter Notebook files into your documentation. See https://nbsphinx.readthedocs.io. 63 | 64 | ### Environment 65 | 66 | On the shell, create an environment with `conda`: 67 | 68 | conda create -n docu-pylib python=3.9 ipython jupyter pandoc 69 | conda activate docu-pylib 70 | pip install sphinx nbsphinx 71 | 72 | ### Build the Documentation 73 | 74 | Clone the Github repository to your local working folder: 75 | 76 | git clone http://github.com/yhilpisch/documentation 77 | 78 | Navigate to the repository folder and execute a doctest as well as build the documentation: 79 | 80 | cd documentation 81 | 82 | Uncomment in `pylib/mod.py` the following code 83 | 84 | >>> # from pylib import * 85 | 86 | Execute the doctest: 87 | 88 | make doctest 89 | 90 | Build the HTML documentation: 91 | 92 | make html 93 | 94 | The HTML documents are found in `_build`. 95 | 96 | 97 | ## First Steps 98 | 99 | Start a Python interactive session session and e.g. execute: 100 | 101 | >>> import pylib 102 | >>> pylib.one(10) 103 | 10 104 | >>> pylib.two(20) 105 | 40 106 | >>> pylib.three(3) 107 | 9 108 | 109 | ## Copyright 110 | 111 | The material is copyright (c) Dr. Yves J. Hilpisch | The Python Quants GmbH. MIT License. 112 | -------------------------------------------------------------------------------- /the_readme.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# The Readme" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "This is the rather simplistic documentation example from the Tools & Skills class of The Python Quants." 15 | ] 16 | }, 17 | { 18 | "cell_type": "markdown", 19 | "metadata": {}, 20 | "source": [ 21 | "## Package\n", 22 | "\n", 23 | "The package documented contains a total of three simple Python files, two of which are in sub-folders/sub-packages, with a single function each.\n", 24 | "\n", 25 | "## Training\n", 26 | "\n", 27 | "In addition to the package files, the Git repository contains also other files used for the training session.\n", 28 | "\n", 29 | "Slides are found under http://hilpisch.com/tools_skills_dist.pdf.\n", 30 | "\n", 31 | "## Documentation\n", 32 | "\n", 33 | "### Sphinx\n", 34 | "\n", 35 | "The `Sphinx` package represents a standard in Python documentation. See e.g. http://www.sphinx-doc.org and http://www.sphinx-doc.org/en/stable/tutorial.html.\n", 36 | "\n", 37 | "A valuable add-on is the `nbsphinx` extension which allows you to directly include Jupyter Notebook files into your documentation. See https://nbsphinx.readthedocs.io.\n", 38 | "\n", 39 | "### Environment\n", 40 | "\n", 41 | "On the shell, create an environment with `conda`:\n", 42 | "\n", 43 | " conda create -n docu-pylib python=3.9 ipython jupyterlab\n", 44 | " conda activate docu-pylib\n", 45 | " pip install sphinx nbsphinx\n", 46 | "\n", 47 | "### Build the Documentation\n", 48 | "\n", 49 | "Clone the Github repository to your local working folder:\n", 50 | "\n", 51 | " git clone http://github.com/yhilpisch/documentation\n", 52 | " \n", 53 | "Navigate to the repository folder and execute a doctest as well as build the documentation:\n", 54 | "\n", 55 | " cd documentation\n", 56 | " \n", 57 | "Uncomment in `pylib/mod.py` the following code\n", 58 | "\n", 59 | " >>> # from pylib import *\n", 60 | "\n", 61 | "Execute the doctest:\n", 62 | "\n", 63 | " make doctest\n", 64 | "\n", 65 | "Build the HTML documentation:\n", 66 | "\n", 67 | " make html\n", 68 | "\n", 69 | "The HTML documents are found in `_build`.\n", 70 | " \n", 71 | "## First Steps\n", 72 | " \n", 73 | "Start a Python interactive session session and e.g. execute:\n", 74 | "\n", 75 | " >>> import pylib\n", 76 | " >>> pylib.one(10)\n", 77 | " 10\n", 78 | " >>> pylib.two(20)\n", 79 | " 40\n", 80 | " >>> pylib.three(3)\n", 81 | " 9" 82 | ] 83 | }, 84 | { 85 | "cell_type": "markdown", 86 | "metadata": {}, 87 | "source": [ 88 | "## Copyright\n", 89 | "\n", 90 | "The material is copyright (c) Dr. Yves J. Hilpisch | The Python Quants GmbH. MIT License." 91 | ] 92 | } 93 | ], 94 | "metadata": { 95 | "kernelspec": { 96 | "display_name": "Python 3", 97 | "language": "python", 98 | "name": "python3" 99 | }, 100 | "language_info": { 101 | "codemirror_mode": { 102 | "name": "ipython", 103 | "version": 3 104 | }, 105 | "file_extension": ".py", 106 | "mimetype": "text/x-python", 107 | "name": "python", 108 | "nbconvert_exporter": "python", 109 | "pygments_lexer": "ipython3", 110 | "version": "3.8.6" 111 | } 112 | }, 113 | "nbformat": 4, 114 | "nbformat_minor": 4 115 | } 116 | -------------------------------------------------------------------------------- /conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Configuration file for the Sphinx documentation builder. 4 | # 5 | # This file does only contain a selection of the most common options. For a 6 | # full list see the documentation: 7 | # http://www.sphinx-doc.org/en/master/config 8 | 9 | # -- Path setup -------------------------------------------------------------- 10 | 11 | # If extensions (or modules to document with autodoc) are in another directory, 12 | # add these directories to sys.path here. If the directory is relative to the 13 | # documentation root, use os.path.abspath to make it absolute, like shown here. 14 | # 15 | import os 16 | import sys 17 | sys.path.insert(0, os.path.abspath('.')) 18 | 19 | 20 | # -- Project information ----------------------------------------------------- 21 | 22 | project = 'pylib' 23 | copyright = '2021, yves' 24 | author = 'yves' 25 | 26 | # The short X.Y version 27 | version = '' 28 | # The full version, including alpha/beta/rc tags 29 | release = '0.15' 30 | 31 | 32 | # -- General configuration --------------------------------------------------- 33 | 34 | # If your documentation needs a minimal Sphinx version, state it here. 35 | # 36 | # needs_sphinx = '1.0' 37 | 38 | # Add any Sphinx extension module names here, as strings. They can be 39 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 40 | # ones. 41 | extensions = [ 42 | 'nbsphinx', 43 | 'sphinx.ext.autodoc', 44 | 'sphinx.ext.doctest', 45 | 'sphinx.ext.coverage', 46 | 'sphinx.ext.mathjax', 47 | 'sphinx.ext.viewcode', 48 | ] 49 | 50 | # Add any paths that contain templates here, relative to this directory. 51 | templates_path = ['_templates'] 52 | 53 | # The suffix(es) of source filenames. 54 | # You can specify multiple suffix as a list of string: 55 | # 56 | # source_suffix = ['.rst', '.md'] 57 | source_suffix = '.rst' 58 | 59 | # The master toctree document. 60 | master_doc = 'pylib' 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | # 65 | # This is also used if you do content translation via gettext catalogs. 66 | # Usually you set "language" from the command line for these cases. 67 | language = None 68 | 69 | # List of patterns, relative to source directory, that match files and 70 | # directories to ignore when looking for source files. 71 | # This pattern also affects html_static_path and html_extra_path . 72 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints'] 73 | 74 | # The name of the Pygments (syntax highlighting) style to use. 75 | pygments_style = 'sphinx' 76 | 77 | 78 | # -- Options for HTML output ------------------------------------------------- 79 | 80 | # The theme to use for HTML and HTML Help pages. See the documentation for 81 | # a list of builtin themes. 82 | # 83 | html_theme = 'alabaster' 84 | 85 | # Theme options are theme-specific and customize the look and feel of a theme 86 | # further. For a list of options available for each theme, see the 87 | # documentation. 88 | # 89 | # html_theme_options = {} 90 | 91 | # Add any paths that contain custom static files (such as style sheets) here, 92 | # relative to this directory. They are copied after the builtin static files, 93 | # so a file named "default.css" will overwrite the builtin "default.css". 94 | html_static_path = ['_static'] 95 | 96 | # Custom sidebar templates, must be a dictionary that maps document names 97 | # to template names. 98 | # 99 | # The default sidebars (for documents that don't match any pattern) are 100 | # defined by theme itself. Builtin themes are using these templates by 101 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 102 | # 'searchbox.html']``. 103 | # 104 | # html_sidebars = {} 105 | 106 | 107 | # -- Options for HTMLHelp output --------------------------------------------- 108 | 109 | # Output file base name for HTML help builder. 110 | htmlhelp_basename = 'pylibdoc' 111 | 112 | 113 | # -- Options for LaTeX output ------------------------------------------------ 114 | 115 | latex_elements = { 116 | # The paper size ('letterpaper' or 'a4paper'). 117 | # 118 | # 'papersize': 'letterpaper', 119 | 120 | # The font size ('10pt', '11pt' or '12pt'). 121 | # 122 | # 'pointsize': '10pt', 123 | 124 | # Additional stuff for the LaTeX preamble. 125 | # 126 | # 'preamble': '', 127 | 128 | # Latex figure (float) alignment 129 | # 130 | # 'figure_align': 'htbp', 131 | } 132 | 133 | # Grouping the document tree into LaTeX files. List of tuples 134 | # (source start file, target name, title, 135 | # author, documentclass [howto, manual, or own class]). 136 | latex_documents = [ 137 | (master_doc, 'pylib.tex', 'pylib Documentation', 138 | 'yves', 'manual'), 139 | ] 140 | 141 | 142 | # -- Options for manual page output ------------------------------------------ 143 | 144 | # One entry per manual page. List of tuples 145 | # (source start file, name, description, authors, manual section). 146 | man_pages = [ 147 | (master_doc, 'pylib', 'pylib Documentation', 148 | [author], 1) 149 | ] 150 | 151 | 152 | # -- Options for Texinfo output ---------------------------------------------- 153 | 154 | # Grouping the document tree into Texinfo files. List of tuples 155 | # (source start file, target name, title, author, 156 | # dir menu entry, description, category) 157 | texinfo_documents = [ 158 | (master_doc, 'pylib', 'pylib Documentation', 159 | author, 'pylib', 'One line description of project.', 160 | 'Miscellaneous'), 161 | ] 162 | 163 | 164 | # -- Extension configuration ------------------------------------------------- 165 | -------------------------------------------------------------------------------- /the_package.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "\"The
" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "# The Package" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "Dr. Yves J. Hilpisch\n", 26 | "\n", 27 | "The Python Quants GmbH\n", 28 | "\n", 29 | "http://tpq.io | training@tpq.io" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": { 35 | "slideshow": { 36 | "slide_type": "subslide" 37 | } 38 | }, 39 | "source": [ 40 | "## Overview" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": { 46 | "slideshow": { 47 | "slide_type": "subslide" 48 | } 49 | }, 50 | "source": [ 51 | "The simple \"package\" consists of three main files. One file `mod.py` on the highest level and one file in each of the two sub-folders." 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": null, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "!find . -name *.pyc -type f -delete" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "!tree pylib" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": { 75 | "slideshow": { 76 | "slide_type": "subslide" 77 | } 78 | }, 79 | "source": [ 80 | "The files are all simple and short ..." 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "!cat pylib/mod.py" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": {}, 96 | "outputs": [], 97 | "source": [ 98 | "!cat pylib/suba/two.py" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "!cat pylib/subb/three.py" 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": { 113 | "slideshow": { 114 | "slide_type": "subslide" 115 | } 116 | }, 117 | "source": [ 118 | "The `__init__.py` files in the folders:" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": null, 124 | "metadata": {}, 125 | "outputs": [], 126 | "source": [ 127 | "!cat pylib/__init__.py" 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": null, 133 | "metadata": {}, 134 | "outputs": [], 135 | "source": [ 136 | "!cat pylib/suba/__init__.py" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "metadata": {}, 143 | "outputs": [], 144 | "source": [ 145 | "!cat pylib/subb/__init__.py" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "## Tutorial" 153 | ] 154 | }, 155 | { 156 | "cell_type": "markdown", 157 | "metadata": { 158 | "slideshow": { 159 | "slide_type": "subslide" 160 | } 161 | }, 162 | "source": [ 163 | "This packaging structure allows us to do the usual imports." 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": null, 169 | "metadata": {}, 170 | "outputs": [], 171 | "source": [ 172 | "import pylib" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": null, 178 | "metadata": { 179 | "slideshow": { 180 | "slide_type": "fragment" 181 | } 182 | }, 183 | "outputs": [], 184 | "source": [ 185 | "pylib.mod.one(10)" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": null, 191 | "metadata": { 192 | "slideshow": { 193 | "slide_type": "fragment" 194 | } 195 | }, 196 | "outputs": [], 197 | "source": [ 198 | "pylib.suba.two(20)" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "metadata": { 205 | "slideshow": { 206 | "slide_type": "fragment" 207 | } 208 | }, 209 | "outputs": [], 210 | "source": [ 211 | "pylib.subb.three(30)" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": null, 217 | "metadata": {}, 218 | "outputs": [], 219 | "source": [ 220 | "pylib.one(15)" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": null, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [ 229 | "pylib.two(15)" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "pylib.three(15)" 239 | ] 240 | }, 241 | { 242 | "cell_type": "markdown", 243 | "metadata": { 244 | "slideshow": { 245 | "slide_type": "subslide" 246 | } 247 | }, 248 | "source": [ 249 | "Star import is also possible." 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "metadata": { 256 | "slideshow": { 257 | "slide_type": "-" 258 | } 259 | }, 260 | "outputs": [], 261 | "source": [ 262 | "from pylib import *" 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "execution_count": null, 268 | "metadata": { 269 | "slideshow": { 270 | "slide_type": "fragment" 271 | } 272 | }, 273 | "outputs": [], 274 | "source": [ 275 | "one(100)" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": null, 281 | "metadata": { 282 | "slideshow": { 283 | "slide_type": "fragment" 284 | } 285 | }, 286 | "outputs": [], 287 | "source": [ 288 | "two(50)" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": null, 294 | "metadata": { 295 | "slideshow": { 296 | "slide_type": "fragment" 297 | } 298 | }, 299 | "outputs": [], 300 | "source": [ 301 | "three(33 + 1/3)" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": { 307 | "slideshow": { 308 | "slide_type": "slide" 309 | } 310 | }, 311 | "source": [ 312 | "## Installation" 313 | ] 314 | }, 315 | { 316 | "cell_type": "markdown", 317 | "metadata": { 318 | "slideshow": { 319 | "slide_type": "subslide" 320 | } 321 | }, 322 | "source": [ 323 | "Writing a `setup.py` script is explained here https://docs.python.org/3/distutils/setupscript.html. For our little example, such a script might look like:" 324 | ] 325 | }, 326 | { 327 | "cell_type": "code", 328 | "execution_count": null, 329 | "metadata": {}, 330 | "outputs": [], 331 | "source": [ 332 | "!cat setup.py" 333 | ] 334 | }, 335 | { 336 | "cell_type": "markdown", 337 | "metadata": { 338 | "slideshow": { 339 | "slide_type": "subslide" 340 | } 341 | }, 342 | "source": [ 343 | "Install the package via\n", 344 | "\n", 345 | " python setup.py install" 346 | ] 347 | }, 348 | { 349 | "cell_type": "markdown", 350 | "metadata": { 351 | "slideshow": { 352 | "slide_type": "slide" 353 | } 354 | }, 355 | "source": [ 356 | "\"The
\n", 357 | "\n", 358 | "http://tpq.io | @dyjh | training@tpq.io" 359 | ] 360 | } 361 | ], 362 | "metadata": { 363 | "anaconda-cloud": {}, 364 | "kernelspec": { 365 | "display_name": "Python 3", 366 | "language": "python", 367 | "name": "python3" 368 | }, 369 | "language_info": { 370 | "codemirror_mode": { 371 | "name": "ipython", 372 | "version": 3 373 | }, 374 | "file_extension": ".py", 375 | "mimetype": "text/x-python", 376 | "name": "python", 377 | "nbconvert_exporter": "python", 378 | "pygments_lexer": "ipython3", 379 | "version": "3.8.6" 380 | } 381 | }, 382 | "nbformat": 4, 383 | "nbformat_minor": 4 384 | } 385 | --------------------------------------------------------------------------------