From f5ee358e880436d6bd9e356ea4237fe4e64db995 Mon Sep 17 00:00:00 2001 From: Julien Wintz Date: Sat, 9 Nov 2019 23:19:01 +0100 Subject: [PATCH 1/9] Packaging cont'd. --- CMakeLists.txt | 19 ++++++++++++------- src/cpp/CMakeLists.txt | 2 +- src/wrapper/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c12ab5..24869a3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,25 +15,30 @@ if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() + +## ################################################################### +## Dependencies - Python +## ################################################################### + +find_package (Python3 COMPONENTS Interpreter Development) + +include_directories(${Python3_INCLUDE_DIRS}) + # --- Libraries find_package(Threads REQUIRED) -find_package(Python REQUIRED) find_package(Qt5Core CONFIG REQUIRED) find_package(Qt5Concurrent CONFIG REQUIRED) find_package(PlantGL REQUIRED) -# Boost -if (DEFINED CONDA_ENV) - set(BOOST_ROOT ${CONDA_ENV}) - set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib") -endif() +set(BOOST_ROOT $ENV{CONDA_PREFIX}) +set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib") set(Boost_NO_SYSTEM_PATHS ON) set(Boost_USE_MULTITHREAD ON) set(Boost_USE_STATIC_LIBS OFF) -find_package(Boost COMPONENTS system ${BOOST_PYTHON_LIB} REQUIRED) +find_package(Boost COMPONENTS system python37 REQUIRED) # --- Include Directories diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 33df4962..2f7f38c1 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(lpy Python3::Python) # Disable Boost Auto-Link target_compile_definitions(lpy PRIVATE BOOST_ALL_NO_LIB) -target_link_libraries(lpy Boost::${BOOST_PYTHON_LIB}) +target_link_libraries(lpy Boost::python37) # --- Preprocessor diff --git a/src/wrapper/CMakeLists.txt b/src/wrapper/CMakeLists.txt index 54b98d0a..e0aeab06 100644 --- a/src/wrapper/CMakeLists.txt +++ b/src/wrapper/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(__lpy_kernel__ Python3::Python) # Disable Boost Auto-Link target_compile_definitions(__lpy_kernel__ PRIVATE BOOST_ALL_NO_LIB) -target_link_libraries(__lpy_kernel__ Boost::system Boost::${BOOST_PYTHON_LIB}) +target_link_libraries(__lpy_kernel__ Boost::system Boost::python37) # --- Dependencies From f5a17be9d82cef8e8b14a68eb5cbc9f5d9163afd Mon Sep 17 00:00:00 2001 From: Julien Wintz Date: Mon, 11 Nov 2019 16:20:01 +0100 Subject: [PATCH 2/9] Almost there. --- CMakeLists.txt | 16 +++ conda/build.sh | 6 +- conda/meta.yaml | 151 +++++++++++++++++----------- setup.py | 10 +- src/openalea/lpy/__init__.py | 2 +- src/openalea/lpy/gui/compile_ui.py | 5 +- src/openalea/lpy/gui/generate_ui.py | 3 +- 7 files changed, 124 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24869a3c..3b22212f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,22 @@ cmake_minimum_required(VERSION 3.12) project(lpy_project CXX) +# --- Build setup + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif("${isSystemDir}" STREQUAL "-1") + # --- CMake Modules set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/conda/build.sh b/conda/build.sh index c5c9546b..e3c8a314 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -1,14 +1,14 @@ #!/bin/bash -# Working Dir +if [[ -d build ]]; then + rm -rf build +fi mkdir build cd build -# Build cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_BUILD_TYPE=Release .. make -j${CPU_COUNT} make install -# Install Python Files cd .. $PYTHON setup.py install --prefix=${PREFIX} diff --git a/conda/meta.yaml b/conda/meta.yaml index c079874d..1f630b70 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,58 +1,93 @@ -# do not edit the following line. It will be updated automatically -{% set version = "2.7.2" %} - -package: - name: openalea.lpy - version: {{ version }} - -source: - path: .. - -about: - home: https://github.com/openalea/lpy - license: Cecill-C - summary: L-Py is a simulation software that mixes L-systems construction with the Python high-level modeling language. - -build: - preserve_egg_dir: True - number: 1 - features: - - vc9 [win and py27] - - vc14 [win and py37] - track_features: - - vc9 [win and py27] - - vc14 [win and py37] - -requirements: - build: - - python - - openalea.plantgl - - boost - - qt =5 - - pyqt - - openalea.deploy - - setuptools - run: - - python - - openalea.plantgl - - boost - - qt =5 - - pyqt - - ipython - - qtconsole - - pyopengl - - pyqglviewer - - vs2008_runtime [win and py27] - - vs2015_runtime [win and py37] - -test: - requires: - - nose - imports: - - openalea.lpy - source_files: - - test/ - - share/ - commands: - - nosetests -v -I test_predecessor_at_scale.py -I test_ui.py [unix] - - nosetests -v -I test_predecessor_at_scale.py -I test_ui.py -I test_axialtree.py -I test_successor_at_scale.py [win] +{% set version = "2.7.2" %} + +package: + name: openalea.lpy + version: {{ version }} + +source: + path: .. + +about: + home: https://github.com/openalea/lpy + license: Cecill-C + summary: L-Py is a simulation software that mixes L-systems construction with the Python high-level modeling language. + +build: + preserve_egg_dir: True + number: 1 + features: + - vc9 [win and py27] + - vc14 [win and py37] + track_features: + - vc9 [win and py27] + - vc14 [win and py37] + +requirements: + build: + - cmake >=3.2.0 + - binutils_impl_linux-64<2.31.0 # [linux] + - {{ compiler('cxx') }} + - {{ cdt('xorg-x11-proto-devel') }} # [linux] + - {{ cdt('mesa-libgl-devel') }} # [linux] + - {{ cdt('mesa-libegl-devel') }} # [linux] + - {{ cdt('mesa-dri-drivers') }} # [linux] + - {{ cdt('libx11-devel') }} # [linux] + - {{ cdt('libXt-devel') }} # [linux] + - {{ cdt('libICE-devel') }} # [linux] + - {{ cdt('libuuid-devel') }} # [linux] + - {{ cdt('libSM-devel') }} # [linux] + - {{ cdt('libxext-devel') }} # [linux] + - {{ cdt('libxcb') }} # [linux] + - {{ cdt('libxrender-devel') }} # [linux] + - {{ cdt('libxau-devel') }} # [linux] + - {{ cdt('libdrm-devel') }} # [linux] + - {{ cdt('libxcomposite-devel') }} # [linux] + - {{ cdt('libxcursor-devel') }} # [linux] + - {{ cdt('libxi-devel') }} # [linux] + - {{ cdt('libxrandr-devel') }} # [linux] + - {{ cdt('pciutils-devel') }} # [linux] + - {{ cdt('libxscrnsaver-devel') }} # [linux] + - {{ cdt('libxtst-devel') }} # [linux] + - {{ cdt('libselinux-devel') }} # [linux] + - {{ cdt('libxdamage') }} # [linux] + - {{ cdt('libxdamage-devel') }} # [linux] + - {{ cdt('libxfixes') }} # [linux] + - {{ cdt('libxfixes-devel') }} # [linux] + - {{ cdt('libxxf86vm') }} # [linux] + - python=3.7 + - qt >=5.9.0 + - boost-cpp + - py-boost + - setuptools +# - openalea.deploy + - cmake >=3.12.0 + - openalea.plantgl + - pyqt + host: + - openalea.plantgl + - boost-cpp + - python=3.7 + - py-boost + run: + - python=3.7 + - openalea.plantgl + - boost-cpp + - qt >=5.9.0 + - pyqt + - ipython +# - qtconsole + - pyopengl +# - pyqglviewer + - vs2008_runtime [win and py27] + - vs2015_runtime [win and py37] +# test: +# requires: +# - nose +# imports: +# - openalea.lpy +# source_files: +# - test/ +# - share/ +# commands: +# - nosetests -v -I test_predecessor_at_scale.py -I test_ui.py [unix] +# - nosetests -v -I test_predecessor_at_scale.py -I test_ui.py -I test_axialtree.py -I test_successor_at_scale.py [win] diff --git a/setup.py b/setup.py index 4c5e6af6..31521140 100644 --- a/setup.py +++ b/setup.py @@ -94,12 +94,12 @@ def compile_interface(): "wralea": ["lpy = openalea.lpy_wralea",], 'gui_scripts': ['lpy = openalea.lpy.gui.lpystudio:main',], 'console_scripts': ['cpfg2lpy = openalea.lpy.cpfg_compat.cpfg2lpy:main',], - }, + } # Dependencies - setup_requires = ['openalea.deploy'], - dependency_links = ['http://openalea.gforge.inria.fr/pi'], - install_requires = install_requires, + # setup_requires = ['openalea.deploy'], + # dependency_links = ['http://openalea.gforge.inria.fr/pi'], + # install_requires = install_requires - pylint_packages = ['src/openalea/lpy/gui'] + # pylint_packages = ['src/openalea/lpy/gui'] ) diff --git a/src/openalea/lpy/__init__.py b/src/openalea/lpy/__init__.py index 30aba78e..d40c560d 100644 --- a/src/openalea/lpy/__init__.py +++ b/src/openalea/lpy/__init__.py @@ -1,5 +1,5 @@ from .__version__ import * -from .__lpy_kernel__ import * +# from .__lpy_kernel__ import * from .parameterset import * def __mod_getattr__(self,name): diff --git a/src/openalea/lpy/gui/compile_ui.py b/src/openalea/lpy/gui/compile_ui.py index 9f4b577f..b15c5de2 100644 --- a/src/openalea/lpy/gui/compile_ui.py +++ b/src/openalea/lpy/gui/compile_ui.py @@ -1,5 +1,8 @@ -from openalea.plantgl.gui.qt import qt +print("DEBUG ===== 1") +# from openalea.plantgl.gui.qt import qt +print("DEBUG ===== 2") from openalea.plantgl.gui.qt.uic import compileUi, compile_args +print("DEBUG ===== 3") import os import sys diff --git a/src/openalea/lpy/gui/generate_ui.py b/src/openalea/lpy/gui/generate_ui.py index 167bc1a0..893472e3 100644 --- a/src/openalea/lpy/gui/generate_ui.py +++ b/src/openalea/lpy/gui/generate_ui.py @@ -6,7 +6,8 @@ py2exe_release = False if not py2exe_release: - import openalea.lpy.gui.compile_ui as ui + import compile_ui as ui + print("Generate Ui - imported") import os.path ldir = os.path.dirname(__file__) print("Generate Ui") From 822f049688311deabb95a5c0af074c437bb36967 Mon Sep 17 00:00:00 2001 From: Julien Wintz Date: Mon, 11 Nov 2019 17:46:09 +0100 Subject: [PATCH 3/9] Packaging continued. --- conda/build.sh | 2 ++ conda/meta.yaml | 38 ++++++++++++++++++++++++------------ setup.py | 5 +++++ src/openalea/lpy/__init__.py | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/conda/build.sh b/conda/build.sh index e3c8a314..541e05f5 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -11,4 +11,6 @@ make -j${CPU_COUNT} make install cd .. +sed -i '' '1,1 s/^/#/' $CONDA_PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py +sed -i '' '1,1 s/^/#/' $BUILD_PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py $PYTHON setup.py install --prefix=${PREFIX} diff --git a/conda/meta.yaml b/conda/meta.yaml index 1f630b70..2e958c01 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -21,7 +21,6 @@ build: track_features: - vc9 [win and py27] - vc14 [win and py37] - requirements: build: - cmake >=3.2.0 @@ -68,18 +67,33 @@ requirements: - boost-cpp - python=3.7 - py-boost + - gmp [unix] + # - cgal [unix] + - qhull + - ann + - eigen + - pyqt >=5.6.0 + - pyopengl + - scipy + - matplotlib run: - - python=3.7 - - openalea.plantgl - - boost-cpp - - qt >=5.9.0 - - pyqt - - ipython -# - qtconsole - - pyopengl -# - pyqglviewer - - vs2008_runtime [win and py27] - - vs2015_runtime [win and py37] + - python=3.7 + - openalea.plantgl + - boost-cpp + - qt >=5.9.0 + - gmp [unix] + # - cgal [unix] + - qhull + - ann + - eigen + - pyqt >=5.6.0 + - ipython + # - qtconsole + - py-boost + - pyopengl + # - pyqglviewer + - vs2008_runtime [win and py27] + - vs2015_runtime [win and py37] # test: # requires: # - nose diff --git a/setup.py b/setup.py index 31521140..0fc9d982 100644 --- a/setup.py +++ b/setup.py @@ -51,9 +51,14 @@ def compile_interface(): cwd = os.getcwd() os.chdir(pj('src','openalea','lpy','gui')) + print("HERE - 1") sys.path = ['']+sys.path + print(sys.path) + print("HERE - 2") import generate_ui + print("HERE - 3") os.chdir(cwd) + print("HERE - 4") compile_interface() install_requires = [] diff --git a/src/openalea/lpy/__init__.py b/src/openalea/lpy/__init__.py index d40c560d..30aba78e 100644 --- a/src/openalea/lpy/__init__.py +++ b/src/openalea/lpy/__init__.py @@ -1,5 +1,5 @@ from .__version__ import * -# from .__lpy_kernel__ import * +from .__lpy_kernel__ import * from .parameterset import * def __mod_getattr__(self,name): From de6988aa389a8d27d2f766ff4aa9bda90e49e6b4 Mon Sep 17 00:00:00 2001 From: Julien Wintz Date: Mon, 11 Nov 2019 22:20:35 +0100 Subject: [PATCH 4/9] Packaging continued. --- conda/build.sh | 1 + options_conda_build.py | 12 ------------ src/openalea/lpy/gui/generate_ui.py | 1 + 3 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 options_conda_build.py diff --git a/conda/build.sh b/conda/build.sh index 541e05f5..4c9d456f 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -13,4 +13,5 @@ make install cd .. sed -i '' '1,1 s/^/#/' $CONDA_PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py sed -i '' '1,1 s/^/#/' $BUILD_PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py +sed -i '' '1,1 s/^/#/' $PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py $PYTHON setup.py install --prefix=${PREFIX} diff --git a/options_conda_build.py b/options_conda_build.py deleted file mode 100644 index f9ca0502..00000000 --- a/options_conda_build.py +++ /dev/null @@ -1,12 +0,0 @@ -import os -pj=os.path.join - -PREFIX = os.path.abspath(os.environ.get('PREFIX')) -SRC_DIR = os.environ.get('SRC_DIR') - -vplants_plantgl_include = pj(PREFIX,'include') -vplants_plantgl_lib = pj(PREFIX,'lib') - -if 'CPU_COUNT' in os.environ: - num_jobs = os.environ['CPU_COUNT'] - diff --git a/src/openalea/lpy/gui/generate_ui.py b/src/openalea/lpy/gui/generate_ui.py index 893472e3..54488968 100644 --- a/src/openalea/lpy/gui/generate_ui.py +++ b/src/openalea/lpy/gui/generate_ui.py @@ -7,6 +7,7 @@ if not py2exe_release: import compile_ui as ui +# from . import compile_ui as ui print("Generate Ui - imported") import os.path ldir = os.path.dirname(__file__) From f49b6a9effe9a88269f24508baa478e39010e289 Mon Sep 17 00:00:00 2001 From: Julien Wintz Date: Mon, 11 Nov 2019 23:55:55 +0100 Subject: [PATCH 5/9] Packaging continued. --- conda/meta.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conda/meta.yaml b/conda/meta.yaml index 2e958c01..c4506f50 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -62,6 +62,7 @@ requirements: - cmake >=3.12.0 - openalea.plantgl - pyqt + - qtconsole host: - openalea.plantgl - boost-cpp @@ -92,6 +93,7 @@ requirements: - py-boost - pyopengl # - pyqglviewer + - qtconsole - vs2008_runtime [win and py27] - vs2015_runtime [win and py37] # test: From 4fce73de4086e5edd87791c7975476d3051d40f9 Mon Sep 17 00:00:00 2001 From: Frederic Boudon Date: Fri, 24 Jan 2020 15:59:40 +0100 Subject: [PATCH 6/9] fix conda build on mac --- CMakeLists.txt | 37 +++++++----- build.sh | 1 + cmake/Anaconda.cmake | 57 +++++++++++++++++- cmake/CXX14.cmake | 6 +- cmake/pywrapper.cmake | 35 +++++++++++ conda/build.sh | 65 +++++++++++++++++++-- conda/meta.yaml | 94 +++++++----------------------- setup.py | 63 +++++++++----------- src/cpp/CMakeLists.txt | 6 +- src/openalea/__init__.py | 18 +----- src/openalea/lpy/gui/compile_ui.py | 6 +- src/openalea/lpy_d/__init__.py | 1 - src/wrapper/CMakeLists.txt | 15 +---- 13 files changed, 234 insertions(+), 170 deletions(-) create mode 100755 build.sh create mode 100644 cmake/pywrapper.cmake delete mode 100644 src/openalea/lpy_d/__init__.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b22212f..913e3c1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,16 @@ -# --- L-Py Project +# --- CMake Modules cmake_minimum_required(VERSION 3.12) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include("Anaconda") +include("pywrapper") + +# --- L-Py Project + project(lpy_project CXX) # --- Build setup -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") @@ -19,11 +22,14 @@ if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif("${isSystemDir}" STREQUAL "-1") -# --- CMake Modules -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include("Anaconda") +# --- CXX11 Compilation + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") # --- (Win32) Multithreaded Compilation @@ -33,11 +39,12 @@ endif() ## ################################################################### -## Dependencies - Python +## Dependencies ## ################################################################### -find_package (Python3 COMPONENTS Interpreter Development) +# --- Python +find_package (Python3 COMPONENTS Interpreter Development) include_directories(${Python3_INCLUDE_DIRS}) # --- Libraries @@ -47,14 +54,16 @@ find_package(Qt5Core CONFIG REQUIRED) find_package(Qt5Concurrent CONFIG REQUIRED) find_package(PlantGL REQUIRED) -set(BOOST_ROOT $ENV{CONDA_PREFIX}) -set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib") +if (USE_CONDA) + set(BOOST_ROOT ${CONDA_ENV}) +endif() set(Boost_NO_SYSTEM_PATHS ON) set(Boost_USE_MULTITHREAD ON) set(Boost_USE_STATIC_LIBS OFF) +set(BUILD_SHARED_LIBS ON) -find_package(Boost COMPONENTS system python37 REQUIRED) +find_package(Boost COMPONENTS system python REQUIRED) # --- Include Directories @@ -64,7 +73,9 @@ include_directories(${Boost_INCLUDE_DIR}) # --- Library Directory -link_directories("${CONDA_ENV}/lib") +if (DEFINED CONDA_ENV) + link_directories("${CONDA_ENV}/lib") +endif() # --- Source Directories diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..727a0bfe --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +conda build . -c conda-forge -c fredboudon -c defaults --python=3.7 diff --git a/cmake/Anaconda.cmake b/cmake/Anaconda.cmake index 8b93c778..f364d36a 100644 --- a/cmake/Anaconda.cmake +++ b/cmake/Anaconda.cmake @@ -1,9 +1,14 @@ # Anaconda Check if (DEFINED ENV{CONDA_PREFIX}) # Anaconda Environment - message(STATUS "Anaconda environment detected.") + message(STATUS "Anaconda environment detected: " $ENV{CONDA_PREFIX}) - file(TO_CMAKE_PATH $ENV{CONDA_PREFIX} TMP_CONDA_ENV) + + if (DEFINED ENV{BUILD_PREFIX}) + file(TO_CMAKE_PATH $ENV{BUILD_PREFIX} TMP_CONDA_ENV) + else() + file(TO_CMAKE_PATH $ENV{CONDA_PREFIX} TMP_CONDA_ENV) + endif() if (WIN32) set(CONDA_ENV "${TMP_CONDA_ENV}/Library/") @@ -12,4 +17,52 @@ if (DEFINED ENV{CONDA_PREFIX}) endif() set(CONDA_PYTHON_ENV "${TMP_CONDA_ENV}/") + + set(USE_CONDA ON) + +else() + message(STATUS "Compilation outside an anaconda environment.") + set(USE_CONDA OFF) +endif() + + +if (DEFINED ENV{CONDA_BUILD}) + message(STATUS "Conda build detected. " $ENV{CONDA_BUILD}) + + # specify the cross compiler + set(CMAKE_C_COMPILER $ENV{CC}) + set(CMAKE_LINKER $ENV{LD}) + set(CMAKE_AR $ENV{AR}) + set(CMAKE_NM $ENV{NM}) + set(CMAKE_RANLIB $ENV{RANLIB}) + set(CMAKE_STRIP $ENV{STRIP}) + set(CMAKE_INSTALL_NAME_TOOL $ENV{INSTALL_NAME_TOOL}) + #CMAKE_MAKE_PROGRAM + #CMAKE_OBJCOPY + #CMAKE_OBJDUMP + + if (APPLE) + set(CMAKE_OSX_ARCHITECTURES $ENV{OSX_ARCH}) + endif() + + set(CMAKE_CXX_COMPILER $ENV{CXX}) + set(CMAKE_CXX_COMPILER_RANLIB $ENV{RANLIB}) + set(CMAKE_CXX_COMPILER_AR $ENV{AR}) + + # where is the target environment + set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot $ENV{CONDA_BUILD_SYSROOT}) + + # search for programs in the build host directories + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + # for libraries and headers in the target directories + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + + set(USE_CONDA_BUILD ON) +else() + set(USE_CONDA_BUILD OFF) endif() + + + diff --git a/cmake/CXX14.cmake b/cmake/CXX14.cmake index 268b9685..4969e6a0 100644 --- a/cmake/CXX14.cmake +++ b/cmake/CXX14.cmake @@ -20,6 +20,6 @@ else() endif() # C++14 Standard -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +#set(CMAKE_CXX_STANDARD 14) +#set(CMAKE_CXX_STANDARD_REQUIRED ON) +#set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/cmake/pywrapper.cmake b/cmake/pywrapper.cmake new file mode 100644 index 00000000..c16742d5 --- /dev/null +++ b/cmake/pywrapper.cmake @@ -0,0 +1,35 @@ + + +function(pgllib_link_python libwrapname) + if(NOT APPLE OR NOT USE_CONDA) + if (Python3_FOUND) + target_link_libraries(${libwrapname} Python3::Python) + elseif (Python2_FOUND) + target_link_libraries(${libwrapname} Python2::Python) + endif() + else() + message(STATUS "Do not link with Python directly : " ${libwrapname}) + endif() + + # Disable Boost Auto-Link + #target_compile_definitions(${libwrapname} PRIVATE BOOST_ALL_NO_LIB) + + #target_link_libraries(${libwrapname} Boost::system Boost::thread Boost::python ) + +endfunction() + + + +function(pglwrapper_install libwrapname) + set_target_properties(${libwrapname} PROPERTIES PREFIX "") + + if (WIN32) + set_target_properties(${libwrapname} PROPERTIES SUFFIX ".pyd") + endif() + + if (APPLE) + set_target_properties(${libwrapname} PROPERTIES SUFFIX ".so") + endif() + + install(TARGETS ${libwrapname} DESTINATION "${CMAKE_SOURCE_DIR}/src/openalea/lpy") +endfunction() diff --git a/conda/build.sh b/conda/build.sh index 4c9d456f..6dfe3a10 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -6,12 +6,65 @@ fi mkdir build cd build -cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_BUILD_TYPE=Release .. -make -j${CPU_COUNT} +if [ `uname` = "Darwin" ]; then + SYSTEM_DEPENDENT_ARGS=( + "-DCMAKE_OSX_SYSROOT=${CONDA_BUILD_SYSROOT}" + ) + export LDFLAGS="-undefined dynamic_lookup ${LDFLAGS}" +else + SYSTEM_DEPENDENT_ARGS=( + "-DOPENGL_opengl_LIBRARY=${BUILD_PREFIX}/${HOST}/sysroot/usr/lib64/libGL.so" + "-DOPENGL_glx_LIBRARY=${BUILD_PREFIX}/${HOST}/sysroot/usr/lib64/libGL.so" + ) +fi + +export SYSTEM_DEPENDENT_ARGS + +echo +echo "****** CMAKE" +which cmake +echo 'CONDA_BUILD_SYSROOT:' $CONDA_BUILD_SYSROOT +echo +echo "****** ENV" +env + +echo +echo "****** CMAKE CONFIG" + +cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} \ + -DCMAKE_PREFIX_PATH=${PREFIX} \ + -DCMAKE_BUILD_TYPE=Release \ + ${SYSTEM_DEPENDENT_ARGS[@]} \ + -LAH .. + +echo +echo "****** LPY CONFIG" +cat $SRC_DIR/src/openalea/lpy/__version__.py + +echo +echo "****** COMPILE" +export VERBOSE=1 +make -j${CPU_COUNT} +echo "****** INSTALL CXX LIB" make install +echo +echo "****** INSTALL PYTHON LIB" cd .. -sed -i '' '1,1 s/^/#/' $CONDA_PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py -sed -i '' '1,1 s/^/#/' $BUILD_PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py -sed -i '' '1,1 s/^/#/' $PREFIX/lib/python3.7/site-packages/openalea/plantgl/gui/__init__.py -$PYTHON setup.py install --prefix=${PREFIX} +echo "PYTHON:" ${PYTHON} + +#echo "** PYTHON CALL" +#export PYTHONPATH=${PREFIX}/lib/python${PY_VER}/site-packages/ +${PYTHON} setup.py install --prefix=${PREFIX} + +echo +echo "****** CHECK PYTHON LIB" +ls -R $PREFIX/lib/python3.7/site-packages/OpenAlea.Lpy-2.7.2-py3.7.egg/ +cat $PREFIX/lib/python3.7/site-packages/OpenAlea.Lpy-2.7.2-py3.7.egg/openalea/__init__.py + +# To check if Python lib is not in the dependencies with conda-forge distribution. +# See https://github.com/conda-forge/boost-feedstock/issues/81 +#if [ `uname` = "Darwin" ]; then +# otool -L `${PYTHON} -c "import openalea.lpy.__lpy_kernel__ as lpy ; print(lpy.__file__)"` +#fi +echo "****** END OF BUILD PROCESS" diff --git a/conda/meta.yaml b/conda/meta.yaml index c4506f50..4a5db68d 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,8 +1,9 @@ -{% set version = "2.7.2" %} +#{% set version = "2.7.2" %} +{% set data = load_setup_py_data() %} package: name: openalea.lpy - version: {{ version }} + version: {{ data.get('version') }} source: path: .. @@ -14,88 +15,37 @@ about: build: preserve_egg_dir: True - number: 1 - features: - - vc9 [win and py27] - - vc14 [win and py37] - track_features: - - vc9 [win and py27] - - vc14 [win and py37] + number: 2 requirements: build: - - cmake >=3.2.0 - binutils_impl_linux-64<2.31.0 # [linux] - {{ compiler('cxx') }} - - {{ cdt('xorg-x11-proto-devel') }} # [linux] - - {{ cdt('mesa-libgl-devel') }} # [linux] - - {{ cdt('mesa-libegl-devel') }} # [linux] - - {{ cdt('mesa-dri-drivers') }} # [linux] - - {{ cdt('libx11-devel') }} # [linux] - - {{ cdt('libXt-devel') }} # [linux] - - {{ cdt('libICE-devel') }} # [linux] - - {{ cdt('libuuid-devel') }} # [linux] - - {{ cdt('libSM-devel') }} # [linux] - - {{ cdt('libxext-devel') }} # [linux] - - {{ cdt('libxcb') }} # [linux] - - {{ cdt('libxrender-devel') }} # [linux] - - {{ cdt('libxau-devel') }} # [linux] - - {{ cdt('libdrm-devel') }} # [linux] - - {{ cdt('libxcomposite-devel') }} # [linux] - - {{ cdt('libxcursor-devel') }} # [linux] - - {{ cdt('libxi-devel') }} # [linux] - - {{ cdt('libxrandr-devel') }} # [linux] - - {{ cdt('pciutils-devel') }} # [linux] - - {{ cdt('libxscrnsaver-devel') }} # [linux] - - {{ cdt('libxtst-devel') }} # [linux] - - {{ cdt('libselinux-devel') }} # [linux] - - {{ cdt('libxdamage') }} # [linux] - - {{ cdt('libxdamage-devel') }} # [linux] - - {{ cdt('libxfixes') }} # [linux] - - {{ cdt('libxfixes-devel') }} # [linux] - - {{ cdt('libxxf86vm') }} # [linux] - - python=3.7 - - qt >=5.9.0 - - boost-cpp - - py-boost - - setuptools -# - openalea.deploy + - python {{PY_VER}} - cmake >=3.12.0 - - openalea.plantgl - - pyqt - - qtconsole + - pkg-config # [linux] + - make # [unix] + - menuinst # [win] host: + - python {{PY_VER}} + - setuptools + # - openalea.deploy - openalea.plantgl - - boost-cpp - - python=3.7 - - py-boost - - gmp [unix] - # - cgal [unix] - - qhull - - ann - - eigen - - pyqt >=5.6.0 - - pyopengl - - scipy - - matplotlib + - boost + - pyqt run: - - python=3.7 + - python {{PY_VER}} + - setuptools + # - openalea.deploy - openalea.plantgl - - boost-cpp - - qt >=5.9.0 - - gmp [unix] - # - cgal [unix] - - qhull - - ann - - eigen - - pyqt >=5.6.0 + - boost + - pyqt - ipython - # - qtconsole - - py-boost - pyopengl - # - pyqglviewer - qtconsole - - vs2008_runtime [win and py27] - - vs2015_runtime [win and py37] + # - pyqglviewer + # - scipy + # - matplotlib + # - openalea.mtg # test: # requires: # - nose diff --git a/setup.py b/setup.py index 0fc9d982..f37fdce9 100644 --- a/setup.py +++ b/setup.py @@ -5,13 +5,6 @@ import os, sys pj = os.path.join -# from openalea.deploy.metainfo import read_metainfo -# metadata = read_metainfo('metainfo.ini', verbose=True) -# for key,value in metadata.items(): -# exec("%s = '%s'" % (key, value)) - -version = '2.7.1' -release = '2.7' project = 'openalea' package = 'lpy' name = 'OpenAlea.Lpy' @@ -19,7 +12,7 @@ pkg_name = 'openalea.lpy' description = 'Lindenmayer Systems in Python package for OpenAlea.' long_description= 'L-Py is a simulation software that mixes L-systems construction with the Python high-level modeling language. ' -authors = 'Frederic Boudon' +authors = 'Frédéric Boudon' authors_email = 'frederic.boudon@cirad.fr' url= 'https://github.com/openalea/lpy' # LGPL compatible INRIA license @@ -31,37 +24,37 @@ # Package name pkg_name= namespace + '.' + package -meta_version = version # check that meta version is updated -f = pj(os.path.dirname(__file__),'src', 'openalea', 'lpy','__version__.py') -d = {} -exec(compile(open(f, "rb").read(), f, 'exec'),d,d) -version= d['LPY_VERSION_STR'] -if meta_version != version: - print ('Warning:: Update the version in metainfo.ini !!') -print (pkg_name+': version ='+version) +lpydir = pj(os.path.dirname(__file__),'src', 'openalea', 'lpy') +versionfile = pj(lpydir,'__version__.py') +versioninfo = {} +with open(versionfile) as fp: + exec(fp.read(), versioninfo) -# Scons build directory -build_prefix = "build-cmake" +version= versioninfo['LPY_VERSION_STR'] +print (pkg_name+': version = '+version) -from setuptools import setup -# from openalea.deploy.binary_deps import binary_deps + +# cmake build directory +build_prefix = "build-cmake" def compile_interface(): cwd = os.getcwd() - os.chdir(pj('src','openalea','lpy','gui')) - print("HERE - 1") + os.chdir(pj(lpydir,'gui')) sys.path = ['']+sys.path - print(sys.path) - print("HERE - 2") import generate_ui - print("HERE - 3") os.chdir(cwd) - print("HERE - 4") -compile_interface() -install_requires = [] + py2exe_file = pj(lpydir,'gui','py2exe_release.py') + if not os.path.exists(py2exe_file): + open(py2exe_file,'w').close() + +if 'install' in sys.argv: + compile_interface() + + +from setuptools import setup setup( name=name, @@ -78,8 +71,8 @@ def compile_interface(): # pure python packages packages = [ + namespace, pkg_name, - pkg_name + '_d', pkg_name + '_wralea', pkg_name + '.gui', pkg_name + '.gui.plugins', @@ -89,9 +82,13 @@ def compile_interface(): # python packages directory package_dir = { '' : 'src',}, + package_data={ + "": ["share/*","share/*/*","share/*/*/*","share/*/*/*/*", '*.pyd', '*.so', '*.dylib', '*.lpy','*.ui','*.qrc'], + }, + # Add package platform libraries if any include_package_data = True, - package_data = {'' : ['*.pyd', '*.so', '*.dylib', '*.lpy','*.ui','*.qrc'],}, + #package_data = {'' : ['*.pyd', '*.so', '*.dylib', '*.lpy','*.ui','*.qrc'],}, zip_safe = False, # Dependencies @@ -101,10 +98,4 @@ def compile_interface(): 'console_scripts': ['cpfg2lpy = openalea.lpy.cpfg_compat.cpfg2lpy:main',], } - # Dependencies - # setup_requires = ['openalea.deploy'], - # dependency_links = ['http://openalea.gforge.inria.fr/pi'], - # install_requires = install_requires - - # pylint_packages = ['src/openalea/lpy/gui'] ) diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 2f7f38c1..5cfb4734 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -8,12 +8,12 @@ add_library(lpy SHARED ${SRC_FILES}) target_link_libraries(lpy ${PLANTGL_LIBRARIES}) target_link_libraries(lpy Qt5::Core Qt5::Concurrent) -target_link_libraries(lpy Python3::Python) +pgllib_link_python(lpy) # Disable Boost Auto-Link target_compile_definitions(lpy PRIVATE BOOST_ALL_NO_LIB) -target_link_libraries(lpy Boost::python37) +target_link_libraries(lpy Boost::python) # --- Preprocessor @@ -28,4 +28,4 @@ install(TARGETS lpy LIBRARY DESTINATION "lib") # --- Install Headers -install(DIRECTORY "." DESTINATION "include" FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") +install(DIRECTORY "." DESTINATION "include/lpy" FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") diff --git a/src/openalea/__init__.py b/src/openalea/__init__.py index 64ac5e45..de40ea7c 100644 --- a/src/openalea/__init__.py +++ b/src/openalea/__init__.py @@ -1,17 +1 @@ -try: - import pkg_resources - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - __path__ = pkgutil.extend_path(__path__, __name__) - - -try: - from __init_path__ import set_path - set_path() -except: - pass - -import modulefinder -for p in __path__: - modulefinder.AddPackagePath(__name__, p) +__import__('pkg_resources').declare_namespace(__name__) diff --git a/src/openalea/lpy/gui/compile_ui.py b/src/openalea/lpy/gui/compile_ui.py index b15c5de2..adc52166 100644 --- a/src/openalea/lpy/gui/compile_ui.py +++ b/src/openalea/lpy/gui/compile_ui.py @@ -1,13 +1,9 @@ -print("DEBUG ===== 1") -# from openalea.plantgl.gui.qt import qt -print("DEBUG ===== 2") +from openalea.plantgl.gui.qt import QT_API, PYQT5_API, PYQT4_API, PYSIDE_API from openalea.plantgl.gui.qt.uic import compileUi, compile_args -print("DEBUG ===== 3") import os import sys -from openalea.plantgl.gui.qt import QT_API, PYQT5_API, PYQT4_API, PYSIDE_API def get_uifnames_from(fname): uiprefix = os.path.splitext(fname)[0] diff --git a/src/openalea/lpy_d/__init__.py b/src/openalea/lpy_d/__init__.py deleted file mode 100644 index 0a7de47b..00000000 --- a/src/openalea/lpy_d/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .__lpy_kernel__ import * \ No newline at end of file diff --git a/src/wrapper/CMakeLists.txt b/src/wrapper/CMakeLists.txt index e0aeab06..5e21f7b9 100644 --- a/src/wrapper/CMakeLists.txt +++ b/src/wrapper/CMakeLists.txt @@ -8,12 +8,12 @@ add_library(__lpy_kernel__ SHARED ${SRC_FILES}) target_link_libraries(__lpy_kernel__ lpy) target_link_libraries(__lpy_kernel__ ${PLANTGL_LIBRARIES}) -target_link_libraries(__lpy_kernel__ Python3::Python) +pgllib_link_python(__lpy_kernel__) # Disable Boost Auto-Link target_compile_definitions(__lpy_kernel__ PRIVATE BOOST_ALL_NO_LIB) -target_link_libraries(__lpy_kernel__ Boost::system Boost::python37) +target_link_libraries(__lpy_kernel__ Boost::system Boost::python) # --- Dependencies @@ -21,14 +21,5 @@ add_dependencies(__lpy_kernel__ lpy) # --- Output Library -set_target_properties(__lpy_kernel__ PROPERTIES PREFIX "") +pglwrapper_install(__lpy_kernel__) -if (WIN32) - set_target_properties(__lpy_kernel__ PROPERTIES SUFFIX ".pyd") -endif() - -if (APPLE) - set_target_properties(__lpy_kernel__ PROPERTIES SUFFIX ".so") -endif() - -install(TARGETS __lpy_kernel__ DESTINATION "${CMAKE_SOURCE_DIR}/src/openalea/lpy") From 9f1627fba3e6ccd607f86f0889f649bfc343e1f1 Mon Sep 17 00:00:00 2001 From: Frederic Boudon Date: Fri, 24 Jan 2020 16:02:13 +0100 Subject: [PATCH 7/9] set version to 3.0 --- src/openalea/lpy/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openalea/lpy/__version__.py b/src/openalea/lpy/__version__.py index fcf0127f..9a455e3c 100644 --- a/src/openalea/lpy/__version__.py +++ b/src/openalea/lpy/__version__.py @@ -1,4 +1,4 @@ -__version_number__ = 0x020702 +__version_number__ = 0x030000 __revision_str__="" From 142e171becc7a844be978156fbf4fb8b8802f3de Mon Sep 17 00:00:00 2001 From: Frederic Boudon Date: Wed, 29 Jan 2020 16:44:49 +0100 Subject: [PATCH 8/9] add channel for CI --- appveyor.yml | 2 ++ conda/build.sh | 11 ++++++----- conda/meta.yaml | 6 ++---- travis.yml | 4 +++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7ad3d65b..4a05c293 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,6 +12,8 @@ install: - git clone https://github.com/OpenAlea/appveyor-ci.git appveyor-ci - cd appveyor-ci - call install.bat + - conda config --prepend channels conda-forge + - conda config --prepend channels fredboudon before_build: - call before_build.bat diff --git a/conda/build.sh b/conda/build.sh index 6dfe3a10..c1988da7 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -59,12 +59,13 @@ ${PYTHON} setup.py install --prefix=${PREFIX} echo echo "****** CHECK PYTHON LIB" -ls -R $PREFIX/lib/python3.7/site-packages/OpenAlea.Lpy-2.7.2-py3.7.egg/ -cat $PREFIX/lib/python3.7/site-packages/OpenAlea.Lpy-2.7.2-py3.7.egg/openalea/__init__.py # To check if Python lib is not in the dependencies with conda-forge distribution. # See https://github.com/conda-forge/boost-feedstock/issues/81 -#if [ `uname` = "Darwin" ]; then -# otool -L `${PYTHON} -c "import openalea.lpy.__lpy_kernel__ as lpy ; print(lpy.__file__)"` -#fi +if [ `uname` = "Darwin" ]; then + alias ldd='otool -L' +fi + +ldd `${PYTHON} -c "import openalea.lpy.__lpy_kernel__ as lpy ; print(lpy.__file__)"` + echo "****** END OF BUILD PROCESS" diff --git a/conda/meta.yaml b/conda/meta.yaml index 4a5db68d..b74fda79 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -15,7 +15,7 @@ about: build: preserve_egg_dir: True - number: 2 + number: 3 requirements: build: - binutils_impl_linux-64<2.31.0 # [linux] @@ -28,21 +28,19 @@ requirements: host: - python {{PY_VER}} - setuptools - # - openalea.deploy - openalea.plantgl - boost - pyqt run: - python {{PY_VER}} - setuptools - # - openalea.deploy - openalea.plantgl - boost - pyqt - ipython - pyopengl - qtconsole - # - pyqglviewer + - pyqglviewer # - scipy # - matplotlib # - openalea.mtg diff --git a/travis.yml b/travis.yml index 4857dc40..88e85d3c 100644 --- a/travis.yml +++ b/travis.yml @@ -11,12 +11,14 @@ services: env: - CONDA_RECIPE=conda - CONDA_VERSION=2 + CONDA_VERSION=3 install: - git clone https://github.com/openalea/travis-ci.git - cd travis-ci - source install.sh + - conda config --prepend channels fredboudon + - conda config --prepend channels conda-forge before_script: - source before_script.sh From 0a8df0ee9c3fe8d55dcf652fcdc24a452b0ed380 Mon Sep 17 00:00:00 2001 From: Frederic Boudon Date: Wed, 29 Jan 2020 18:11:38 +0100 Subject: [PATCH 9/9] fix bug on lib testing on mac --- conda/build.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conda/build.sh b/conda/build.sh index c1988da7..af75983a 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -63,9 +63,11 @@ echo "****** CHECK PYTHON LIB" # To check if Python lib is not in the dependencies with conda-forge distribution. # See https://github.com/conda-forge/boost-feedstock/issues/81 if [ `uname` = "Darwin" ]; then - alias ldd='otool -L' + export LDD='otool -L' +else + export LDD='ldd' fi -ldd `${PYTHON} -c "import openalea.lpy.__lpy_kernel__ as lpy ; print(lpy.__file__)"` +${LDD} `${PYTHON} -c "import openalea.lpy.__lpy_kernel__ as lpy ; print(lpy.__file__)"` echo "****** END OF BUILD PROCESS"