From e242ca5fc0fdc5a7d70b221b3df996bda219b77c Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Fri, 11 Mar 2022 15:03:38 +0100 Subject: [PATCH 1/5] Revert "BLD: Remove conda as a hard build requirement" This reverts commit 3903b1ad4891b13caa8107b57aeaa873c318fe0d. --- setup.py | 61 ++++++++++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/setup.py b/setup.py index cd9c2c40e..b4bdaac60 100644 --- a/setup.py +++ b/setup.py @@ -2,23 +2,20 @@ import os import sys from os.path import join -from typing import Dict, List, Tuple, TYPE_CHECKING +from typing import Dict import setuptools from Cython.Distutils import build_ext from setuptools import Extension, find_packages, setup -if TYPE_CHECKING: - from distutils.ccompiler import CCompiler - here = os.path.abspath(os.path.dirname(__file__)) -version: Dict[str, str] = {} +version = {} # type: Dict[str, str] with open(os.path.join(here, 'nanoqm', '__version__.py')) as f: exec(f.read(), version) -def readme() -> str: +def readme(): """Load readme.""" with open('README.rst') as f: return f.read() @@ -32,15 +29,15 @@ class get_pybind_include: method can be invoked. """ - def __init__(self, user: bool = False) -> None: + def __init__(self, user=False): self.user = user - def __str__(self) -> str: + def __str__(self): import pybind11 return pybind11.get_include(self.user) -def has_flag(compiler: "CCompiler", flagname: str) -> bool: +def has_flag(compiler, flagname): """Return a boolean indicating whether a flag name is supported on the specified compiler. As of Python 3.6, CCompiler has a `has_flag` method. @@ -56,7 +53,7 @@ def has_flag(compiler: "CCompiler", flagname: str) -> bool: return True -def cpp_flag(compiler: "CCompiler") -> str: +def cpp_flag(compiler): """Return the -std=c++[17/14/11] compiler flag. The newer version is prefered over c++11 (when it is available). @@ -74,11 +71,11 @@ def cpp_flag(compiler: "CCompiler") -> str: class BuildExt(build_ext): """A custom build extension for adding compiler-specific options.""" - c_opts: Dict[str, List[str]] = { + c_opts = { 'msvc': ['/EHsc'], 'unix': [], } - l_opts: Dict[str, List[str]] = { + l_opts = { 'msvc': [], 'unix': [], } @@ -88,7 +85,7 @@ class BuildExt(build_ext): c_opts['unix'] += darwin_opts l_opts['unix'] += darwin_opts - def build_extensions(self) -> None: + def build_extensions(self): """Actual compilation.""" ct = self.compiler.compiler_type opts = self.c_opts.get(ct, []) @@ -108,43 +105,29 @@ def build_extensions(self) -> None: build_ext.build_extensions(self) -def get_includes() -> Tuple[str, str]: - """Get the include directories of the ``eigen`` and ``libint`` C++ libraries. +# Set path to the conda libraries +conda_prefix = os.environ["CONDA_PREFIX"] +if conda_prefix is None: + raise RuntimeError( + "No conda module found. A Conda environment is required") - Use the paths specified in the ``$EIGEN3_INCLUDE_DIR`` and ``$LIBINT_INCLUDE_DIR`` - environment variables if specified; use ``$CONDA_PREFIX`` otherwise. - """ - conda_prefix = os.environ.get("CONDA_PREFIX") - eigen_dir = os.environ.get("EIGEN3_INCLUDE_DIR") - libint_dir = os.environ.get("LIBINT_INCLUDE_DIR") - if conda_prefix is None and (None in (eigen_dir, libint_dir)): - raise RuntimeError( - "No conda module found. A Conda environment is required " - "or one must set both the `$EIGEN3_INCLUDE_DIR` and `$LIBINT_INCLUDE_DIR` " - "environment variables" - ) - - if conda_prefix is not None: - return join(conda_prefix, 'include', 'eigen3'), join(conda_prefix, 'include') - else: - return eigen_dir, libint_dir - - -eigen_include, libint_include = get_includes() +conda_include = join(conda_prefix, 'include') +conda_lib = join(conda_prefix, 'lib') ext_pybind = Extension( 'compute_integrals', sources=['libint/compute_integrals.cc'], include_dirs=[ # Path to pybind11 headers 'libint/include', - libint_include, - eigen_include, + conda_include, + join(conda_include, 'eigen3'), get_pybind_include(), get_pybind_include(user=True), + '/usr/include/eigen3' ], libraries=['hdf5', 'int2'], - language='c++', -) + library_dirs=[conda_lib], + language='c++') setup( name='nano-qmflows', From 9bbd87d0d51207286e25bf141c244bd5082da4b6 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Fri, 11 Mar 2022 15:04:48 +0100 Subject: [PATCH 2/5] TST: Use GH Actions builtin `concurrency` option over `styfle/cancel-workflow-action` --- .github/workflows/pythonapp.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 05412e276..60c1b791d 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -7,6 +7,10 @@ on: pull_request: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: test: name: ${{ matrix.os }}; py ${{ matrix.python-version }}; CP2K ${{ matrix.cp2k }}; gcc ${{ matrix.gcc }}; pre-release ${{ matrix.pre_release }} @@ -74,11 +78,6 @@ jobs: CP2K_DATA_DIR: /usr/share/cp2k/data steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v2 - name: Install CP2K From 78887ce21e499361780deb6a7d6115397224f86e Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Fri, 11 Mar 2022 15:23:06 +0100 Subject: [PATCH 3/5] TYP: Add annotations to `setup.py` --- .github/workflows/pythonapp.yml | 4 ++-- setup.py | 33 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 60c1b791d..3a1700496 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -169,7 +169,7 @@ jobs: python-version: "3.10" - name: Install linters - run: pip install pydocstyle pycodestyle mypy qmflows "numpy>=1.21" types-pyyaml types-pkg_resources + run: pip install pydocstyle pycodestyle mypy qmflows "numpy>=1.21" types-pyyaml types-pkg_resources types-setuptools - name: Python info run: | @@ -186,5 +186,5 @@ jobs: run: pydocstyle nanoqm - name: Run mypy - run: mypy nanoqm + run: mypy nanoqm setup.py continue-on-error: true diff --git a/setup.py b/setup.py index b4bdaac60..43fd74f5c 100644 --- a/setup.py +++ b/setup.py @@ -2,20 +2,27 @@ import os import sys from os.path import join -from typing import Dict +from typing import TYPE_CHECKING import setuptools from Cython.Distutils import build_ext from setuptools import Extension, find_packages, setup +if TYPE_CHECKING: + from distutils.ccompiler import CCompiler + from distutils.errors import CompileError +else: + CCompiler = setuptools.distutils.ccompiler.CCompiler + CompileError = setuptools.distutils.errors.CompileError + here = os.path.abspath(os.path.dirname(__file__)) -version = {} # type: Dict[str, str] +version: "dict[str, str]" = {} with open(os.path.join(here, 'nanoqm', '__version__.py')) as f: exec(f.read(), version) -def readme(): +def readme() -> str: """Load readme.""" with open('README.rst') as f: return f.read() @@ -29,15 +36,15 @@ class get_pybind_include: method can be invoked. """ - def __init__(self, user=False): + def __init__(self, user: bool = False) -> None: self.user = user - def __str__(self): + def __str__(self) -> str: import pybind11 return pybind11.get_include(self.user) -def has_flag(compiler, flagname): +def has_flag(compiler: "CCompiler", flagname: str) -> bool: """Return a boolean indicating whether a flag name is supported on the specified compiler. As of Python 3.6, CCompiler has a `has_flag` method. @@ -48,18 +55,17 @@ def has_flag(compiler, flagname): f.write('int main (int argc, char **argv) { return 0; }') try: compiler.compile([f.name], extra_postargs=[flagname]) - except setuptools.distutils.errors.CompileError: + except CompileError: return False return True -def cpp_flag(compiler): +def cpp_flag(compiler: "CCompiler") -> str: """Return the -std=c++[17/14/11] compiler flag. The newer version is prefered over c++11 (when it is available). """ flags = ['-std=c++17', '-std=c++14', '-std=c++11'] - for flag in flags: if has_flag(compiler, flag): return flag @@ -71,11 +77,11 @@ def cpp_flag(compiler): class BuildExt(build_ext): """A custom build extension for adding compiler-specific options.""" - c_opts = { + c_opts: "dict[str, list[str]]" = { 'msvc': ['/EHsc'], 'unix': [], } - l_opts = { + l_opts: "dict[str, list[str]]" = { 'msvc': [], 'unix': [], } @@ -85,7 +91,7 @@ class BuildExt(build_ext): c_opts['unix'] += darwin_opts l_opts['unix'] += darwin_opts - def build_extensions(self): + def build_extensions(self) -> None: """Actual compilation.""" ct = self.compiler.compiler_type opts = self.c_opts.get(ct, []) @@ -127,7 +133,8 @@ def build_extensions(self): ], libraries=['hdf5', 'int2'], library_dirs=[conda_lib], - language='c++') + language='c++', +) setup( name='nano-qmflows', From b837034c904fe08cdf81cc16a298dcaf3a4df9fa Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Fri, 11 Mar 2022 15:23:36 +0100 Subject: [PATCH 4/5] BLD: Set the minimum setuptools version to >=48.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7fe0dfb2a..7a911ff4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] # Minimum requirements for the build system to execute. -requires = ['Cython', 'setuptools', 'wheel', 'pybind11>=2.2.4'] +requires = ['Cython', 'setuptools>=48.0', 'wheel', 'pybind11>=2.2.4'] [tool.mypy] plugins = "numpy.typing.mypy_plugin" From cef0feaf0bed538271991bfc2ff27c14404ac5ea Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Fri, 11 Mar 2022 15:30:45 +0100 Subject: [PATCH 5/5] REL: Prepare for Nano-QMFlows 0.12.3 --- CHANGELOG.md | 13 +++++++++++++ nanoqm/__version__.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4200d9307..e93887f59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +# 0.12.3 (11/03/2022) + +## Changed +* Do not hard code basis set names for compution of the HOMO index. +* Do not overwrite explicit `basis_set_file_name` and `potential_file_name` CP2K settings. +* Add the `basis_file_name` and `potential_file_name` options. +* Do not hard-code the `BASIS_MOLOPT` coefficients in the .hdf5 file. +* Always use the `-q` suffix when reading basis sets from .hdf5. +* Add settings for manual choice of XC functionals for GGA, MGGA and hybrids. +* Remove the upper version bound of noodles. +* Formally set the minimum python version to >= 3.7. + + # 0.12.2 (17/11/2021) ## Changed diff --git a/nanoqm/__version__.py b/nanoqm/__version__.py index ac5faf58f..fcef531fe 100644 --- a/nanoqm/__version__.py +++ b/nanoqm/__version__.py @@ -1,3 +1,3 @@ """The Nano-QMFlows version.""" -__version__ = '0.12.2' +__version__ = '0.12.3'