Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# --- CMake Modules

cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.20)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include("Anaconda")
include("pywrapper")
Expand All @@ -11,8 +11,7 @@ project(lpy_project CXX)

# --- Build setup

set(CMAKE_INCLUDE_PATH "$ENV{CONDA_PREFIX}/include" ${CMAKE_INCLUDE_PATH})
set(CMAKE_LIBRARY_PATH "$ENV{CONDA_PREFIX}/lib" ${CMAKE_LIBRARY_PATH})

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
Expand Down Expand Up @@ -56,13 +55,15 @@ endif()

# --- Python

set(Python3_FIND_VIRTUALENV FIRST)
set(Python_FIND_VIRTUALENV FIRST)
if (WIN32)
# needed when we run cmake in a conda environment
set(Python3_FIND_REGISTRY LAST)
set(Python_FIND_REGISTRY LAST)
endif()

find_package (Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
set(Python_ROOT_DIR "$ENV{CONDA_PREFIX}")
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)

include_directories(${Python3_INCLUDE_DIRS})

# --- Libraries
Expand All @@ -72,19 +73,17 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Concurrent)
find_package(PlantGL REQUIRED)

if(POLICY CMP0167) # Removes find boost warning
cmake_policy(SET CMP0167 NEW)
endif()

set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
set(BUILD_SHARED_LIBS ON)


set(boost_python python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
find_package(Boost 1.69 COMPONENTS system ${boost_python} REQUIRED)
if (NOT Boost_FOUND)
message("Boost not found, trying again")
set(boost_python python)
find_package(Boost 1.69 COMPONENTS system ${boost_python} REQUIRED)
endif()

find_package(Boost COMPONENTS system ${boost_python} REQUIRED)

Expand All @@ -105,4 +104,4 @@ endif()
add_subdirectory("src/cpp")
add_subdirectory("src/wrapper")

install_share("share" "lpy")
install_share("share" "lpy")
File renamed without changes.
43 changes: 37 additions & 6 deletions cmake/Anaconda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
if (DEFINED ENV{CONDA_PREFIX})
# Anaconda Environment
message(STATUS "Anaconda environment detected: " $ENV{CONDA_PREFIX})



set(CMAKE_INCLUDE_PATH "$ENV{CONDA_PREFIX}/include" ${CMAKE_INCLUDE_PATH})
set(CMAKE_LIBRARY_PATH "$ENV{CONDA_PREFIX}/lib" ${CMAKE_LIBRARY_PATH})

if (DEFINED ENV{PREFIX})
file(TO_CMAKE_PATH $ENV{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/")
else()
Expand Down Expand Up @@ -45,15 +47,36 @@ if (DEFINED ENV{CONDA_BUILD})
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})
set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX})
if (APPLE)
list(APPEND CMAKE_FIND_ROOT_PATH $ENV{CONDA_BUILD_SYSROOT} )
endif()
if (WIN32)
list(APPEND CMAKE_FIND_ROOT_PATH $ENV{BUILD_PREFIX}/Library/usr $ENV{PREFIX}/Library/usr)
set(CMAKE_INCLUDE_PATH "$ENV{BUILD_PREFIX}/Library/usr/include" ${CMAKE_INCLUDE_PATH})
set(CMAKE_LIBRARY_PATH "$ENV{BUILD_PREFIX}/Library/usr/lib" ${CMAKE_LIBRARY_PATH})
endif()
if (UNIX)
# I add both old stype and new style cdts : https://github.com/conda-forge/cdt-builds#old-stylelegacy-vs-new-style-cdts
list(APPEND CMAKE_FIND_ROOT_PATH $ENV{BUILD_PREFIX}/x86_64-conda-linux-gnu/sysroot $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot )
list(APPEND CMAKE_FIND_ROOT_PATH $ENV{PREFIX}/x86_64-conda-linux-gnu/sysroot $ENV{PREFIX}/$ENV{HOST}/sysroot )

link_directories($ENV{BUILD_PREFIX}/x86_64-conda-linux-gnu/sysroot/lib64 $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot/lib64)
link_directories($ENV{BUILD_PREFIX}/x86_64-conda-linux-gnu/sysroot/lib $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot/lib)
link_directories($ENV{BUILD_PREFIX}/x86_64-conda-linux-gnu/sysroot/usr/lib64 $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot/usr/lib64)
link_directories($ENV{BUILD_PREFIX}/x86_64-conda-linux-gnu/sysroot/usr/lib $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot/usr/lib)
endif()

message("CMAKE_FIND_ROOT_PATH :" ${CMAKE_FIND_ROOT_PATH})
message(STATUS "CMAKE_FIND_ROOT_PATH :")
foreach(dir ${CMAKE_FIND_ROOT_PATH})
message(STATUS " - " ${dir})
endforeach()

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
Expand Down Expand Up @@ -86,4 +109,12 @@ else()
message(STATUS "Install Prefix: " ${CMAKE_INSTALL_PREFIX})
endif()

function(install_pgllib libname)
message("Installing ${libname} in ${CONDA_ENV}lib/")
install(TARGETS ${libname}
RUNTIME DESTINATION "${CONDA_ENV}bin/"
LIBRARY DESTINATION "${CONDA_ENV}lib/"
ARCHIVE DESTINATION "${CONDA_ENV}lib/"
)
endfunction()

14 changes: 5 additions & 9 deletions cmake/pywrapper.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@


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)
if (APPLE)
target_link_libraries(${libwrapname} "-undefined dynamic_lookup")
else()
target_link_libraries(${libwrapname} Python3::Python)
endif()
else()
message(STATUS "Do not link with Python directly : " ${libwrapname})
endif()
endfunction()

function(pgllib_link_boost libwrapname)
Expand All @@ -35,5 +31,5 @@ function(pglwrapper_install libwrapname)
endfunction()

function(install_share sharedirectory project)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${sharedirectory}/ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${project}")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${sharedirectory}/ DESTINATION "${CONDA_ENV}/share/${project}")
endfunction()
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions conda/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: lpy_dev
channels:
- openalea3/label/dev
- openalea3/label/rc
- conda-forge
dependencies:
- openalea.plantgl
- qtconsole
- pip
- pip:
- -e .."[doc, test]"
11 changes: 8 additions & 3 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ source:
path: ..

about:
home: https://github.com/openalea/plantgl
home: https://github.com/openalea/lpy
license: Cecill-C
summary: An open-source graphic toolkit for the creation, simulation and analysis of 3D virtual plants.
summary: Lindenmayer Systems in Python package for OpenAlea.

build:
string: py{{ PY_VER }}
number: 0
preserve_egg_dir: True
script:
- {{ PYTHON }} -m pip install --prefix={{ PREFIX }} . --no-deps --no-build-isolation -vv
entry_points:
- lpy = openalea.lpy.gui.lpystudio:main
- cpfg2lpy = openalea.lpy.cpfg_compat.cpfg2lpy:main

requirements:
host:
- python
- setuptools
- setuptools_scm
- scikit-build-core
- openalea.plantgl
- boost
- pyqt
Expand All @@ -38,7 +44,6 @@ requirements:
- setuptools
- openalea.plantgl
- boost
- pyqt
- ipython
- qtconsole
- jupyter_client # <6
Expand Down
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["scikit-build-core", "setuptools-scm"]
build-backend = "scikit_build_core.build"

[project]
name = "openalea.lpy"
authors = [
{name = "Frederic Boudon"}
]
description = "Lindenmayer Systems in Python package for OpenAlea."
requires-python = ">=3.9"
classifiers = [
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering",
]
license-files = ["LICEN[CS]E*"]
# version = "1.0.2"
readme = "README.rst"
dynamic = ["version"]
dependencies = [
"pandas",
"scipy",
]

[project.optional-dependencies]
doc = [
"sphinx",
"sphinx-autoapi",
"sphinx-copybutton",
"nbsphinx",
"pydata-sphinx-theme",
"myst-parser",
"sphinx-favicon"
]
notebook = [
"jupyter",
"ipywidgets"
]
test = [
"pytest",
"pytest-cov",
]

[tool.conda.environment]
channels = [
"openalea3",
"conda-forge"
]
dependencies = [
"openalea.plantgl",
"qtconsole",
]

[tool.setuptools_scm]
# Format version to ease alignment with conda/meta.yaml tag-based versioning
fallback_version = "3.14.1.dev0"
version_scheme = "guess-next-dev"
local_scheme = "no-local-version"

[tool.scikit-build]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
build-dir="./build/"
sdist.include = ["*.so", "*.dylib", "*.dll", "*.pyd", '*.lpy','*.ui','*.qrc','*.json','*.png']
sdist.exclude = ["*.pyc", "*.pyo"]
logging.level = "WARNING"
build.verbose = true
experimental = true

[tool.scikit-build.cmake]
build-type="Release"
source-dir="."

[tool.scikit-build.wheel]
packages = ["src/openalea/"]

[project.urls]
Homepage = "https://github.com/openalea/lpy"
"Bug Tracker" = "https://github.com/openalea/lpy/issues"
Discussions = "https://github.com/openalea/lpy/discussions"
Changelog = "https://github.com/openalea/lpy/releases"

[project.entry-points."wralea"]
"lpy" = "openalea.lpy_wralea"

[project.scripts]
"lpy" = "openalea.lpy.gui.lpystudio:main"
"cpfg2lpy" = "openalea.lpy.cpfg_compat.cpfg2lpy:main"
4 changes: 2 additions & 2 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ endif()

# --- Output Library

install(TARGETS lpy LIBRARY DESTINATION "lib")
install_pgllib(lpy)

# --- Install Headers

install(DIRECTORY "." DESTINATION "include/lpy" FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
install(DIRECTORY "." DESTINATION "${CONDA_ENV}include/lpy" FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
2 changes: 1 addition & 1 deletion src/openalea/lpy/gui/lpystudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def main():
splash.finish(w)
w.splash = splash

qapp.exec_()
return qapp.exec_()

if __name__ == '__main__':
main()
Loading