From e4373644adb36cda7038deb5113624f521e60818 Mon Sep 17 00:00:00 2001 From: David Daish Date: Mon, 10 Feb 2020 20:41:02 +1300 Subject: [PATCH 1/2] Migrate from https://gitlab.com/daviddaish/freecad_docker_env/ --- Dockerfile | 389 +++++++++++++++++ LICENSE | 165 ++++++++ README.md | 1 - add_files/freecad_build_script.sh | 22 + add_files/pivy_setup.py | 677 ++++++++++++++++++++++++++++++ readme.md | 89 ++++ 6 files changed, 1342 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 LICENSE delete mode 100644 README.md create mode 100755 add_files/freecad_build_script.sh create mode 100755 add_files/pivy_setup.py create mode 100644 readme.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7433af1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,389 @@ +FROM debian:stretch + +SHELL ["/bin/bash", "-c"] + +WORKDIR /tmp + +# Build tools, and misc supporting tools +RUN apt update && \ + apt install -y build-essential gfortran automake bison flex libtool git \ + wget unzip doxygen + +# Python v3.7.6 +RUN apt install -y zlib1g-dev libffi-dev libssl-dev && \ + wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz && \ + tar -xf Python-3.7.6.tar.xz && rm Python-3.7.6.tar.xz && \ + mkdir /tmp/Python-3.7.6/build && cd /tmp/Python-3.7.6/build && \ + ../configure --enable-shared \ + --enable-unicode=ucs4 --enable-ipv6 && \ + make -j $(nproc --ignore=2) && \ + make install -j $(nproc --ignore=2) && \ + ldconfig && \ + rm -rfv /tmp/* + +# Ensuring Python3.7 is the default version +RUN ln -sf /usr/local/bin/python3.7 /usr/bin/python && \ + ln -sf /usr/local/bin/python3.7-config /usr/local/bin/python-config && \ + # Ensuring python is found, even when program is not looking for "m" suffix + ln -s python3.7m /usr/local/include/python3.7 && \ + ln -s libpython3.7m.a /usr/local/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7.a + +# CMake v3.16.3 +RUN git clone --verbose -n https://gitlab.kitware.com/cmake/cmake.git && \ + mkdir /tmp/cmake/build && cd /tmp/cmake/build && \ + git checkout v3.16.3 && \ + # I may want to revert to an earlier version to see if the list concatenating + # issue encountered with Pivy remains. + ../bootstrap --parallel=$(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) && \ + make install -j $(nproc --ignore=2) && \ + rm -rfv /tmp/* + +# Boost v1.72.0 +RUN wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz && \ + tar -xzf boost_1_72_0.tar.gz && rm boost_1_72_0.tar.gz && \ + cd /tmp/boost_1_72_0 && \ + ./bootstrap.sh --with-python=/usr/local/bin/python3 \ + --with-python-root=/usr/local --with-python-version=3.7 && \ + ./b2 -j$(nproc --ignore=2) && \ + ./b2 -j$(nproc --ignore=2) install && \ + rm -rf /tmp/* + +# Link libboost_python, so it can be found without it's python version +RUN ln -s /usr/local/lib/libboost_python37.so.1.72.0 /usr/local/lib/libboost_python.so + +# Infrequently used languages +RUN apt install -y perl ruby + +# Freetype v 2.9.1 +RUN wget http://mirror.downloadvn.com/nongnu/freetype/freetype-2.9.1.tar.gz && \ + tar -xzf freetype-2.9.1.tar.gz && rm freetype-2.9.1.tar.gz && \ + cd /tmp/freetype-2.9.1 && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# QT5's accessability dependancies, webkit dependancies, multimedia +# dependancies, and Libxcb +RUN apt install -y libatspi2.0-dev libdbus-1-dev flex gperf libicu-dev \ + libxslt-dev ruby bison libasound2-dev libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev '^libxcb.*-dev' libx11-xcb-dev \ + libglu1-mesa-dev libxrender-dev libxi-dev libxcb-xinerama0-dev \ + libfontconfig1-dev libx11-dev libxext-dev libxfixes-dev libxcb1-dev \ + libxkbcommon-dev + +# QT5 v5.13.2 +RUN QT_VER=5.13.2 && \ + git clone -n git://code.qt.io/qt/qt5.git && \ + cd /tmp/qt5 && git checkout $QT_VER && \ + perl init-repository --module-subset=default,-qtpurchasing,\ +-qtgamepad,-qtfeedback,-qtandroidextras && \ + ./configure -opensource -confirm-license -qt-xcb \ + -nomake examples -nomake tests && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* && \ + ln -v -s /usr/local/Qt-$QT_VER /usr/local/Qt-5 +ENV PATH="/usr/local/Qt-5/bin:${PATH}" + +# QT Wayland v5.14.0 +RUN apt install -y libwayland-dev libwayland-egl1-mesa libwayland-server0 \ + libgles2-mesa-dev libxkbcommon-dev && \ + git clone -n git://code.qt.io/qt/qtwayland.git && \ + cd qtwayland && git checkout v5.13.2 &&\ + qmake && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# QT WebKit v5.212 +RUN apt install -y libsqlite3-dev libhyphen-dev libjpeg-dev libwebp-dev \ + libxcomposite-dev python2.7 && \ + git clone -n https://code.qt.io/qt/qtwebkit.git && \ + cd /tmp/qtwebkit && git checkout 5.212 && \ + mkdir /tmp/qtwebkit/build && cd build && \ + cmake -D PORT=Qt -D CMAKE_BUILD_TYPE=Release -D ENABLE_ALLINONE_BUILD=OFF .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Clang v9.0.1 +RUN git clone -n https://github.com/llvm/llvm-project.git && \ + cd /tmp/llvm-project && git checkout llvmorg-9.0.1 && \ + mkdir /tmp/llvm-project/build && cd /tmp/llvm-project/build && \ + cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" \ + -DCMAKE_BUILD_TYPE=Release ../llvm && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# TCL v8.7 +RUN wget https://prdownloads.sourceforge.net/tcl/tcl8.7a1-src.tar.gz && \ + tar -xzf tcl8.7a1-src.tar.gz && rm tcl8.7a1-src.tar.gz && \ + cd /tmp/tcl8.7a1/unix && \ + ./configure --enable-64bit --enable-shared --enable-gcc --enable-threads && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# TK v8.7 +RUN wget https://prdownloads.sourceforge.net/tcl/tk8.7a1-src.tar.gz && \ + tar -xzf tk8.7a1-src.tar.gz && rm tk8.7a1-src.tar.gz && \ + cd /tmp/tk8.7a1/unix && \ + ./configure --enable-64bit --enable-shared --enable-gcc --enable-threads && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Open Cascade v7.4 +RUN apt install -y libxt-dev libxmu-dev libxi-dev libgl1-mesa-dev \ + libglu1-mesa-dev libfreeimage-dev libtbb-dev && \ + wget "http://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=fd47711d682be943f0e0a13d1fb54911b0499c31;sf=tgz" -O occt.tar.gz && \ + mkdir /tmp/occt && \ + tar -xzf occt.tar.gz -C /tmp/occt --strip-components 1 && \ + mkdir /tmp/occt/build && cd /tmp/occt/build && \ + cmake .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Gmsh v4.5.1 +RUN wget gmsh.info/src/gmsh-4.5.1-source.tgz && \ + tar -xzf gmsh-4.5.1-source.tgz && rm gmsh-4.5.1-source.tgz && \ + mkdir /tmp/gmsh-4.5.1-source/build && cd /tmp/gmsh-4.5.1-source/build && \ + cmake .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Coin 3D v2020/1/25 +RUN git clone -n https://github.com/coin3d/coin.git && \ + cd /tmp/coin && git checkout 381b9acb29243d7e381106dbebb98f11681c10e5 && \ + mkdir /tmp/coin/build_tmp && cd /tmp/coin/build_tmp && \ + cmake .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Swig v4.0.1 +RUN apt install -y libpcre3-dev && \ + wget https://cfhcable.dl.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz && \ + tar -xzf swig-4.0.1.tar.gz && rm swig-4.0.1.tar.gz && \ + cd /tmp/swig-4.0.1 && \ + ./configure && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# SOQT v1.5.0 +RUN git clone -n https://github.com/coin3d/soqt.git && \ + cd /tmp/soqt && git checkout 2d0e3ed22f942d51380e1f8e67289b9eb6732f67 && \ + git submodule update --init --recursive && \ + mkdir /tmp/soqt/build_tmp && cd /tmp/soqt/build_tmp && \ + cmake -DCMAKE_PREFIX_PATH=/usr/local/Qt-5 .. && \ + make -j $(nproc --ignore=2) && make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Pivy v0.6.5 +RUN apt install -y gcc-multilib g++-multilib && \ + git clone -n https://github.com/coin3d/pivy.git && \ + cd /tmp/pivy && git checkout 0.6.5 && \ + rm setup.py +ADD add_files/pivy_setup.py /tmp/pivy/setup.py +RUN cd /tmp/pivy && \ + export CMAKE_PREFIX_PATH=/usr/local/Qt-5 && \ + CFLAGS="-fpermissive" python3 setup.py build && \ + python3 setup.py install && \ + rm -rfv /tmp/* +# There are four issues I ran into with the Pivy setup.py script while I was +# creating this Dockerfile. I am documenting the issues here, so I can resolve +# them in a less hacky way, later. +# 1) SWIG -I flags +# SWIG needs to be given the following additional flags: +# -I/usr/include/boost/compatibility/cpp_c_headers +# -I/usr/include/x86_64-linux-gnu/c++/6/ +# -I/usr/include/c++/6 +# 2) Finding qmake +# The script cannot find the qmake binary, so when running: +# `qtinfo.QtInfo()`, add this argument: +# `qtinfo.QtInfo(qmake_command=['/usr/local/Qt-5/bin/qmake'])` +# 3) CMake misreporting SoQt include dirs +# For some reason, CMake reports the SOQT_INCLUDE_DIR as +# `/usr/local/include/usr/include`, instead of +# `/usr/local/include;/usr/include`. I'm not entirely sure why. To work +# around that, overwrite the stored value like this: +# `config_dict["SOQT_INCLUDE_DIR"] = "/usr/local/include"` +# 4) -fpermissive flag +# I ran into the following issue when the swig-generated file coin_wrap.cpp +# got compiled. This forced me to add the -fpermissive flag to the +# compilation. While I'm not an expert, it is my understanding this is +# unsafe: +# pivy/coin_wrap.cpp: In function ‘void SoSensorPythonCB(void*, SoSensor*)’: +# pivy/coin_wrap.cpp:6342:40: warning: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] +# sensor_cast_name = PyUnicode_AsUTF8(item); +# ~~~~~~~~~~~~~~~~^~~~~~ +# pivy/coin_wrap.cpp: In function ‘void SoMarkerSet_addMarker__SWIG_3(int, const SbVec2s&, PyObject*, SbBool, SbBool)’: +# pivy/coin_wrap.cpp:7236:43: warning: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] +# coin_marker = PyUnicode_AsUTF8(string); +# ~~~~~~~~~~~~~~~~^~~~~~~~ + +# simage v1.8.0 +RUN git clone -n https://github.com/coin3d/simage.git && \ + cd /tmp/simage && git checkout simage-1.8.0 && \ + git submodule update --init --recursive && \ + mkdir /tmp/simage/tmp_build && cd /tmp/simage/tmp_build && \ + ../configure && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Eigen v3.3.7 +RUN git clone -n https://gitlab.com/libeigen/eigen.git && \ + cd /tmp/eigen && git checkout 3.3.7 && \ + mkdir /tmp/eigen/build && cd /tmp/eigen/build && \ + cmake .. && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# LibArea v12/7/2015 +RUN git clone -n https://github.com/danielfalck/libarea.git && \ + cd /tmp/libarea && git checkout 51e6778 && \ + mkdir /tmp/libarea/build && cd /tmp/libarea/build && \ + cmake .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Xerces C++ v3.2.2 +RUN wget https://www-eu.apache.org/dist//xerces/c/3/sources/xerces-c-3.2.2.tar.gz && \ + tar -xzf xerces-c-3.2.2.tar.gz && rm xerces-c-3.2.2.tar.gz && \ + mkdir /tmp/xerces-c-3.2.2/build && cd /tmp/xerces-c-3.2.2/build && \ + cmake .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Pyside2 and shiboken2 v5.13.2 +RUN git clone -n https://code.qt.io/pyside/pyside-setup && \ + cd /tmp/pyside-setup && git checkout v5.13.2 && \ + git submodule update --init --recursive --progress && \ + python setup.py install --cmake=/usr/local/bin/cmake \ + --qmake=/usr/local/Qt-5/bin/qmake --ignore-git \ + --parallel=$(nproc --ignore=2) && \ + # Create links to make it easier to point Freecad's CMAKE script to the + # shared libraries. + cd /usr/local/lib/python3.7/site-packages && \ + ln -s libshiboken2.cpython-37m-x86_64-linux-gnu.so.5.13 \ + shiboken2/libshiboken2.cpython-37m-x86_64-linux-gnu.so.5 && \ + ln -s libpyside2.cpython-37m-x86_64-linux-gnu.so.5.13 \ + PySide2/libpyside2.cpython-37m-x86_64-linux-gnu.so.5 && \ + rm -rfv /tmp/* + +# IFC Open Shell v0.6.0b0 +RUN git clone -n https://github.com/IfcOpenShell/IfcOpenShell.git && \ + cd /tmp/IfcOpenShell && git checkout v0.6.0b0 && \ + mkdir /tmp/IfcOpenShell/build && cd /tmp/IfcOpenShell/build && \ + cmake ../cmake -D COLLADA_SUPPORT=0 \ + -D OCC_INCLUDE_DIR=/usr/local/include/opencascade \ + -D OCC_LIBRARY_DIR=/usr/local/lib \ + -D LIBXML2_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxml2.so \ + -D LIBXML2_INCLUDE_DIR=/usr/include/libxml2 && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Numpy v1.16.2 and Matplotlib v3.0.3 +RUN python -m pip install cython==0.29.14 && python -m pip install numpy==1.18.1 matplotlib==3.1.2 + +# SPOOLES v2.2 +RUN mkdir spooles && cd spooles && \ + wget www.netlib.org/linalg/spooles/spooles.2.2.tgz && \ + tar -xzf spooles.2.2.tgz && \ + make lib CC=cc -j $(nproc --ignore=2) && \ + mkdir /usr/local/SPOOLES.2.2 && \ + mv * /usr/local/SPOOLES.2.2 && \ + rm -rfv /tmp/* + +# ARpack v96 +RUN mkdir arpack && cd arpack && \ + wget https://www.caam.rice.edu/software/ARPACK/SRC/arpack96.tar.gz && \ + wget https://www.caam.rice.edu/software/ARPACK/SRC/patch.tar.gz && \ + tar -xzf arpack96.tar.gz && \ + tar -xzf patch.tar.gz && \ + cd ARPACK && \ + sed -i 's/ EXTERNAL ETIME/* EXTERNAL ETIME/' UTIL/second.f && \ + make lib home=/tmp/arpack/ARPACK MAKE=make SHELL=bash FC=gfortran PLAT=INTEL FFLAGS="-O" && \ + mkdir /usr/local/ARPACK && \ + mv libarpack_INTEL.a /usr/local/ARPACK && \ + rm -rfv /tmp/* + +# CalculiX v2.16 +RUN cd /usr/local && \ + wget http://www.dhondt.de/ccx_2.16.src.tar.bz2 && \ + tar -xjvf ccx_2.16.src.tar.bz2 && \ + cd /usr/local/CalculiX/ccx_2.16/src && \ + make -j $(nproc --ignore=2)&& \ + mv ccx_2.16 /usr/local/bin/ccx && \ + cd /usr/local/bin && \ + chmod a+rx ccx + +# VTK v8.2.0 +RUN git clone -n https://gitlab.kitware.com/vtk/vtk.git && \ + mkdir /tmp/vtk/build && cd /tmp/vtk/build && \ + git checkout v8.2.0 && \ + cmake -DVTK_QT_VERSION:STRING=5 \ + -D QT_QMAKE_EXECUTABLE:PATH=/usr/local/Qt-5.12.6/bin/qmake \ + -D VTK_Group_Qt:BOOL=ON \ + -D CMAKE_PREFIX_PATH:PATH=/usr/local/Qt-5/lib/cmake \ + -D BUILD_SHARED_LIBS:BOOL=ON \ + .. && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# HDF5 v1.10.6 (CMake version) +ENV hdf5_path=/usr/local/hdf5 +RUN wget https://hdf-wordpress-1.s3.amazonaws.com/wp-content/uploads/manual/HDF5/HDF5_1_10_6/source/CMake-hdf5-1.10.6.tar.gz && \ + tar -xzf CMake-hdf5-1.10.6.tar.gz && \ + cd CMake-hdf5-1.10.6 && \ + ./build-unix.sh && \ + ./HDF5-1.10.6-Linux.sh --exclude-subdir --skip-license && \ + mkdir $hdf5_path && \ + mv HDF_Group/HDF5/1.10.6/* $hdf5_path && \ + export PATH=$PATH:$hdf5_path && \ + echo "$hdf5_path/lib" > /etc/ld.so.conf.d/hdf5.conf && \ + ldconfig && \ + # Because HDF5's libz.so does not have version information, link to use + # package installed version. + rm /usr/local/hdf5/lib/libz.so* && \ + ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/local/hdf5/lib/libz.so && \ + ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/local/hdf5/lib/libz.so.1 && \ + ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/local/hdf5/lib/libz.so.1.2.11 && \ + rm -rfv /tmp/* + +# HDF5's root has to be on the path for it to be detected. +ENV PATH=$PATH:$hdf5_path + +# Libmed v3.0.6-11 (AKA: MED-fichier/Modelisation and Data Exchange) +RUN wget https://salsa.debian.org/science-team/med-fichier/-/archive/debian/4.0.0+repack-9/med-fichier-debian-4.0.0+repack-9.tar.gz && \ + tar -xzf med-fichier-debian-4.0.0+repack-9.tar.gz && \ + rm med-fichier-debian-4.0.0+repack-9.tar.gz && \ + mkdir /tmp/med-fichier-debian-4.0.0+repack-9/build && \ + cd /tmp/med-fichier-debian-4.0.0+repack-9/build && \ + cmake .. && \ + make -j $(nproc --ignore=2) && make -j $(nproc --ignore=2) install && \ + rm -rfv /tmp/* + +# Add the build script +ADD add_files/freecad_build_script.sh /root/build_script.sh + +# Add enviroment varaible so CMake can find QT5 +ENV CMAKE_PREFIX_PATH=/usr/local/Qt-5 + +# So Qt5 can find it's shared libaries +RUN echo "/usr/local/Qt-5/lib" > /etc/ld.so.conf.d/qt5.conf && \ + ldconfig + +WORKDIR /root + +# Note for later: May need -fPIC diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md deleted file mode 100644 index f656f25..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -FreeCAD development & deployment with Docker. diff --git a/add_files/freecad_build_script.sh b/add_files/freecad_build_script.sh new file mode 100755 index 0000000..9b1b749 --- /dev/null +++ b/add_files/freecad_build_script.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +cmake -j$(nproc) \ + -D BOOST_ROOT=/usr/local/include/boost \ + -D BUILD_QT5=ON -D BUILD_FEM=ON -D BUILD_SANDBOX=ON \ + -D PYTHON_LIBRARY=/usr/local/lib/libpython3.7m.so \ + -D PYTHON_INCLUDE_DIR=/usr/local/include/python3.7 \ + -D PYTHON_PACKAGES_PATH=/usr/local/lib/python3.7/site-packages \ + -D PYTHON_EXECUTABLE=/usr/local/bin/python3 \ + -D SHIBOKEN_INCLUDE_DIR=/usr/local/lib/python3.7/site-packages/shiboken2_generator/include \ + -D SHIBOKEN_LIBRARY=/usr/local/lib/python3.7/site-packages/shiboken2/libshiboken2.cpython-37m-x86_64-linux-gnu.so.5 \ + -D PYSIDE_INCLUDE_DIR=/usr/local/lib/python3.7/site-packages/PySide2/include \ + -D PYSIDE_LIBRARY=/usr/local/lib/python3.7/site-packages/PySide2/libpyside2.cpython-37m-x86_64-linux-gnu.so.5 \ + -D PYSIDE2RCCBINARY=/usr/local/lib/python3.7/site-packages/PySide2/pyside2-rcc \ + -S /mnt/source \ + -B /mnt/build + +cd /mnt/build + +make -j $(nproc) diff --git a/add_files/pivy_setup.py b/add_files/pivy_setup.py new file mode 100755 index 0000000..f1f4177 --- /dev/null +++ b/add_files/pivy_setup.py @@ -0,0 +1,677 @@ +#!/usr/bin/env python + +### +# Copyright (c) 2002-2009 Systems in Motion +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +### +# Pivy distutils setup script. +# + +"""Pivy is a Coin binding for Python. Coin is a high-level 3D graphics +library with a C++ Application Programming Interface. Coin uses +scene-graph data structures to render real-time graphics suitable for +mostly all kinds of scientific and engineering visualization +applications. +""" + +### +# Setup file for the Pivy distribution. +# +import glob +import os +import shutil +import subprocess +import sys + +from distutils.command.build import build +from distutils.command.clean import clean +from distutils.command.install import install +from distutils.core import setup +from distutils.extension import Extension +from distutils import sysconfig + +# if we are on a Gentoo box salute the chap and output stuff in nice colors +# Gentoo is Python friendly, so be especially friendly to them! ;) +try: + from portage.output import green, blue, turquoise, red, yellow + print(red("Oooh, it's a Gentoo! Nice nice! tuhtah salutes you! :)")) +except: + try: + from colorama import Fore, Style + + def red(text): return Fore.RED + text + Style.RESET_ALL + + def green(text): return Fore.GREEN + text + Style.RESET_ALL + + def blue(text): return Fore.BLUE + text + Style.RESET_ALL + + def turquoise(text): return Fore.CYAN + text + Style.RESET_ALL + + def yellow(text): return Fore.YELLOW + text + Style.RESET_ALL + except: + def red(text): return text + + def green(text): return text + + def blue(text): return text + + def turquoise(text): return text + + def yellow(text): return text + +PIVY_CLASSIFIERS = """\ +Development Status :: 5 - Production/Stable +Intended Audience :: Developers +License :: OSI Approved :: BSD License +Operating System :: MacOS :: MacOS X +Operating System :: Microsoft :: Windows +Operating System :: Unix +Programming Language :: Python +Topic :: Multimedia :: Graphics +Topic :: Multimedia :: Graphics :: 3D Modeling +Topic :: Multimedia :: Graphics :: 3D Rendering +Topic :: Software Development :: Libraries :: Python Modules +""" + +__dir_name__ = os.path.dirname(__file__) +pivy_dir = os.path.join(__dir_name__, "pivy") +sys.path.append(pivy_dir) +import pivy_meta +PIVY_VERSION = pivy_meta.__version__ +sys.path.pop(-1) + +class pivy_build(build): + PIVY_SNAKES = r""" + _____ + .-'` '. + __/ __ \ + / \ / \ | ___ + | /`\| /`\| | .-' /^\/^\ + | \(/| \(/| |/ |) |)| + .-\__/ \__/ | \_/\_/__..._ + _...---'-. / _ '. + /, , \ '| `\ \ + | )) )) /`| \ `. /) /) | + | ` ` .' | `-._ / + \ .' | ,_ `--....-' + `. __.' , | / /`'''` + `'-.____.-' / /, | / / + `. `-.-` .' \ / / | + `-.__.'| \ | | |-. + _.._| | / | | `'. + .-''`` | | | / | `-. + .'` / / / | | '. + /` / / | / |\ \ + / | | | | /\ | + || | / | / '. | + |\ \ | / | '. / + \ `. '. / | \ '---'/ + \ '. `-./ \ '. / + '. `'. `-._ '.__ '-._____.'--'''''--. + '-. `'--._ `.__ `';----` \ + `-. `-. `.''``` ; + `'-..,_ `-. `'-. / + '. '. '. .' + + + ~~~ HISSSSSSSSSS ~~~ + Welcome to Pivy %s! + Building Pivy has never been so much fun! + + """ % PIVY_VERSION + + pivy_header_include = """\ +#ifdef __PIVY__ +%%include %s +#endif + +""" + + SWIG = ((sys.platform == "win32" and "swig.exe") or "swig") + + SWIG_SUPPRESS_WARNINGS = "-w302,306,307,312,314,325,361,362,467,389,503,509,510" + #SWIG_PARAMS = "-c++ -python -includeall -modern -D__PIVY__ " + \ + # "-I. -Ifake_headers -I\"%s\" %s -o %s_wrap.cpp " + \ + # "interfaces" + os.sep + "%s.i" + ##### Added an extra set of flags for swig here: + SWIG_PARAMS = "-c++ -python -includeall -modern -D__PIVY__ " + \ + "-I/usr/local/include/boost/compatibility/cpp_c_headers " + \ + "-I. -Ifake_headers -I\"%s\" %s -o %s_wrap.cpp " + \ + "interfaces" + os.sep + "%s.i" + ################################################ + if sys.version_info.major >= 3: + SWIG_PARAMS = '-py3 ' + SWIG_PARAMS + + + # TODO: add command line arguments to tell distutils which library should be build + SOGUI = ['soqt'] # stop supporting soxt, sogtk, and sowin to simplify the setup + coin_interface = 'coin' + soqt_interface = 'soqt' + + if sys.version_info.major < 3: + coin_interface = 'coin2' + soqt_interface = 'soqt2' + + MODULES = { + 'coin': ['_coin', 'COIN', 'pivy.', coin_interface], + 'soqt': ['gui._soqt', 'SOQT', 'pivy.gui.', soqt_interface] + } + + import qtinfo + QTINFO = qtinfo.QtInfo() + + SUPPORTED_SWIG_VERSIONS = ['3.0.8', '3.0.10', '3.0.12'] + SWIG_VERSION = "" + SWIG_COND_SYMBOLS = [] + CXX_INCS = "-Iinterfaces " + CXX_LIBS = "" + + ext_modules = [] + py_modules = ['pivy.quarter.ContextMenu', + 'pivy.quarter.ImageReader', + 'pivy.quarter.QuarterWidget', + 'pivy.quarter.SensorManager', + 'pivy.quarter.SignalThread', + 'pivy.quarter.devices.DeviceHandler', + 'pivy.quarter.devices.DeviceManager', + 'pivy.quarter.devices.KeyboardHandler', + 'pivy.quarter.devices.MouseHandler', + 'pivy.quarter.eventhandlers.DragDropHandler', + 'pivy.quarter.eventhandlers.EventHandler', + 'pivy.quarter.eventhandlers.EventManager', + 'pivy.quarter.plugins.designer.python.PyQuarterWidgetPlugin', + 'pivy.utils', + 'pivy.graphics.colors', + 'pivy.graphics.mesh', + 'pivy.graphics.plot', + 'pivy.graphics.viewer'] + + def check_with_cmake(self): + dirname = os.path.dirname(__file__) + cmake_command = ['cmake', dirname] + try: + cmake_command += ['-G', os.environ['GENERATOR']] + except KeyError: + pass + print(yellow('calling: ' + cmake_command[0] + ' ' + cmake_command[1])) + cmake = subprocess.Popen(cmake_command, stdout=subprocess.PIPE) + cmake_out, _ = cmake.communicate() + coin_vars = ['COIN_FOUND', 'COIN_VERSION', 'COIN_INCLUDE_DIR', 'COIN_LIB_DIR'] + soqt_vars = ['SOQT_FOUND', 'SOQT_VERSION', 'SOQT_INCLUDE_DIR', 'SOQT_LIB_DIR'] + config_dict = {} + if cmake.returncode == 0: + for line in cmake_out.decode("utf-8").split("\n"): + for var in coin_vars + soqt_vars: + if var in line: + line = (line + .replace('-- ' + var, '') + .replace(': ', '') + .replace('\n', '')) + config_dict[var] = line + + # Added overwrite of SOQT_INCLUDE_DIR, because cmake is identifying it incorrectly + config_dict["SOQT_INCLUDE_DIR"] = "/usr/local/include" + ########## + + print(yellow('\nchecking for COIN via cmake')) + for key in coin_vars: + if key in config_dict: + print(blue(key + ': ' + config_dict[key])) + + print(yellow('\nchecking for SOQT via cmake')) + for key in soqt_vars: + if key in config_dict: + print(blue(key + ': ' + config_dict[key])) + + if config_dict['SOQT_FOUND'] == 'false': + pivy_build.MODULES.pop('soqt') + print(red("\ndisable soqt, because cmake couldn't find it")) + + self.cmake_config_dict = config_dict + if not bool(self.cmake_config_dict['COIN_FOUND']): + raise(RuntimeError('coin was not found, but you need coin to build pivy')) + + if not bool(self.cmake_config_dict['SOQT_FOUND']): + raise(RuntimeError('soqt was not found, but you need soqt to build pivy')) + + def do_os_popen(self, cmd): + "return the output of a command in a single line" + fd = os.popen(cmd) + lines = fd.readlines() + for i in range(len(lines)): + lines[i] = lines[i].strip() + lines = " ".join(lines) + fd.close() + return lines + + def check_cmd_exists(self, cmd): + "return the path of the specified command if it exists" + print(blue("Checking for %s..." % cmd)) + for path in os.environ['PATH'].split(os.path.pathsep): + if os.path.exists(os.path.join(path, cmd)): + print(blue("'%s'" % os.path.join(path, cmd))) + return 1 + print(red("not found.")) + return 0 + + def check_python_version(self): + "check the Python version" + print(blue("Python version...%s" % sys.version.split(" ")[0])) + if int(sys.version[0]) < 2: + print(red("Pivy only works with Python versions >= 2.0.")) + sys.exit(1) + + def check_coin_version(self): + ''' + check the Coin version + ''' + print(yellow('\ncheck_coin_version is not supported in this version')) + print(yellow('coin-bindings are build by default')) + print(yellow('checks have been disabled because of missing config files')) + print(yellow('make sure you have installed the coin library + headers!')) + return #TODO + + if sys.platform == "win32": + return + if not self.check_cmd_exists("coin-config"): + sys.exit(1) + print(blue("Coin version...")) + version = self.do_os_popen("coin-config --version") + print(blue("%s" % version)) + # if not version.startswith('3'): + # print(yellow("** Warning: Pivy has only been tested with Coin " + # "versions Coin-dev 3.")) + + def check_simvoleon_version(self): + '''return if SIMVoleon is available and check the version''' + print(yellow('\ncheck_simvoleon_version is not supported in this version')) + return #TODO + + if sys.platform == "win32" or not self.check_cmd_exists("simvoleon-config"): + self.MODULES.pop('simvoleon', None) + return False + + print(blue("SIMVoleon version...")) + version = self.do_os_popen("simvoleon-config --version") + print(blue("%s" % version)) + if not version.startswith('2.0'): + print(yellow("** Warning: Pivy has only been tested with SIMVoleon " + "versions 2.0.x.")) + return True + + def check_gui_bindings(self): + '''check for availability of SoGui bindings and removes the not available ones''' + + print(yellow('\ncheck_gui_bindings is not supported in this version')) + print(yellow('soqt is build by default')) + print(yellow('make sure you have installed the soqt library + headers\n')) + return #TODO + + if sys.platform == "_win32": + self.MODULES.pop('soxt', None) + self.MODULES.pop('sogtk', None) + print(blue("Checking for SoWin...")) + if not os.path.exists(os.path.join(os.getenv("COINDIR"), "include", "Inventor", "Win", "SoWin.h")): + self.MODULES.pop('sowin', None) + print(red("COINDIR\\include\\Inventor\\Win\\SoWin.h not found. (SoWin bindings won't be built)")) + print(blue("Checking for QTDIR environment variable...")) + if os.getenv("QTDIR"): + print(blue(os.getenv("QTDIR"))) + else: + self.MODULES.pop('soqt', None) + print(red("not set. (SoQt bindings won't be built)")) + else: + for gui in self.SOGUI: + if gui not in self.MODULES: + continue + gui_config_cmd = self.MODULES[gui][1] + if not self.check_cmd_exists(gui_config_cmd): + self.MODULES.pop(gui, None) + else: + print(blue("Checking for %s version..." % gui)) + version = self.do_os_popen("%s --version" % gui_config_cmd) + print(blue("%s" % version)) + + def get_coin_features(self): + ''' + set the global variable SWIG_COND_SYMBOLS needed for conditional wrapping + ''' + print(yellow('\ncoin-features are not supported in this version')) + return #TODO + + if sys.platform == "win32": + return + print(blue("Checking for Coin features...")) + if not os.system("coin-config --have-feature 3ds_import"): + self.SWIG_COND_SYMBOLS.append("-DHAVE_FEATURE_3DS_IMPORT") + print(green("3ds import ")) + + if not os.system("coin-config --have-feature vrml97"): + self.SWIG_COND_SYMBOLS.append("-DHAVE_FEATURE_VRML97") + print(green("vrml97 ")) + + if not os.system("coin-config --have-feature sound"): + self.SWIG_COND_SYMBOLS.append("-DHAVE_FEATURE_SOUND") + print(green("sound ")) + + if not os.system("coin-config --have-feature superglu"): + self.SWIG_COND_SYMBOLS.append("-DHAVE_FEATURE_SUPERGLUE") + print(green("superglu ")) + + if not os.system("coin-config --have-feature threads"): + self.SWIG_COND_SYMBOLS.append("-DHAVE_FEATURE_THREADS") + print(green("threads ")) + + if not os.system("coin-config --have-feature threadsafe"): + self.SWIG_COND_SYMBOLS.append("-DHAVE_FEATURE_THREADSAFE") + print(green("threadsafe ")) + + print() + + def check_swig_version(self, swig): + "check for the swig version" + global SWIG_VERSION + if not self.check_cmd_exists(swig): + # on some systems there is only a swig3.0 so check for this and + # set SWIG to "swig3.0" + swig = "swig3.0" + if not self.check_cmd_exists(swig): + sys.exit(1) + else: + self.SWIG = swig + print(blue("Checking for SWIG version...")) + p = subprocess.Popen("%s -version" % swig, + shell=True, stdout=subprocess.PIPE) + version = str(p.stdout.readlines()[1].strip()).split(" ")[2] + if version[-1] == "'": + version = version[:-1] + p.stdout.close() + print(blue("%s" % version)) + SWIG_VERSION = version + if version not in self.SUPPORTED_SWIG_VERSIONS: + print(yellow("Warning: Pivy has only been tested with the following " + + "SWIG versions: %s." % " ".join(self.SUPPORTED_SWIG_VERSIONS))) + + def copy_and_swigify_headers(self, includedir, dirname, files): + """Copy the header files to the local include directories. Add an + #include line at the beginning for the SWIG interface files...""" + for file in files: + if not os.path.isfile(os.path.join(dirname, file)): + continue + + if file[-2:] == ".i": + file_i = os.path.join(dirname, file) + file_h = os.path.join(dirname, file)[:-2] + ".h" + + if (not os.path.exists(file_h) and os.path.exists(os.path.join(includedir, file_h))): + shutil.copyfile(os.path.join(includedir, file_h), file_h) + sys.stdout.write(' ' + turquoise(file_h)) + fd = open(file_h, 'r+') + contents = fd.readlines() + + ins_line_nr = -1 + for line in contents: + ins_line_nr += 1 + if line.find("#include ") != -1: + break + + if ins_line_nr != -1: + contents.insert(ins_line_nr, self.pivy_header_include % (file_i)) + fd.seek(0) + fd.writelines(contents) + else: + print(blue("[") + red("failed") + blue("]")) + sys.exit(1) + fd.close + # fixes for SWIG 1.3.21 and upwards + # (mostly workarounding swig's preprocessor "function like macros" + # preprocessor bug when no parameters are provided which then results + # in no constructors being created in the wrapper) + elif file[-4:] == ".fix": + sys.stdout.write(' ' + red(os.path.join(dirname, file)[:-4])) + shutil.copyfile(os.path.join(dirname, file), + os.path.join(dirname, file)[:-4]) + # had to introduce this because windows is a piece of crap + elif sys.platform == "win32" and file[-6:] == ".win32": + sys.stdout.write(' ' + red(os.path.join(dirname, file)[:-6])) + shutil.copyfile(os.path.join(dirname, file), + os.path.join(dirname, file)[:-6]) + + def pivy_configure(self): + ''' + configure pivy + ''' + print(turquoise(self.PIVY_SNAKES)) + print(blue("Platform...%s" % sys.platform)) + self.check_python_version() + self.check_swig_version(self.SWIG) + # self.check_coin_version() + + self.check_with_cmake() + + # TODO: find a way to enable coin-features + self.get_coin_features() + # if self.SOGUI: + # self.check_gui_bindings() + + if 'simvoleon' in self.MODULES and self.check_simvoleon_version(): + if sys.platform == "win32": + INCLUDE_DIR = os.getenv("SIMVOLEONDIR") + "\\include" + else: + INCLUDE_DIR = self.do_os_popen("simvoleon-config --includedir") + + sys.stdout.write(blue("Preparing") + green(" VolumeViz ") + blue("headers:")) + dir_gen = os.walk("VolumeViz", INCLUDE_DIR) + for _dir, _, names in dir_gen: + self.copy_and_swigify_headers(INCLUDE_DIR, _dir, names) + print(green(".")) + + # if sys.platform == "win32": + # INCLUDE_DIR = os.path.join(os.getenv("COINDIR"), "include") + # else: + # INCLUDE_DIR = sysconfig.get_config_var("INCLUDEDIR") + + # TODO: Check on win + INCLUDE_DIR = self.cmake_config_dict['COIN_INCLUDE_DIR'] + + # sys.stdout.write(blue("Preparing") + green(" Inventor ") + blue("headers:")) + dir_gen = os.walk("Inventor", INCLUDE_DIR) + for _dir, _, names in dir_gen: + self.copy_and_swigify_headers(INCLUDE_DIR, _dir, names) + print(green(".")) + + def swig_generate(self): + "build all available modules" + + def quote(s): return '"' + s + '"' + + def win_quote(s): + if sys.platform == 'win32': + return '"' + s + '"' + return s + + for module in self.MODULES: + module_name = self.MODULES[module][0] + config_cmd = self.MODULES[module][1] + module_pkg_name = self.MODULES[module][2] + mod_hack_name = self.MODULES[module][3] + mod_out_prefix = module_pkg_name.replace('.', os.sep) + module + + if sys.platform == "_win32": + INCLUDE_DIR = os.path.join(os.getenv("COINDIR"), "include") + CPP_FLAGS = "-I" + quote(INCLUDE_DIR) + " " + \ + "-I" + quote(os.path.join(os.getenv("COINDIR"), "include", "Inventor", "annex")) + \ + " /DCOIN_DLL /wd4244 /wd4049" + # aquire highest non-debug Coin library version + try: + LDFLAGS_LIBS = quote( + max(glob.glob(os.path.join(os.getenv("COINDIR"), "lib", "coin?.lib")))) + " " + # with cmake the coin library is named Coin4.lib + except ValueError: + LDFLAGS_LIBS = quote( + max(glob.glob(os.path.join(os.getenv("COINDIR"), "lib", "Coin?.lib")))) + " " + + if module == "sowin": + CPP_FLAGS += " /DSOWIN_DLL" + LDFLAGS_LIBS += quote(os.path.join(os.getenv("COINDIR"), "lib", "sowin1.lib")) + elif module == "soqt": + CPP_FLAGS += " -I" + '"' + os.getenv("QTDIR") + "\\include\" /DSOQT_DLL" + if os.path.isdir(os.getenv("QTDIR") + "\\include\Qt\""): + CPP_FLAGS += " -I" + '"' + os.getenv("QTDIR") + "\\include\Qt\"" + LDFLAGS_LIBS += os.path.join(os.getenv("COINDIR"), "lib", "soqt1.lib") + " " + else: + # workaround for conda qt4: + CPP_FLAGS += " -I" + '"' + os.getenv("QTDIR") + "\\include\qt\Qt\"" + CPP_FLAGS += " -I" + '"' + os.getenv("QTDIR") + "\\include\qt\"" + LDFLAGS_LIBS += os.path.join(os.getenv("COINDIR"), "lib", "SoQt.lib") + " " + else: + INCLUDE_DIR = self.cmake_config_dict[config_cmd + '_INCLUDE_DIR'] + LIB_DIR = self.cmake_config_dict[config_cmd + '_LIB_DIR'] + CPP_FLAGS = ' -I' + win_quote(INCLUDE_DIR) + CPP_FLAGS += ' -I' + win_quote(os.path.join(INCLUDE_DIR, 'Inventor', 'annex')) + if sys.platform == 'win32': + CPP_FLAGS += " /DCOIN_DLL /wd4244 /wd4049" + LDFLAGS_LIBS = quote(max(glob.glob(os.path.join(LIB_DIR, "Coin?.lib")))) + " " + else: + CPP_FLAGS += " -Wno-unused -Wno-maybe-uninitialized" + LDFLAGS_LIBS = ' -L' + self.cmake_config_dict[config_cmd + '_LIB_DIR'] + + if module == "soqt": + CPP_FLAGS += ' -I' + win_quote(self.QTINFO.getHeadersPath()) + CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtCore')) + CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtGui')) + CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtOpenGL')) + CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtWidgets')) + if sys.platform == 'win32': + LDFLAGS_LIBS += " " + quote(max(glob.glob(os.path.join(LIB_DIR, "SoQt?.lib")))) + " " + CPP_FLAGS += " /DSOQT_DLL" + else: + LDFLAGS_LIBS += ' -lSoQt' + + if module == "coin": + if sys.platform == 'win32': + pass + else: + LDFLAGS_LIBS += ' -lCoin' + + if not os.path.isfile(mod_out_prefix + "_wrap.cpp"): + print(red("\n=== Generating %s_wrap.cpp for %s ===\n" % + (mod_out_prefix, module))) + print(blue(self.SWIG + " " + self.SWIG_SUPPRESS_WARNINGS + " " + self.SWIG_PARAMS % + (INCLUDE_DIR, + self.CXX_INCS, + mod_out_prefix, module))) + if os.system(self.SWIG + " " + self.SWIG_SUPPRESS_WARNINGS + " " + self.SWIG_PARAMS % + (INCLUDE_DIR, + self.CXX_INCS, + mod_out_prefix, mod_hack_name)): + print(red("SWIG did not generate wrappers successfully! ** Aborting **")) + sys.exit(1) + else: + print(red("=== %s_wrap.cpp for %s already exists! ===" % + (mod_out_prefix, module_pkg_name + module))) + + self.ext_modules.append(Extension(module_name, [mod_out_prefix + "_wrap.cpp"], + extra_compile_args=( + self.CXX_INCS + CPP_FLAGS).split(), + extra_link_args=(self.CXX_LIBS + LDFLAGS_LIBS).split())) + + def run(self): + "the entry point for the distutils build class" + # if sys.platform == "win32" and not os.getenv("COINDIR"): + # print("Please set the COINDIR environment variable to your Coin root directory! ** Aborting **") + # sys.exit(1) + + self.pivy_configure() + self.swig_generate() + + for cmd_name in self.get_sub_commands(): + self.run_command(cmd_name) + + +class pivy_clean(clean): + pivy_path = 'pivy' + os.sep + gui_path = 'pivy' + os.sep + 'gui' + os.sep + REMOVE_FILES = (pivy_path + '__init__.pyc', gui_path + '__init__.pyc', + pivy_path + 'coin_wrap.cpp', pivy_path + 'coin2_wrap.cpp', pivy_path + 'coin.py', pivy_path + 'coin.pyc', + pivy_path + 'simvoleon_wrap.cpp', pivy_path + 'simvoleon.py', pivy_path + 'simvoleon.pyc', + gui_path + 'soqt_wrap.cpp', gui_path + 'soqt.py', gui_path + 'soqt.pyc', + gui_path + 'sogtk_wrap.cpp', gui_path + 'sogtk.py', gui_path + 'sogtk.py', + gui_path + 'soxt_wrap.cpp', gui_path + 'soxt.py', gui_path + 'soxt.pyc', + gui_path + 'sowin_wrap.cpp', gui_path + 'sowin.py', gui_path + 'sowin.pyc', + pivy_path + 'sogui.pyc') + + def remove_headers(self, arg, dirname, files): + "remove the coin headers from the pivy Inventor directory" + for file in files: + if not os.path.isfile(os.path.join(dirname, file)) or file[-2:] != ".h": + continue + sys.stdout.write(' ' + turquoise(os.path.join(dirname, file))) + os.remove(os.path.join(dirname, file)) + + def run(self): + "the entry point for the distutils clean class" + sys.stdout.write(blue("Cleaning headers:")) + dir_gen = os.walk("Inventor") + for _dir, _, names in dir_gen: + self.remove_headers(None, _dir, names) + + dir_gen = os.walk("VolumeViz") + for _dir, _, names in dir_gen: + self.remove_headers(None, _dir, names) + + self.remove_cmake() + + # remove the SWIG generated wrappers + for wrapper_file in self.REMOVE_FILES: + if os.path.isfile(wrapper_file): + sys.stdout.write(' ' + turquoise(wrapper_file)) + os.remove(wrapper_file) + print(green(".")) + + clean.run(self) + + def remove_cmake(self): + if os.path.isdir('CMakeFiles'): + shutil.rmtree('CMakeFiles') + if os.path.isfile('CMakeCache.txt'): + os.remove('CMakeCache.txt') + + + +for i in reversed(list(range(len(sys.argv)))): + if sys.argv[i][:10] == "--without-": + pivy_build.MODULES.pop(sys.argv[i][10:], None) + del sys.argv[i] + +setup(name="Pivy", + version=PIVY_VERSION, + description="A Python binding for Coin", + long_description=__doc__, + author="Tamer Fahmy", + author_email="tamer@sim.no", + download_url="http://pivy.coin3d.org/download/", + url="http://pivy.coin3d.org/", + cmdclass={'build': pivy_build, + 'clean': pivy_clean}, + ext_package='pivy', + ext_modules=pivy_build.ext_modules, + py_modules=pivy_build.py_modules, + packages=['pivy', 'pivy.gui'], + classifiers=[_f for _f in PIVY_CLASSIFIERS.split("\n") if _f], + license="BSD License", + platforms=['Any'] + ) diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7daf582 --- /dev/null +++ b/readme.md @@ -0,0 +1,89 @@ +This is a docker container intended to act as a build and run environment for +FreeCAD. + +The directories containing FreeCAD's source code and build are not included +inside the docker image. Instead, they are attached to the docker container +when you run the container. This allows the built code to have continuity +across different docker containers, reducing the time for a build to occur, and +allowing you to use your own editor/IDE outside of the container. + +# Image use + +## Pull image + +``` +docker pull registry.gitlab.com/daviddaish/freecad_docker_env:latest +``` + +## Run image + +Allow xhost access, so you can use the GUI. Note that this method is easy, [but +insecure](https://wiki.ros.org/docker/Tutorials/GUI). + +``` +xhost + +``` + +Using enviroment variables, specify: + +- The root directory of the FreeCAD source; +- Where to build FreeCAD; +- A directory containing any other files you'd like to use, such as + `.fcstd` files, for testing. + +``` +fc_source=~/code/freecad_source +fc_build=~/code/freecad_build +other_files=~/ +``` + +Run the docker image. + +``` +docker run -it --rm \ +-v $fc_source:/mnt/source \ +-v $fc_build:/mnt/build \ +-v $other_files:/mnt/files \ +-e "DISPLAY" -e "QT_X11_NO_MITSHM=1" -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ +registry.gitlab.com/daviddaish/freecad_docker_env:latest +``` + +You will be able to find the mounted directories within the container in the +`/mnt` directory, named `/mnt/source`, `/mnt/build`, and `/mnt/files`. + +## Build FreeCAD + +``` +/root/build_script.sh +``` + +## Run FreeCAD + +``` +/mnt/build/bin/FreeCAD +``` + +# Developing the image + +## Build docker image + +Building the docker image will take several hours. + +``` +docker build -t registry.gitlab.com/daviddaish/freecad_docker_env:latest . +``` + +Note that, because of the size of the dependancies, docker may throw a `no +space left on device` error part way through the build. To reduce the +likelyhood of this, ensure you have around 25GB of space on your storage, and +running `docker system prune`. + +## Pushing the docker image + +Prior to pushing, the image must be able to reliabily build the most recent +tags of the FreeCAD source code: `master`, `0.19_pre`, and `0.18.4`. + +``` +docker login registry.gitlab.com +docker push registry.gitlab.com/daviddaish/freecad_docker_env:updates +``` From 57cbf9957dd6684c98d31a83396ce57a8fb71094 Mon Sep 17 00:00:00 2001 From: David Daish Date: Thu, 26 Mar 2020 10:43:15 +1300 Subject: [PATCH 2/2] Added opencamlib --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7433af1..a00033c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -374,6 +374,14 @@ RUN wget https://salsa.debian.org/science-team/med-fichier/-/archive/debian/4.0. make -j $(nproc --ignore=2) && make -j $(nproc --ignore=2) install && \ rm -rfv /tmp/* +# OpenCamLib v29/12/2019(Commit:983a4168fb0a8e84154c45c6f0a286dc2e752b9a) +RUN git clone -n https://github.com/aewallin/opencamlib.git && \ + mkdir /tmp/opencamlib/build && cd /tmp/opencamlib/build && \ + git checkout 983a4168fb0a8e84154c45c6f0a286dc2e752b9a && \ + cmake -D BUILD_PY_LIB=ON -D BUILD_CXX_LIB=OFF -D USE_PY_3=ON ../src && \ + make -j $(nproc --ignore=2) && \ + make -j $(nproc --ignore=2) install + # Add the build script ADD add_files/freecad_build_script.sh /root/build_script.sh