diff --git a/.github/workflows/conda-package-build.yml b/.github/workflows/conda-package-build.yml index b975736..ed7d257 100644 --- a/.github/workflows/conda-package-build.yml +++ b/.github/workflows/conda-package-build.yml @@ -1,18 +1,23 @@ -name: Building Package +name: OpenAlea CI on: push: branches: - - '**' + - main + - master tags: - 'v*' pull_request: - branches: - - '**' - + types: + - opened + - synchronize + - reopened + release: + types: + - published jobs: build: - uses: openalea/github-action-conda-build/.github/workflows/conda-package-build.yml@main + uses: openalea/action-build-publish-anaconda/.github/workflows/openalea_ci.yml@main secrets: - anaconda_token: ${{ secrets.ANACONDA_TOKEN }} \ No newline at end of file + anaconda_token: ${{ secrets.ANACONDA_TOKEN }} diff --git a/conda/environment.yml b/conda/environment.yml index 4646782..d951756 100644 --- a/conda/environment.yml +++ b/conda/environment.yml @@ -1,14 +1,14 @@ +name: hydroroot_dev channels: - - conda-forge + - openalea3/label/dev + - openalea3/label/rc - openalea3 + - conda-forge dependencies: - openalea.mtg - openalea.plantgl - - alinea.caribu - - alinea.astk - - numpy - - scipy - - sympy - - pandas - - jsonschema - - pvlib-python + - openalea.caribu + - openalea.astk + - pip + - pip: + - -e .."[test,doc]" diff --git a/conda/meta.yaml b/conda/meta.yaml index 44ceab3..05d8031 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,35 +1,60 @@ -package: - name: hydroshoot - version: "5.2.2" +{% set pyproject = load_file_data('../pyproject.toml', from_recipe_dir=True) %} +{% set name = pyproject.get('project').get('name') %} +{% set description = pyproject.get('project').get('description') %} +{% set version = environ.get('SETUPTOOLS_SCM_PRETEND_VERSION', "0.0.0.dev") %} +{% set license = pyproject.get('project').get('license') %} +{% set home = pyproject.get('project', {}).get('urls', {}).get('Homepage', '') %} +{% set build_deps = pyproject.get("build-system", {}).get("requires", []) %} +{% set deps = pyproject.get('project', {}).get('dependencies', []) %} +{% set conda_deps = pyproject.get('tool', {}).get('conda', {}).get('environment', {}).get('dependencies',[]) %} +{% set test_deps = pyproject.get('project', {}).get('optional-dependencies', {}).get('test',[]) %} +package: + name: {{ name }} + version: {{ version }} source: - git_url: ../ + path: .. build: - noarch: python + string: py{{ PY_VER }} + number: 0 preserve_egg_dir: True - script: {{PYTHON}} -m pip install . + script: + - {{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-build-isolation -vv requirements: - build: - - python {{PY_VER}} - - setuptools + host: + - python + - setuptools_scm + {% for dep in build_deps %} + - {{ dep }} + {% endfor %} run: - python - - numpy - - scipy - - sympy - - pandas - - jsonschema - - pvlib-python - - openalea.mtg - - openalea.plantgl - - alinea.caribu - - alinea.astk + {% for dep in deps + conda_deps %} + - {{ dep }} + {% endfor %} + + +test: + imports: + - {{ name }} + requires: + - pytest + source_files: + - test/ + commands: + - pytest -v about: - summary: "HydroShoot is an FSPM model to simulate gas-exchange on vine" - license: "cecill-c" - license_file: LICENSE + home: {{ home }} + summary: {{ description }} + license: {{ license }} + +extra: + recipe-maintainers: + - artzet-s + - pradal + - fournier \ No newline at end of file diff --git a/doc/environment.yml b/doc/environment.yml index ad69412..0750c30 100644 --- a/doc/environment.yml +++ b/doc/environment.yml @@ -5,7 +5,7 @@ channels: dependencies: - openalea.mtg - openalea.plantgl - - alinea.caribu + - openalea.caribu - alinea.astk - numpy - scipy diff --git a/pyproject.toml b/pyproject.toml index a79c2bc..175b9c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] @@ -11,21 +11,17 @@ authors = [ { name = "Eric Lebon"}, ] description = "A functional-structural plant model (FSPM) to simulate gas and energy exchange of grapevine" -license = {file = "LICENSE"} -requires-python = ">=3.8" +license = "CECILL-C" +license-files = ["LICEN[CS]E*"] +requires-python = ">=3.9" classifiers = [ "Intended Audience :: Science/Research", "Intended Audience :: Developers", - "License :: OSI Approved :: CeCILL-C License", "Operating System :: OS Independent", + "Framework :: OpenAlea", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering", ] @@ -55,11 +51,31 @@ Discussions = "https://github.com/openalea/hydroshoot/discussions" Changelog = "https://github.com/openalea/hydroshoot/releases" [tool.setuptools.dynamic] -version = {attr = "hydroshoot.version.__version__"} readme = {file = ["README.rst"]} +# enable dynamic version based on git tags +[tool.setuptools_scm] +# Format version to ease alignment with conda/meta.yaml tag-based versioning +fallback_version = "5.2.2.dev0" +version_scheme = "guess-next-dev" +local_scheme = "no-local-version" + [tool.setuptools.packages.find] where = ["src"] [tool.setuptools.package-data] "hydroshoot_data" = ["*"] + +# not used yet by pip, but by meta.yaml +[tool.conda.environment] +channels = [ + "openalea3", + "conda-forge", +] +# deps not available in pip with conda name +dependencies = [ + "openalea.mtg", + "openalea.plantgl", + "openalea.caribu", + "openalea.astk", +] diff --git a/src/hydroshoot/__init__.py b/src/hydroshoot/__init__.py index 7025d99..56e70c0 100644 --- a/src/hydroshoot/__init__.py +++ b/src/hydroshoot/__init__.py @@ -1,7 +1,7 @@ -# {# pkglts, base +from importlib.metadata import version, PackageNotFoundError -from . import version - -__version__ = version.__version__ - -# #} +try: + __version__ = version("hydroshoot") +except PackageNotFoundError: + # package is not installed + pass diff --git a/src/hydroshoot/energy.py b/src/hydroshoot/energy.py index d76a61f..9acead4 100644 --- a/src/hydroshoot/energy.py +++ b/src/hydroshoot/energy.py @@ -10,10 +10,10 @@ from math import pi -import alinea.astk.icosphere as ico +import openalea.astk.icosphere as ico import openalea.plantgl.all as pgl -from alinea.caribu.CaribuScene import CaribuScene -from alinea.caribu.sky_tools import turtle +from openalea.caribu.CaribuScene import CaribuScene +from openalea.caribu.sky_tools import turtle from openalea.mtg.mtg import MTG from scipy import optimize from sympy import Symbol diff --git a/src/hydroshoot/irradiance.py b/src/hydroshoot/irradiance.py index 1f9dac3..b36bf5d 100644 --- a/src/hydroshoot/irradiance.py +++ b/src/hydroshoot/irradiance.py @@ -6,10 +6,10 @@ TODO: plug to the standard interface of Caribu module. """ -import alinea.astk.icosphere as ico -from alinea.caribu.CaribuScene import CaribuScene -from alinea.caribu.sky_tools import turtle, Gensun, GetLightsSun -from alinea.caribu.sky_tools.spitters_horaire import RdRsH +import openalea.astk.icosphere as ico +from openalea.caribu.CaribuScene import CaribuScene +from openalea.caribu.sky_tools import turtle, Gensun, GetLightsSun +from openalea.caribu.sky_tools.spitters_horaire import RdRsH from numpy import array, deg2rad from openalea.plantgl.all import Translated, Sphere, Shape, Material, Color3, Viewer from pandas import date_range diff --git a/src/hydroshoot/version.py b/src/hydroshoot/version.py deleted file mode 100644 index 5da0853..0000000 --- a/src/hydroshoot/version.py +++ /dev/null @@ -1,9 +0,0 @@ -# {# pkglts, version -# -*- coding: utf-8 -*- - -major = 5 -minor = 2 -post = 2 - -__version__ = ".".join([str(s) for s in (major, minor, post)]) -# #}