|
1 |
| -Overview |
2 |
| --------- |
3 |
| - |
4 |
| -pythonOCC is a python library whose purpose is to provide 3D modeling features. |
5 |
| -It's intended to |
6 |
| -developers who aim at developing a complete CAD/PLM application, and to |
7 |
| -engineers who want to have a total control over the data during complex design |
8 |
| -activities. |
9 |
| - |
10 |
| -About this document |
11 |
| -------------------- |
12 |
| - |
13 |
| -This file explains how to build pythonocc-core from source on Windows, Linux or |
14 |
| -MacOSX platforms. |
| 1 | +Build pythonocc-7.7.2 from scratch on a fresh Ubuntu 22.04 install |
| 2 | +------------------------------------------------------------------ |
15 | 3 |
|
16 | 4 | Requirements
|
17 | 5 | ------------
|
18 | 6 |
|
19 |
| -pythonOCC needs the following libraries or programs to be installed before you |
| 7 | +pythonOCC-7.7.2 needs the following libraries or programs to be installed before you |
20 | 8 | can compile/use it:
|
21 | 9 |
|
22 |
| -* the python programming language (<https://www.python.org>). Python 3.x is required. |
| 10 | +* the python programming language (<https://www.python.org>). Python 3.8 or more is required. |
23 | 11 |
|
24 |
| -* OpenCascade 7.7.0 (<https://dev.opencascade.org>) |
| 12 | +* OpenCascade 7.7.2 (<https://dev.opencascade.org>) |
25 | 13 |
|
26 |
| - IMPORTANT: OpenCASCADE has to be compiled using flag -D BUILD_RELEASE_DISABLE_EXCEPTIONS=OFF |
| 14 | +* SWIG 4.1.1 (<https://www.swig.org>) |
27 | 15 |
|
28 |
| -* SWIG 4.0.2 (<https://www.swig.org>) |
| 16 | +* rapidjson (<https://rapidjson.org/>) for Gltf import/export |
29 | 17 |
|
30 |
| -Optional |
31 |
| --------- |
32 |
| - |
33 |
| -If you want to benefit from a 3D graphical rendering, you will need a GUI manager, e.g. PyQt, PySide or wxPython. |
34 |
| - |
35 |
| -Create a local copy of the repository |
36 |
| -------------------------------------- |
| 18 | +* cmake |
37 | 19 |
|
| 20 | +All the necessary libraries can be downloaded/installed using apt: |
38 | 21 | ```bash
|
39 |
| -git clone https://github.com/tpaviot/pythonocc-core.git |
| 22 | +$ sudo apt-get update |
| 23 | +$ sudo apt-get install -y wget libglu1-mesa-dev libgl1-mesa-dev libxmu-dev libxi-dev build-essential cmake libfreetype6-dev tk-dev python3-dev rapidjson-dev python3 git python3-pip libpcre2-dev |
40 | 24 | ```
|
41 | 25 |
|
42 |
| -pythonocc-core compilation |
43 |
| --------------------------- |
44 |
| - |
| 26 | +Build swig |
| 27 | +---------- |
| 28 | +The required swgi version is 4.1.1. Unfortunately, the ubuntu ppa only provides an outdated 4.0.2 version. If swig 4.1.1 is not available on your machine, you have to download/build by yourself (depends on libpcre2, previously installed): |
45 | 29 | ```bash
|
46 |
| -cd pythonocc-core |
47 |
| -mkdir cmake-build |
48 |
| -cd cmake-build |
| 30 | +$ wget http://prdownloads.sourceforge.net/swig/swig-4.1.1.tar.gz |
| 31 | +$ tar -zxvf swig-4.1.1.tar.gz |
| 32 | +$ cd swig-4.1.1 |
| 33 | +$ ./configure && make -j4 && make install |
49 | 34 | ```
|
50 | 35 |
|
51 |
| -The configuration steps uses cmake: |
| 36 | +Build OpenCascade |
| 37 | +----------------- |
| 38 | + |
| 39 | +Download/extract version 7.7.2 https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=cec1ecd0c9f3b3d2572c47035d11949e8dfa85e2;sf=tgz |
52 | 40 |
|
53 | 41 | ```bash
|
54 |
| -cmake .. |
| 42 | +$ wget -o occt-7.7.2.tgz https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=cec1ecd0c9f3b3d2572c47035d11949e8dfa85e2;sf=tgz |
| 43 | +$ tar -zxvf occt-7.7.2.tgz |
55 | 44 | ```
|
56 | 45 |
|
57 |
| -By default, cmake looks for oce include headers in /usr/local/include/oce and |
58 |
| -libraries in /usr/local/include/lib. If these paths don't match your |
59 |
| -installation, you have to set OCE_INCLUDE_PATH and OCE_LIB_PATH: |
60 |
| - |
| 46 | +Prepare the build stage: |
61 | 47 | ```bash
|
62 |
| -cmake -DOCE_INCLUDE_PATH=/your_oce_headers -DOCE_LIB_PATH=/your_lib_dir .. |
| 48 | +$ cd occt-cec1ecd |
| 49 | +$ mkdir cmake-build |
| 50 | +$ cd cmake-build |
63 | 51 | ```
|
64 | 52 |
|
65 |
| -And launch the build process |
66 |
| - |
| 53 | +Choose an installation destination. Default is /usr/local, but it is better to set up |
| 54 | +an other folder so that it's easier to work with concurrent versions. |
67 | 55 | ```bash
|
68 |
| -make |
| 56 | +$ cmake -DINSTALL_DIR=/opt/build/occt772 -DBUILD_RELEASE_DISABLE_EXCEPTIONS=OFF .. |
69 | 57 | ```
|
70 |
| - |
71 |
| -If you have many cpus, you can increase the compilation speed with: |
72 |
| - |
| 58 | +then |
73 | 59 | ```bash
|
74 |
| -make -j$ncpus |
| 60 | +$ make -j4 |
| 61 | +``` |
| 62 | +and finally add the libraries to the system |
| 63 | +```bash |
| 64 | +echo "/opt/build/occt772/lib" >> /etc/ld.so.conf.d/occt.conf |
75 | 65 | ```
|
76 | 66 |
|
77 |
| -According to your machine/os/ncpus, the total compilation time should be around 15 minutes. |
| 67 | +Build pythonocc |
| 68 | +--------------- |
| 69 | +First create a local copy of the git repository: |
| 70 | +```bash |
| 71 | +git clone https://github.com/tpaviot/pythonocc-core.git |
| 72 | +``` |
| 73 | +then |
| 74 | +```bash |
| 75 | +cd xx/pythonocc-core |
| 76 | +mkdir cmake-build && cd cmake-build |
78 | 77 |
|
79 |
| -Then |
| 78 | +RUN cmake \ |
| 79 | + -DOCCT_INCLUDE_DIR=/opt/build/occt772/include/opencascade \ |
| 80 | + -DOCCT_LIBRARY_DIR=/opt/build/occt772/lib \ |
| 81 | + -DPYTHONOCC_BUILD_TYPE=Release \ |
| 82 | + .. |
80 | 83 |
|
81 |
| -```bash |
82 |
| -make install |
| 84 | +RUN make -j4 && make install |
83 | 85 | ```
|
84 | 86 |
|
85 |
| -You may require admin privileges to install |
| 87 | +simple test |
| 88 | +----------- |
| 89 | +``` |
| 90 | +$ python |
| 91 | +>>> from OCC.Core.gp import gp_Pnt |
| 92 | +>>> p = gp_Pnt(1., 2., 3.) |
| 93 | +>>> p.X() |
| 94 | +1.0 |
| 95 | +>>> |
| 96 | +``` |
86 | 97 |
|
87 |
| -```bash |
88 |
| -sudo make install |
| 98 | +additional dependencies |
| 99 | +----------------------- |
| 100 | +Additional python packages are required if you want to benefit from all pythonocc features. |
| 101 | +``` |
| 102 | +pip install svgwrite numpy matplotlib PyQt5 |
89 | 103 | ```
|
90 | 104 |
|
91 | 105 | test
|
|
0 commit comments