Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 14-Dec-2021 | - | ||||
doc/ | H | 03-May-2022 | - | 119 | 99 | |
README.md | H A D | 14-Dec-2021 | 2.9 KiB | 99 | 73 | |
setup.py.in | H A D | 03-May-2022 | 4.1 KiB | 105 | 93 |
README.md
1# Introduction 2 3This is the documentation page for the Python 3.6+ wrapper of OR-Tools. 4 5This project aim to explain how you build a Python native wheel package using 6[`setup.py`](https://packaging.python.org/tutorials/packaging-projects/). 7 8## Table of Content 9 10* [Requirement](#requirement) 11* [Directory Layout](#directory-layout) 12* [Build Process](#build-process) 13 * [Local Package](#local-package) 14 * [Building a native Package](#building-local-native-package) 15* [Appendices](#appendices) 16 * [Resources](#resources) 17* [Misc](#misc) 18 19## Requirement 20 21You'll need "Python >= 3.6" and few python modules ("wheel" and "absl-py"). 22 23## Directory Layout 24 25* [setup.py.in](setup.py.in) `Setup.py` template to build the python native 26 project. 27 28## Build Process 29 30To Create a native dependent package which will contains two parts: 31* A bunch of native libraries for the supported platform targeted. 32* The Python code depending on it. 33 34note: Since [Pypi.org](https://pypi.org/) support multiple packages, we will 35simply upload one package per supported platform. 36 37### Local Package 38 39The pipeline for `linux-x86-64` should be as follow: \ 40note: The pipeline will be similar for other architectures, don't hesitate to 41look at the CI log! ![Local Pipeline](doc/local_pipeline.svg) 42![Legend](doc/legend.svg) 43 44#### Building local native Package 45 46Thus we have the C++ shared library `libortools.so` and the SWIG generated 47Python wrappers e.g. `pywrapsat.py` in the same package. 48 49Here some dev-note concerning this `setup.py`. 50* This package is a native package containing native libraries. 51 52Then you can generate the package and install it locally using: 53```bash 54python3 setup.py bdist_wheel 55python3 -m pip install --user --find-links=dist ortools 56``` 57 58If everything good the package (located in `<buildir>/python/dist`) should have 59this layout: 60``` 61{...}/dist/ortools-X.Y.9999-cp3Z-cp3Z-<platform>.whl: 62\- ortools 63 \- __init__.py 64 \- .libs 65 \- libortools.so 66 \- constraint_solver 67 \- __init__.py 68 \- pywrapcp.py 69 \- _pywrapcp.so 70 \- ... 71 \- __init__.py 72 \- pywrap....py 73 \- _pywrap....so 74... 75``` 76note: `<platform>` could be `manylinux2014_x86_64`, `macosx_10_9_x86_64` or `win-amd64`. 77 78tips: since wheel package are just zip archive you can use `unzip -l <package>.whl` 79to study their layout. 80 81## Appendices 82 83Few links on the subject... 84 85### Resources 86 87* [Packaging Python Project](https://packaging.python.org/tutorials/packaging-projects/) 88* [PEP 513 -- A Platform Tag for Portable Linux Built Distributions](https://www.python.org/dev/peps/pep-0513/) 89* [PEP 571 -- The manylinux2010 Platform Tag](https://www.python.org/dev/peps/pep-0571/) 90* [PEP 600 Future 'manylinux' Platform Tags](https://www.python.org/dev/peps/pep-0600/) 91 92## Misc 93 94Image has been generated using [plantuml](http://plantuml.com/): 95```bash 96plantuml -Tsvg doc/{file}.dot 97``` 98So you can find the dot source files in [doc](doc). 99