From: Gilles DAVID Date: Fri, 18 Oct 2024 19:19:06 +0000 (+0200) Subject: Début de l'installation par pip de KERNEL (package salome_kernel) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ab988c3b347c8161f25cf944fb59b9f8b63201f7;p=modules%2Fkernel.git Début de l'installation par pip de KERNEL (package salome_kernel) --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..0325d3b9c --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# Temporary and binary files +*~ +*.py[cod] +*.so +*.o +*.out +*.cfg +!.isort.cfg +!setup.cfg +!channel.cfg +*.orig +*.log +*.pot +__pycache__/* +.cache/* +.*.swp +*/.ipynb_checkpoints/* +.DS_Store + +# Project files +.ropeproject +.project +.pydevproject +.settings +.idea +.vscode +tags + +# Package files +*.egg +*.eggs/ +.installed.cfg +*.egg-info + +# Unittest and coverage +htmlcov/* +.coverage +.coverage.* +.tox +junit*.xml +coverage.xml +.pytest_cache/ + +# Build and docs folder/files +build/* +dist/* +sdist/* +docs/api/* +docs/_rst/* +docs/_build/* +cover/* +MANIFEST + +# Per-project virtualenvs +.venv*/ +.conda*/ +.python-version diff --git a/README_pypi.md b/README_pypi.md new file mode 100644 index 000000000..49930773d --- /dev/null +++ b/README_pypi.md @@ -0,0 +1,45 @@ +Procédure d'installation du package salome_kernel +================================================= + +Prérequis +--------- + +Avoir le dernier tag Git au format X.Y.Z + +Procédure +--------- + +* Positionner l'environnement de construction + - soit en positionnant les variables d'environnement cherchées par cmake (xxx_ROOT_DIR) + - soit en indiquant ces variables lors de l'installation + - les variables attendues sont : + - OMNIORBPY_DIR + - LIBBATCH_ROOT_DIR + - CMAKE_MODULE_PATH + +* Créer un environnement virtuel python + - python3 -m venv .venv + +* Copier le script 'activate' dans le répertoire 'bin' du venv + - cp -f activate .venv/bin + +* Activer le venv et mettre à jour pip et setuptools. Le package build peut aussi être installé pour la construction du wheel. + - source .venv/bin/activate + - python3 -m pip install -U pip setuptools build + +* Pour construire et installer le wheel de salome_kernel (par défaut les fichiers .tar.gz et .whl sont produits dans le répertoire dist) + - python3 -m build install requirements.txt + - python3 -m build --no-isolation -v + - python3 -m pip install dist/salome_kernel-[XXX].whl + +* Pour installer salome_kernel sans conserver le wheel + - python3 -m pip install . + +* Il est possible de fournir des options aux commandes pip pour configurer cmake : + * Par une option à pip : + - pip install -Ccmake.define.CMAKE_BUILD_PARALLEL_LEVEL=8 . + * Avec une variable d'environnement : + - CMAKE_BUILD_PARALLEL_LEVEL=8 pip install . + +Attention : le wheel produit n'est pas distribuable en l'état. Une réparation est nécessaire. +Cf https://scikit-build-core.readthedocs.io/en/stable/build.html#repairing diff --git a/activate b/activate new file mode 100644 index 000000000..dfe3df41c --- /dev/null +++ b/activate @@ -0,0 +1,77 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + if [ -n "${_OLD_VIRTUAL_LD_LIBRARY_PATH:-}" ] ; then + LD_LIBRARY_PATH="${_OLD_VIRTUAL_LD_LIBRARY_PATH:-}" + export LD_LIBRARY_PATH + unset _OLD_VIRTUAL_LD_LIBRARY_PATH + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "${1:-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && cd .. && pwd )" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + PS1="(.venv) ${PS1:-}" + export PS1 +fi + +PATH="$VIRTUAL_ENV/bin/salome:$PATH" + +_OLD_VIRTUAL_LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}" +LD_LIBRARY_PATH="$VIRTUAL_ENV/lib/salome:$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null +fi diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..ef8b16cef --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "salome_kernel" +description = "SALOME KERNEL module implements general services of SALOME platform." +readme = {file = "README", content-type = "text/markdown"} +requires-python = ">= 3.7" +license = {file = "COPYING"} +dependencies = [ + # Uncomment when omniorbpy wheel is published + # "omniorbpy", + "psutil", + "numpy", +] +dynamic = ["version"] + +[project.optional-dependencies] +scipy = ["scipy"] + +[tool.scikit-build.cmake.define] +SALOME_BUILD_TESTS = "ON" +SALOME_USE_LIBBATCH = "ON" +SALOME_USE_64BIT_IDS = "ON" +SALOME_BUILD_DOC = "OFF" + +OMNIORBPY_ROOT_DIR = {env="OMNIORBPY_DIR", default="EMPTY"} +LIBBATCH_ROOT_DIR = {env="LIBBATCH_ROOT_DIR", default="EMPTY"} +CMAKE_MODULE_PATH = {env="CONFIGURATION_CMAKE_DIR", default="EMPTY"} + +[tool.scikit-build] +cmake.version = ">=3.15" +cmake.build-type = "Release" +cmake.source-dir = "." +experimental = true +wheel.install-dir = "/data" +build-dir = "build/{wheel_tag}_{build_type}" + +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.setuptools_scm" + +[tool.setuptools_scm] +# write_to = "src/KERNEL_PY/_version.py" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..e778fc0aa --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ninja>=1.5 +scikit-build-core +setuptools_scm +build \ No newline at end of file