diff --git a/.github/workflows/deploy_check.yml b/.github/workflows/deploy_check.yml index cf16019a6..cfb1161e2 100644 --- a/.github/workflows/deploy_check.yml +++ b/.github/workflows/deploy_check.yml @@ -45,10 +45,14 @@ jobs: - name: Build and deploy to TestPyPI if: steps.duplicate_check.outputs.should_skip != 'true' run: | - CURRENT_VERSION=$(sed -n 's/__version__ = "\(.*\)"/\1/p' psydac/version.py) + CURRENT_VERSION=$(grep 'version *= *"\([0-9\.]*\)"' pyproject.toml | grep '[0-9\.]*' -o) TEST_VERSION=${CURRENT_VERSION}.dev$(date +%Y%m%d%H%M%S) - sed -i.bak "s/${CURRENT_VERSION}/${TEST_VERSION}/g" psydac/version.py && rm psydac/version.py.bak + sed -i.bak "s/\"${CURRENT_VERSION}\"/\"${TEST_VERSION}\"/g" pyproject.toml && rm pyproject.toml.bak echo "TEST_VERSION=${TEST_VERSION}" >> $GITHUB_ENV + # Setup dummy user to save temp version for meson + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + git commit -m "Save temp version" pyproject.toml python -m build --sdist ls dist/* twine check --strict dist/* diff --git a/.gitmodules b/.gitmodules index 366b7b8d6..c30e31fc5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "external/igakit"] - path = external/igakit +[submodule "subprojects/igakit"] + path = subprojects/igakit url = https://github.com/dalcinl/igakit/ diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..393112bf7 --- /dev/null +++ b/meson.build @@ -0,0 +1,47 @@ +project( + 'psydac', + 'c', 'fortran', + meson_version: '>=1.1.0', +) + +run_command('pyccel', 'make', '-g', 'psydac/**/*_kernels.py', '--convert-only', + check: true) + +find = find_program('find', required: true) + +pyccel_meson_math_file = run_command(find, '__pyccel__/math', '-name', 'meson.build', + check: true).stdout().strip() +pyccel_meson_cwrapper_file = run_command(find, '__pyccel__/cwrapper', '-name', 'meson.build', + check: true).stdout().strip() +pyccel_meson_files = run_command(find, '__pyccel__/psydac', '-name', 'meson.build', + check: true).stdout().split() + +sed = find_program('sed', required: true) + +run_command(sed, '-i.swp', 's/install: true//g', pyccel_meson_math_file, pyccel_meson_cwrapper_file, + check: true) + +foreach f : pyccel_meson_files + f_parts = f.split('/') + rel_f = f_parts.get(1) + foreach i : range(2, f_parts.length()-1) + rel_f = rel_f / f_parts.get(i) + endforeach + run_command(sed, '-i.swp', 's/install_dir: .*/subdir: \'' + rel_f.replace('/','\/') + '\',/g', f, + check: true) +endforeach + + +igakit_proj = subproject('igakit') + +py = import('python').find_installation(modules: ['numpy'], pure: false) + +subdir('__pyccel__/math') +subdir('__pyccel__/cwrapper') +subdir('__pyccel__/psydac') + +# Install the pure-Python package itself +install_subdir('psydac', install_dir: py.get_install_dir()) +install_subdir('mesh', install_dir: py.get_install_dir()) + + diff --git a/psydac/version.py b/psydac/version.py index 567ce4fc2..3652431d0 100644 --- a/psydac/version.py +++ b/psydac/version.py @@ -3,4 +3,33 @@ # LICENSE file or go to https://github.com/pyccel/psydac/blob/devel/LICENSE # # for full license details. # #---------------------------------------------------------------------------# -__version__ = "0.1" +def extract_version() -> str: + """ + Returns either the version of the installed package (e.g. "0.17.1") or the + one found in pyproject.toml (e.g. "0.17.1-dev (at /project/location)"). + + Returns + ------- + str + The package version. + + See also + -------- + https://stackoverflow.com/a/76206192 + + """ + from contextlib import suppress + from pathlib import Path + + with suppress(FileNotFoundError, StopIteration): + root_dir = Path(__file__).parent.parent + with open(root_dir / "pyproject.toml", encoding="utf-8") as pyproject_toml: + version_line = next(line for line in pyproject_toml if line.startswith("version")) + version = version_line.split("=")[1].strip("'\"\n ") + return f"{version}-dev (at {root_dir})" + + import importlib.metadata + return importlib.metadata.version(__package__) + + +__version__ = extract_version() diff --git a/pyproject.toml b/pyproject.toml index 59c36fd15..91b514045 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,14 @@ [build-system] -requires = ["setuptools >= 64.0, != 67.2.0", "wheel", "numpy", "pyccel >= 2.1.0"] -build-backend = "setuptools.build_meta" +requires = ["meson-python", "wheel", "numpy", "pyccel >= 2.1.0"] +build-backend = "mesonpy" [project] name = "psydac" description = "Python package for isogeometric analysis (IGA)" -dynamic = ["version"] readme = "README.md" license = "MIT" license-files = ["LICENSE", "AUTHORS"] +version = "0.1" requires-python = ">= 3.10" authors = [ {name = "PSYDAC development team", email = "psydac@googlegroups.com"} @@ -51,9 +51,6 @@ dependencies = [ # When pyccel is run in parallel with MPI, it uses tblib to pickle # tracebacks, which allows mpi4py to broadcast exceptions 'tblib', - - # IGAKIT - not on PyPI - 'igakit @ https://github.com/dalcinl/igakit/archive/refs/heads/master.zip' ] [project.optional-dependencies] @@ -73,13 +70,10 @@ Repository = "https://github.com/pyccel/psydac.git" psydac-mesh = "psydac.cmd.mesh:main" psydac-accelerate = "psydac.cmd.accelerate:main" -[tool.setuptools.packages.find] -include = ["psydac*"] -exclude = ["*__psydac__*"] -namespaces = false - -[tool.setuptools.package-data] -"*" = ["*.txt", "**/tests/data/*.png"] +[tool.meson-python.args] +setup=['-Ddefault_library=static'] +dist=['--include-subprojects'] +install=['--only=python-modules'] [tool.coverage.run] branch = true diff --git a/external/igakit b/subprojects/igakit similarity index 100% rename from external/igakit rename to subprojects/igakit