From 8dac4eb1037846e25602b1d6c627c4b9f8c52c4d Mon Sep 17 00:00:00 2001 From: luoxiaoc Date: Fri, 12 Aug 2022 10:56:12 +0800 Subject: [PATCH 1/4] setup sub-project message-infrastructure Signed-off-by: luoxiaoc --- poetry.lock | 16 +- pyproject.toml | 1 + .../message_infrastructure/__init__.py | 0 .../message_infrastructure/poetry.lock | 154 ++++++++++++++++++ .../message_infrastructure/pyproject.toml | 19 +++ .../runtime/message_infrastructure/setup.py | 131 +++++++++++++++ 6 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 src/lava/magma/runtime/message_infrastructure/message_infrastructure/__init__.py create mode 100644 src/lava/magma/runtime/message_infrastructure/poetry.lock create mode 100644 src/lava/magma/runtime/message_infrastructure/pyproject.toml create mode 100644 src/lava/magma/runtime/message_infrastructure/setup.py diff --git a/poetry.lock b/poetry.lock index 8e009ba5f..4f4737dc3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -946,6 +946,19 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "message-infrastructure" +version = "0.1.0" +description = "Message Infrastructure" +category = "main" +optional = false +python-versions = "^3.8" +develop = false + +[package.source] +type = "directory" +url = "src/lava/magma/runtime/message_infrastructure" + [[package]] name = "mistune" version = "0.8.4" @@ -1891,7 +1904,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = ">=3.8, <3.11" -content-hash = "e9009feb56c9f7953c89c0024ed8b6ef69c1229398082456a9771f254327919e" +content-hash = "9eca04289ece2768f9504dc2d74fb925633038a4b728d7a51f3a2a3666b70665" [metadata.files] alabaster = [ @@ -2451,6 +2464,7 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] +message-infrastructure = [] mistune = [ {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, diff --git a/pyproject.toml b/pyproject.toml index 1ba1f8720..067b917f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ networkx = "<=2.8" nbformat = "^5.3.0" nbconvert = "^6.5.0" pandas = "^1.4.2" +message-infrastructure = {path = "src/lava/magma/runtime/message_infrastructure"} [tool.poetry.dev-dependencies] bandit = "1.7.2" diff --git a/src/lava/magma/runtime/message_infrastructure/message_infrastructure/__init__.py b/src/lava/magma/runtime/message_infrastructure/message_infrastructure/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/lava/magma/runtime/message_infrastructure/poetry.lock b/src/lava/magma/runtime/message_infrastructure/poetry.lock new file mode 100644 index 000000000..3bd5dd3af --- /dev/null +++ b/src/lava/magma/runtime/message_infrastructure/poetry.lock @@ -0,0 +1,154 @@ +[[package]] +name = "atomicwrites" +version = "1.4.1" +description = "Atomic file writes." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "attrs" +version = "22.1.0" +description = "Classes Without Boilerplate" +category = "dev" +optional = false +python-versions = ">=3.5" + +[package.extras] +dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] +docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] +tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] +tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "cloudpickle"] + +[[package]] +name = "colorama" +version = "0.4.5" +description = "Cross-platform colored terminal text." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "more-itertools" +version = "8.14.0" +description = "More routines for operating on iterables, beyond itertools" +category = "dev" +optional = false +python-versions = ">=3.5" + +[[package]] +name = "packaging" +version = "21.3" +description = "Core utilities for Python packages" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" + +[[package]] +name = "pluggy" +version = "0.13.1" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.extras] +dev = ["tox", "pre-commit"] + +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "pyparsing" +version = "3.0.9" +description = "pyparsing module - Classes and methods to define and execute parsing grammars" +category = "dev" +optional = false +python-versions = ">=3.6.8" + +[package.extras] +diagrams = ["railroad-diagrams", "jinja2"] + +[[package]] +name = "pytest" +version = "5.4.3" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.5" + +[package.dependencies] +atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} +attrs = ">=17.4.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +more-itertools = ">=4.0.0" +packaging = "*" +pluggy = ">=0.12,<1.0" +py = ">=1.5.0" +wcwidth = "*" + +[package.extras] +checkqa-mypy = ["mypy (==v0.761)"] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] + +[[package]] +name = "wcwidth" +version = "0.2.5" +description = "Measures the displayed width of unicode strings in a terminal" +category = "dev" +optional = false +python-versions = "*" + +[metadata] +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "c27944f25b55067b06883f1cea204be7d97841a4b8228fab69b91895347494ad" + +[metadata.files] +atomicwrites = [ + {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, +] +attrs = [ + {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"}, + {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, +] +colorama = [ + {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, + {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, +] +more-itertools = [ + {file = "more-itertools-8.14.0.tar.gz", hash = "sha256:c09443cd3d5438b8dafccd867a6bc1cb0894389e90cb53d227456b0b0bccb750"}, + {file = "more_itertools-8.14.0-py3-none-any.whl", hash = "sha256:1bc4f91ee5b1b31ac7ceacc17c09befe6a40a503907baf9c839c229b5095cfd2"}, +] +packaging = [ + {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, + {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, +] +pluggy = [ + {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, + {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, +] +py = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] +pyparsing = [ + {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, + {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, +] +pytest = [ + {file = "pytest-5.4.3-py3-none-any.whl", hash = "sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1"}, + {file = "pytest-5.4.3.tar.gz", hash = "sha256:7979331bfcba207414f5e1263b5a0f8f521d0f457318836a7355531ed1a4c7d8"}, +] +wcwidth = [ + {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"}, + {file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"}, +] diff --git a/src/lava/magma/runtime/message_infrastructure/pyproject.toml b/src/lava/magma/runtime/message_infrastructure/pyproject.toml new file mode 100644 index 000000000..6829c5c94 --- /dev/null +++ b/src/lava/magma/runtime/message_infrastructure/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "message_infrastructure" +version = "0.1.0" +description = "Message Infrastructure" +authors = ["Intel's Neuromorphic Computing Lab and the open source community "] +license = "BSD-3-Clause or LGPL-2.1-or-later" + +[tool.poetry.dependencies] +python = "^3.8" + +[tool.poetry.dev-dependencies] +pytest = "^5.2" + +[tool.poetry.build] +script = "setup.py" + +[build-system] +requires = ["poetry-core>=1.0.0", "setuptools>=42", "wheel", "cmake>=3.12"] +build-backend = "poetry.core.masonry.api" diff --git a/src/lava/magma/runtime/message_infrastructure/setup.py b/src/lava/magma/runtime/message_infrastructure/setup.py new file mode 100644 index 000000000..0b2a0aaed --- /dev/null +++ b/src/lava/magma/runtime/message_infrastructure/setup.py @@ -0,0 +1,131 @@ +import os +import re +import subprocess +import sys + +from setuptools import Extension, setup +from setuptools.command.build_ext import build_ext + +# Convert distutils Windows platform specifiers to CMake -A arguments +PLAT_TO_CMAKE = { + "win32": "Win32", + "win-amd64": "x64", + "win-arm32": "ARM", + "win-arm64": "ARM64", +} + + +# A CMakeExtension needs a sourcedir instead of a file list. +# The name must be the _single_ output extension from the CMake build. +# If you need multiple extensions, see scikit-build. +class CMakeExtension(Extension): + def __init__(self, name, sourcedir=""): + Extension.__init__(self, name, sources=[]) + self.sourcedir = os.path.abspath(sourcedir) + + +class CMakeBuild(build_ext): + def build_extension(self, ext): + extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) + + # required for auto-detection & inclusion of auxiliary "native" libs + if not extdir.endswith(os.path.sep): + extdir += os.path.sep + + debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug + cfg = "Debug" if debug else "Release" + + # CMake lets you override the generator - we need to check this. + # Can be set with Conda-Build, for example. + cmake_generator = os.environ.get("CMAKE_GENERATOR", "") + + # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON + # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code + # from Python. + cmake_args = [ + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}", + f"-DPYTHON_EXECUTABLE={sys.executable}", + f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm + ] + build_args = [] + # Adding CMake arguments set as environment variable + # (needed e.g. to build for ARM OSx on conda-forge) + if "CMAKE_ARGS" in os.environ: + cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] + + # In this example, we pass in the version to C++. You might not need to. + cmake_args += [f"-DEXAMPLE_VERSION_INFO={self.distribution.get_version()}"] + + if self.compiler.compiler_type != "msvc": + # Using Ninja-build since it a) is available as a wheel and b) + # multithreads automatically. MSVC would require all variables be + # exported for Ninja to pick it up, which is a little tricky to do. + # Users can override the generator with CMAKE_GENERATOR in CMake + # 3.15+. + if not cmake_generator or cmake_generator == "Ninja": + try: + import ninja # noqa: F401 + + ninja_executable_path = os.path.join(ninja.BIN_DIR, "ninja") + cmake_args += [ + "-GNinja", + f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}", + ] + except ImportError: + pass + + else: + + # Single config generators are handled "normally" + single_config = any(x in cmake_generator for x in {"NMake", "Ninja"}) + + # CMake allows an arch-in-generator style for backward compatibility + contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"}) + + # Specify the arch if using MSVC generator, but only if it doesn't + # contain a backward-compatibility arch spec already in the + # generator name. + if not single_config and not contains_arch: + cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]] + + # Multi-config generators have a different way to specify configs + if not single_config: + cmake_args += [ + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}" + ] + build_args += ["--config", cfg] + + if sys.platform.startswith("darwin"): + # Cross-compile support for macOS - respect ARCHFLAGS if set + archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", "")) + if archs: + cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] + + # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level + # across all generators. + if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: + # self.parallel is a Python 3 only way to set parallel jobs by hand + # using -j in the build_ext call, not supported by pip or PyPA-build. + if hasattr(self, "parallel") and self.parallel: + # CMake 3.12+ only. + build_args += [f"-j{self.parallel}"] + + build_temp = os.path.join(self.build_temp, ext.name) + if not os.path.exists(build_temp): + os.makedirs(build_temp) + + subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=build_temp) + subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=build_temp) + + +# The information here can also be placed in setup.cfg - better separation of +# logic and declaration, and simpler if you include description/version in a file. +setup( + name="MessageInfrastructurePywrapper", + version="0.0.1", + ext_modules=[CMakeExtension("MessageInfrastructurePywrapper")], + cmdclass={"build_ext": CMakeBuild}, + zip_safe=False, + extras_require={"test": ["pytest>=5.2"]}, + python_requires=">=3.8", +) From 2becd34310575b2eedb484ede918f8d3cb32509e Mon Sep 17 00:00:00 2001 From: luoxiaoc Date: Fri, 12 Aug 2022 11:25:12 +0800 Subject: [PATCH 2/4] install pybind11 by poetry Signed-off-by: luoxiaoc --- .gitmodules | 3 -- poetry.lock | 33 +++++++++++++++++++ .../message_infrastructure/CMakeLists.txt | 2 +- .../message_infrastructure/poetry.lock | 32 +++++++++++++++++- .../runtime/message_infrastructure/pybind11 | 1 - .../message_infrastructure/pyproject.toml | 1 + 6 files changed, 66 insertions(+), 6 deletions(-) delete mode 160000 src/lava/magma/runtime/message_infrastructure/pybind11 diff --git a/.gitmodules b/.gitmodules index 856e46166..e11057ce3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "docs"] path = docs url = https://github.com/lava-nc/lava-docs.git -[submodule "src/lava/magma/runtime/message_infrastructure/pybind11"] - path = src/lava/magma/runtime/message_infrastructure/pybind11 - url = https://github.com/pybind/pybind11.git diff --git a/poetry.lock b/poetry.lock index 4f4737dc3..498edec91 100644 --- a/poetry.lock +++ b/poetry.lock @@ -955,6 +955,9 @@ optional = false python-versions = "^3.8" develop = false +[package.dependencies] +pybind11 = {version = "^2.10.0", extras = ["global"]} + [package.source] type = "directory" url = "src/lava/magma/runtime/message_infrastructure" @@ -1303,6 +1306,28 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "pybind11" +version = "2.10.0" +description = "Seamless operability between C++11 and Python" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +pybind11-global = {version = "2.10.0", optional = true, markers = "extra == \"global\""} + +[package.extras] +global = ["pybind11-global (==2.10.0)"] + +[[package]] +name = "pybind11-global" +version = "2.10.0" +description = "Seamless operability between C++11 and Python" +category = "main" +optional = false +python-versions = ">=3.6" + [[package]] name = "pycodestyle" version = "2.8.0" @@ -2732,6 +2757,14 @@ py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] +pybind11 = [ + {file = "pybind11-2.10.0-py3-none-any.whl", hash = "sha256:6bbc7a2f79689307f0d8d240172851955fc214b33e4cbd7fdbc9cd7176a09260"}, + {file = "pybind11-2.10.0.tar.gz", hash = "sha256:18977589c10f595f65ec1be90b0a0763b43e458d25d97be9db75b958eb1f43fe"}, +] +pybind11-global = [ + {file = "pybind11_global-2.10.0-py3-none-any.whl", hash = "sha256:362c041a8251089013227e968f90fb53e8a7dcf88f9eb2507f5e459ddb3baa3f"}, + {file = "pybind11_global-2.10.0.tar.gz", hash = "sha256:dd063cd36557c2204f529564ce3e55f7941bcdc554782cec3250704a07766bf0"}, +] pycodestyle = [ {file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"}, {file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"}, diff --git a/src/lava/magma/runtime/message_infrastructure/CMakeLists.txt b/src/lava/magma/runtime/message_infrastructure/CMakeLists.txt index 8ebcb4d1e..83bd84834 100644 --- a/src/lava/magma/runtime/message_infrastructure/CMakeLists.txt +++ b/src/lava/magma/runtime/message_infrastructure/CMakeLists.txt @@ -8,7 +8,7 @@ file (GLOB MULTI_PROC_SRCS "message_infrastructure/csrc/multiprocessing.cc") file (GLOB PY_WRAPPER "message_infrastructure/csrc/message_infrastructure_py_wrapper.cc") -add_subdirectory(pybind11) +find_package(pybind11 CONFIG) add_library(multi_processing SHARED ${MULTI_PROC_SRCS}) diff --git a/src/lava/magma/runtime/message_infrastructure/poetry.lock b/src/lava/magma/runtime/message_infrastructure/poetry.lock index 3bd5dd3af..8790ecf1b 100644 --- a/src/lava/magma/runtime/message_infrastructure/poetry.lock +++ b/src/lava/magma/runtime/message_infrastructure/poetry.lock @@ -66,6 +66,28 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "pybind11" +version = "2.10.0" +description = "Seamless operability between C++11 and Python" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +pybind11-global = {version = "2.10.0", optional = true, markers = "extra == \"global\""} + +[package.extras] +global = ["pybind11-global (==2.10.0)"] + +[[package]] +name = "pybind11-global" +version = "2.10.0" +description = "Seamless operability between C++11 and Python" +category = "main" +optional = false +python-versions = ">=3.6" + [[package]] name = "pyparsing" version = "3.0.9" @@ -110,7 +132,7 @@ python-versions = "*" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "c27944f25b55067b06883f1cea204be7d97841a4b8228fab69b91895347494ad" +content-hash = "ac58973fd8bb5760f9da3ff6174e090f5ff80c5ad90fb37d0a04ffbd4396ccef" [metadata.files] atomicwrites = [ @@ -140,6 +162,14 @@ py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] +pybind11 = [ + {file = "pybind11-2.10.0-py3-none-any.whl", hash = "sha256:6bbc7a2f79689307f0d8d240172851955fc214b33e4cbd7fdbc9cd7176a09260"}, + {file = "pybind11-2.10.0.tar.gz", hash = "sha256:18977589c10f595f65ec1be90b0a0763b43e458d25d97be9db75b958eb1f43fe"}, +] +pybind11-global = [ + {file = "pybind11_global-2.10.0-py3-none-any.whl", hash = "sha256:362c041a8251089013227e968f90fb53e8a7dcf88f9eb2507f5e459ddb3baa3f"}, + {file = "pybind11_global-2.10.0.tar.gz", hash = "sha256:dd063cd36557c2204f529564ce3e55f7941bcdc554782cec3250704a07766bf0"}, +] pyparsing = [ {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, diff --git a/src/lava/magma/runtime/message_infrastructure/pybind11 b/src/lava/magma/runtime/message_infrastructure/pybind11 deleted file mode 160000 index ba5ccd845..000000000 --- a/src/lava/magma/runtime/message_infrastructure/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ba5ccd845a2261e538df651e3d528dc1bece094d diff --git a/src/lava/magma/runtime/message_infrastructure/pyproject.toml b/src/lava/magma/runtime/message_infrastructure/pyproject.toml index 6829c5c94..3448e2aad 100644 --- a/src/lava/magma/runtime/message_infrastructure/pyproject.toml +++ b/src/lava/magma/runtime/message_infrastructure/pyproject.toml @@ -7,6 +7,7 @@ license = "BSD-3-Clause or LGPL-2.1-or-later" [tool.poetry.dependencies] python = "^3.8" +pybind11 = {extras = ["global"], version = "^2.10.0"} [tool.poetry.dev-dependencies] pytest = "^5.2" From 75681c85a512dff66580a085c91b7113d5dba1d8 Mon Sep 17 00:00:00 2001 From: luoxiaoc Date: Fri, 12 Aug 2022 12:17:54 +0800 Subject: [PATCH 3/4] fix lint fails Signed-off-by: luoxiaoc --- .../runtime/message_infrastructure/setup.py | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/lava/magma/runtime/message_infrastructure/setup.py b/src/lava/magma/runtime/message_infrastructure/setup.py index 0b2a0aaed..ed38746b7 100644 --- a/src/lava/magma/runtime/message_infrastructure/setup.py +++ b/src/lava/magma/runtime/message_infrastructure/setup.py @@ -26,13 +26,15 @@ def __init__(self, name, sourcedir=""): class CMakeBuild(build_ext): def build_extension(self, ext): - extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) + extdir = os.path.abspath( + os.path.dirname(self.get_ext_fullpath(ext.name))) # required for auto-detection & inclusion of auxiliary "native" libs if not extdir.endswith(os.path.sep): extdir += os.path.sep - debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug + debug = int( + os.environ.get("DEBUG", 0)) if self.debug is None else self.debug cfg = "Debug" if debug else "Release" # CMake lets you override the generator - we need to check this. @@ -51,10 +53,12 @@ def build_extension(self, ext): # Adding CMake arguments set as environment variable # (needed e.g. to build for ARM OSx on conda-forge) if "CMAKE_ARGS" in os.environ: - cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] + cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") + if item] # In this example, we pass in the version to C++. You might not need to. - cmake_args += [f"-DEXAMPLE_VERSION_INFO={self.distribution.get_version()}"] + cmake_args += [ + f"-DEXAMPLE_VERSION_INFO={self.distribution.get_version()}"] if self.compiler.compiler_type != "msvc": # Using Ninja-build since it a) is available as a wheel and b) @@ -69,7 +73,7 @@ def build_extension(self, ext): ninja_executable_path = os.path.join(ninja.BIN_DIR, "ninja") cmake_args += [ "-GNinja", - f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}", + f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}" ] except ImportError: pass @@ -77,7 +81,8 @@ def build_extension(self, ext): else: # Single config generators are handled "normally" - single_config = any(x in cmake_generator for x in {"NMake", "Ninja"}) + single_config = any( + x in cmake_generator for x in {"NMake", "Ninja"}) # CMake allows an arch-in-generator style for backward compatibility contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"}) @@ -99,13 +104,15 @@ def build_extension(self, ext): # Cross-compile support for macOS - respect ARCHFLAGS if set archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", "")) if archs: - cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] + cmake_args += [ + "-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level # across all generators. if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: # self.parallel is a Python 3 only way to set parallel jobs by hand - # using -j in the build_ext call, not supported by pip or PyPA-build. + # using -j in the build_ext call, + # not supported by pip or PyPA-build. if hasattr(self, "parallel") and self.parallel: # CMake 3.12+ only. build_args += [f"-j{self.parallel}"] @@ -114,12 +121,15 @@ def build_extension(self, ext): if not os.path.exists(build_temp): os.makedirs(build_temp) - subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=build_temp) - subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=build_temp) + subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, + cwd=build_temp, shell=True) + subprocess.check_call(["cmake", "--build", "."] + build_args, + cwd=build_temp, shell=True) # The information here can also be placed in setup.cfg - better separation of -# logic and declaration, and simpler if you include description/version in a file. +# logic and declaration, +# and simpler if you include description/version in a file. setup( name="MessageInfrastructurePywrapper", version="0.0.1", From 2fa47976a657611d90d23c5a302f92f03c34ce83 Mon Sep 17 00:00:00 2001 From: luoxiaoc Date: Fri, 12 Aug 2022 13:10:37 +0800 Subject: [PATCH 4/4] add skip annotating at setup.py Signed-off-by: luoxiaoc --- src/lava/magma/runtime/message_infrastructure/setup.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lava/magma/runtime/message_infrastructure/setup.py b/src/lava/magma/runtime/message_infrastructure/setup.py index ed38746b7..81d88d197 100644 --- a/src/lava/magma/runtime/message_infrastructure/setup.py +++ b/src/lava/magma/runtime/message_infrastructure/setup.py @@ -1,6 +1,6 @@ import os import re -import subprocess +import subprocess # nosec import sys from setuptools import Extension, setup @@ -121,10 +121,8 @@ def build_extension(self, ext): if not os.path.exists(build_temp): os.makedirs(build_temp) - subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, - cwd=build_temp, shell=True) - subprocess.check_call(["cmake", "--build", "."] + build_args, - cwd=build_temp, shell=True) + subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=build_temp) # nosec # noqa + subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=build_temp) # nosec # noqa # The information here can also be placed in setup.cfg - better separation of