forked from easybuilders/easybuild-easyconfigs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16ce21b
commit 1401ca6
Showing
2 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
easybuild/easyconfigs/d/dm-tree/dm-tree-0.1.8-GCC-13.3.0.eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
easyblock = 'PythonPackage' | ||
|
||
name = 'dm-tree' | ||
version = '0.1.8' | ||
|
||
homepage = 'https://github.com/deepmind/tree' | ||
description = """dm-tree provides tree, a library for working with nested data structures. In a way, | ||
tree generalizes the builtin map function which only supports flat sequences, and | ||
allows to apply a function to each "leaf" preserving the overall structure.""" | ||
|
||
toolchain = {'name': 'GCC', 'version': '13.3.0'} | ||
|
||
sources = [SOURCELOWER_TAR_GZ] | ||
patches = ['dm-tree-0.1.8_pybind11.patch'] | ||
checksums = [ | ||
{'dm-tree-0.1.8.tar.gz': '0fcaabbb14e7980377439e7140bd05552739ca5e515ecb3119f234acee4b9430'}, | ||
{'dm-tree-0.1.8_pybind11.patch': '1ed433eda86d46333d735dfea9eecf9d007ba0ca8b1bc610c6f02cd478b8d131'}, | ||
] | ||
|
||
builddependencies = [ | ||
('pybind11', '2.12.0'), | ||
] | ||
dependencies = [ | ||
('Python', '3.12.3'), | ||
('Abseil', '20240722.0'), | ||
] | ||
|
||
download_dep_fail = True | ||
|
||
use_pip = True | ||
sanity_pip_check = True | ||
|
||
options = {'modulename': 'tree'} | ||
|
||
moduleclass = 'lib' |
140 changes: 140 additions & 0 deletions
140
easybuild/easyconfigs/d/dm-tree/dm-tree-0.1.8_pybind11.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
# Taken from: https://data.gpo.zugaina.org/benzene-overlay/dev-python/dm-tree/files/dm-tree-0.1.8-Simplify-setup.py-by-using-pybind11.setup_helpers.Py.patch | ||
From: Michael Fladischer <[email protected]> | ||
Date: Mon, 31 Jul 2023 21:13:42 +0000 | ||
Subject: Simplify setup.py by using pybind11.setup_helpers.Pybind11Extension. | ||
|
||
--- | ||
setup.py | 103 ++++++++++++--------------------------------------------------- | ||
1 file changed, 19 insertions(+), 84 deletions(-) | ||
|
||
diff --git a/setup.py b/setup.py | ||
index d1862a1..8381bff 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -15,14 +15,10 @@ | ||
"""Setup for pip package.""" | ||
|
||
import os | ||
-import platform | ||
-import shutil | ||
-import subprocess | ||
-import sys | ||
-import sysconfig | ||
|
||
-import setuptools | ||
-from setuptools.command import build_ext | ||
+from setuptools import find_packages, setup | ||
+from pybind11.setup_helpers import Pybind11Extension, build_ext | ||
+ | ||
|
||
here = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
@@ -48,80 +44,7 @@ def _parse_requirements(path): | ||
] | ||
|
||
|
||
-class CMakeExtension(setuptools.Extension): | ||
- """An extension with no sources. | ||
- | ||
- We do not want distutils to handle any of the compilation (instead we rely | ||
- on CMake), so we always pass an empty list to the constructor. | ||
- """ | ||
- | ||
- def __init__(self, name, source_dir=''): | ||
- super().__init__(name, sources=[]) | ||
- self.source_dir = os.path.abspath(source_dir) | ||
- | ||
- | ||
-class BuildCMakeExtension(build_ext.build_ext): | ||
- """Our custom build_ext command. | ||
- | ||
- Uses CMake to build extensions instead of a bare compiler (e.g. gcc, clang). | ||
- """ | ||
- | ||
- def run(self): | ||
- self._check_build_environment() | ||
- for ext in self.extensions: | ||
- self.build_extension(ext) | ||
- | ||
- def _check_build_environment(self): | ||
- """Check for required build tools: CMake, C++ compiler, and python dev.""" | ||
- try: | ||
- subprocess.check_call(['cmake', '--version']) | ||
- except OSError as e: | ||
- ext_names = ', '.join(e.name for e in self.extensions) | ||
- raise RuntimeError( | ||
- f'CMake must be installed to build the following extensions: {ext_names}' | ||
- ) from e | ||
- print('Found CMake') | ||
- | ||
- def build_extension(self, ext): | ||
- extension_dir = os.path.abspath( | ||
- os.path.dirname(self.get_ext_fullpath(ext.name))) | ||
- build_cfg = 'Debug' if self.debug else 'Release' | ||
- cmake_args = [ | ||
- f'-DPython3_ROOT_DIR={sys.prefix}', | ||
- f'-DPython3_EXECUTABLE={sys.executable}', | ||
- f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extension_dir}', | ||
- f'-DCMAKE_BUILD_TYPE={build_cfg}' | ||
- ] | ||
- if platform.system() != 'Windows': | ||
- cmake_args.extend([ | ||
- f'-DPython3_LIBRARY={sysconfig.get_paths()["stdlib"]}', | ||
- f'-DPython3_INCLUDE_DIR={sysconfig.get_paths()["include"]}', | ||
- ]) | ||
- if platform.system() == 'Darwin' and os.environ.get('ARCHFLAGS'): | ||
- osx_archs = [] | ||
- if '-arch x86_64' in os.environ['ARCHFLAGS']: | ||
- osx_archs.append('x86_64') | ||
- if '-arch arm64' in os.environ['ARCHFLAGS']: | ||
- osx_archs.append('arm64') | ||
- cmake_args.append(f'-DCMAKE_OSX_ARCHITECTURES={";".join(osx_archs)}') | ||
- os.makedirs(self.build_temp, exist_ok=True) | ||
- subprocess.check_call( | ||
- ['cmake', ext.source_dir] + cmake_args, cwd=self.build_temp) | ||
- subprocess.check_call( | ||
- ['cmake', '--build', '.', f'-j{os.cpu_count()}', '--config', build_cfg], | ||
- cwd=self.build_temp) | ||
- | ||
- # Force output to <extension_dir>/. Amends CMake multigenerator output paths | ||
- # on Windows and avoids Debug/ and Release/ subdirs, which is CMake default. | ||
- tree_dir = os.path.join(extension_dir, 'tree') # pylint:disable=unreachable | ||
- for cfg in ('Release', 'Debug'): | ||
- cfg_dir = os.path.join(extension_dir, cfg) | ||
- if os.path.isdir(cfg_dir): | ||
- for f in os.listdir(cfg_dir): | ||
- shutil.move(os.path.join(cfg_dir, f), tree_dir) | ||
- | ||
- | ||
-setuptools.setup( | ||
+setup( | ||
name='dm-tree', | ||
version=_get_tree_version(), | ||
url='https://github.com/deepmind/tree', | ||
@@ -131,11 +54,23 @@ setuptools.setup( | ||
long_description=open(os.path.join(here, 'README.md')).read(), | ||
long_description_content_type='text/markdown', | ||
# Contained modules and scripts. | ||
- packages=setuptools.find_packages(), | ||
+ packages=find_packages(), | ||
tests_require=_parse_requirements('requirements-test.txt'), | ||
test_suite='tree', | ||
- cmdclass=dict(build_ext=BuildCMakeExtension), | ||
- ext_modules=[CMakeExtension('_tree', source_dir='tree')], | ||
+ cmdclass={"build_ext": build_ext}, | ||
+ ext_modules=[ | ||
+ Pybind11Extension( | ||
+ 'tree._tree', | ||
+ sources=['tree/tree.cc'], | ||
+ libraries=[ | ||
+ 'absl_int128', | ||
+ 'absl_raw_hash_set', | ||
+ 'absl_raw_logging_internal', | ||
+ 'absl_strings', | ||
+ 'absl_throw_delegate', | ||
+ ] | ||
+ ) | ||
+ ], | ||
zip_safe=False, | ||
# PyPI package information. | ||
classifiers=[ |