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
59 changes: 45 additions & 14 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,41 @@ name: wheel
on: [push, workflow_dispatch]

jobs:
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Reorganize repository
run: |
git config user.email ""
git config user.name "dummy"
git subtree add --prefix python/subprojects/s-dftd3 . HEAD
git mv {assets,python/dftd3}/parameters.toml
git mv python/{mesonpep517,pyproject}.toml
git commit -m "Python dist"
- run: |
pipx run build python/ --sdist --outdir .
- uses: actions/upload-artifact@v3
with:
name: dftd3-python-sdist
path: ./*.tar.gz
retention-days: 5

manylinux:
needs:
- sdist
runs-on: ubuntu-latest
container: condaforge/linux-anvil-cos7-x86_64
strategy:
fail-fast: false
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
python: ['3.7', '3.8', '3.9', '3.10']

defaults:
run:
shell: ${{ matrix.shell || 'bash -l {0}' }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
path: python/subprojects/s-dftd3
- name: Create environment
run: >-
mamba create -n wheel
Expand All @@ -28,20 +46,33 @@ jobs:
fortran-compiler
python=${{ matrix.python }}
auditwheel
--file assets/ci/wheel-req.txt
git
python
pip
python-build
pkgconfig
patchelf
cffi
numpy
meson
unzip
wheel
- name: Download sdist
uses: actions/download-artifact@v2
with:
name: dftd3-python-sdist
- name: Build wheel
run: |
conda activate wheel
set -ex
cp ../assets/parameters.toml dftd3
cp {mesonpep517,pyproject}.toml
python -m build . --wheel
auditwheel show dist/*.whl
auditwheel repair -w dist dist/*.whl --plat ${{ env.plat }}
rm dist/*-linux_x86_64.whl
tar xvf dftd3-*.tar.gz
python -m build dftd3-*/ --wheel
auditwheel show dftd3-*/dist/*.whl
auditwheel repair -w . dftd3-*/dist/*.whl --plat ${{ env.plat }}
env:
plat: manylinux${{ matrix.python == '3.6' && '2010' || '_2_12' }}_x86_64
working-directory: python
- uses: actions/upload-artifact@v3
with:
path: python/dist/*.whl
name: dftd3-python-${{ matrix.python }}
path: ./*.whl
retention-days: 5
5 changes: 5 additions & 0 deletions config/template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
set("@PROJECT_NAME@_WITH_API" @WITH_API@)
set("@PROJECT_NAME@_WITH_OpenMP" @WITH_OpenMP@)
set("@PROJECT_NAME@_WITH_BLAS" @WITH_BLAS@)
set(
"@PROJECT_NAME@_INCLUDE_DIRS"
"@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@"
"@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@module-dir@"
)

if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
Expand Down
2 changes: 2 additions & 0 deletions include/s-dftd3.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
#define SDFTD3_API_ENTRY extern "C"
#else
#define SDFTD3_API_ENTRY extern
#ifndef SDFTD3_CFFI
#include <stdbool.h>
#endif
#endif
#define SDFTD3_API_CALL
#define SDFTD3_API_SUFFIX__V_0_2
#define SDFTD3_API_SUFFIX__V_0_3
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ sdftd3_dep = declare_dependency(
link_with: sdftd3_lib,
include_directories: sdftd3_inc,
dependencies: lib_deps,
variables: {'includedir': meson.current_source_dir() / 'include'},
)

sdftd3_parameters = files(
Expand Down
48 changes: 34 additions & 14 deletions python/dftd3/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ python_dep = python.dependency(required: true)
# Python's CFFI is horrible in working with preprocessor statements,
# therefore, we have to preprocess the header before passing it to the ffibuilder
sdftd3_pp = configure_file(
command: [cc, '-E', '@INPUT@'],
command: [
cc,
'-I@0@'.format(
sdftd3_dep.get_variable(
pkgconfig: 'includedir',
cmake: 's-dftd3_INCLUDE_DIRS',
internal: 'includedir',
).split().get(0)
),
'-DSDFTD3_CFFI',
'-E',
'@INPUT@',
],
input: sdftd3_header[0],
output: '_libdftd3.h',
capture: true,
Expand All @@ -55,21 +67,29 @@ sdftd3_pyext = python.extension_module(
subdir: 'dftd3',
)

pysrcs = files(
'__init__.py',
'ase.py',
'library.py',
'interface.py',
'parameters.py',
'pyscf.py',
'qcschema.py',
'test_ase.py',
'test_library.py',
'test_interface.py',
'test_parameters.py',
'test_pyscf.py',
'test_qcschema.py',
)
fs = import('fs')
if fs.exists('parameters.toml')
pysrcs += files('parameters.toml')
endif

if install
python.install_sources(
'__init__.py',
'ase.py',
'library.py',
'interface.py',
'parameters.py',
'pyscf.py',
'qcschema.py',
'test_ase.py',
'test_library.py',
'test_interface.py',
'test_parameters.py',
'test_pyscf.py',
'test_qcschema.py',
pysrcs,
subdir: 'dftd3',
)
endif
3 changes: 3 additions & 0 deletions python/include/_dftd3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#include "dftd3.h"
2 changes: 1 addition & 1 deletion python/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ sdftd3_dep = dependency(
'python=false',
],
)
sdftd3_header = files('..'/'include'/'s-dftd3.h')
sdftd3_header = files('include'/'_dftd3.h')

subdir('dftd3')
40 changes: 30 additions & 10 deletions python/mesonpep517.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
[build-system]
requires = ["mesonpep517"]
build-backend = "mesonpep517.buildapi"
requires = ["meson-python", "cffi"]
build-backend = "mesonpy"

[tool.mesonpep517.metadata]
author = "Sebastian Ehlert"
author-email = "awvwgk@disroot.org"
summary = "Python API of the DFT-D3 project"
description-file = "README.rst"
home-page = "https://dftd3.readthedocs.io"
requires = [
[project]
name = "dftd3"
version = "0.6.0"
description = "Python API of the DFT-D3 project"
readme = "README.rst"
license.text = "LGPL-3.0-or-later"
urls.repository = "https://github.com/dftd3/simple-dftd3"
urls.documentation = "https://dftd3.readthedocs.io"
classifiers = [
"Intended Audience :: Science/Research",
"Programming Language :: Fortran",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
]
requires-python = ">=3.7"
dependencies = [
"cffi",
"numpy",
]
requires-python = ">=3.6"
optional-dependencies.ase = ["ase"]
optional-dependencies.qcschema = ["qcelemental"]
optional-dependencies.pyscf = ["pyscf"]
optional-dependencies.test = [
"pytest",
"pytest-cov",
]