From 01e7576315dc08026d26f901bce80391c8a93f61 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Fri, 3 Feb 2023 14:02:34 -0500 Subject: [PATCH 01/14] Run black -l 100 on: - .github/workflows/dev_version_script.py - .github/workflows/vb_script.py - bin/utils.py - doc/conf.py - setup.py --- .github/workflows/dev_version_script.py | 39 ++++++++------ .github/workflows/vb_script.py | 67 ++++++++++++++++--------- bin/utils.py | 18 ++++--- doc/conf.py | 12 +++-- setup.py | 36 +++++++------ 5 files changed, 104 insertions(+), 68 deletions(-) diff --git a/.github/workflows/dev_version_script.py b/.github/workflows/dev_version_script.py index 82d47e6656..f7ab794b26 100644 --- a/.github/workflows/dev_version_script.py +++ b/.github/workflows/dev_version_script.py @@ -17,61 +17,68 @@ import re -VERSION_FILE_PATH = 'pennylane_lightning/_version.py' +VERSION_FILE_PATH = "pennylane_lightning/_version.py" -rgx_ver = re.compile('^__version__ = \"(.*?)\"$') +rgx_ver = re.compile('^__version__ = "(.*?)"$') + +rgx_dev_ver = re.compile("^(\d*\.\d*\.\d*)-dev(\d*)$") -rgx_dev_ver = re.compile('^(\d*\.\d*\.\d*)-dev(\d*)$') def extract_version(package_path): - with package_path.joinpath(VERSION_FILE_PATH).open('r') as f: + with package_path.joinpath(VERSION_FILE_PATH).open("r") as f: for line in f.readlines(): - if line.startswith('__version__'): + if line.startswith("__version__"): line = line.strip() m = rgx_ver.match(line) return m.group(1) raise ValueError("Cannot parse version") + def is_dev(version_str): m = rgx_dev_ver.fullmatch(version_str) return m is not None + def update_dev_version(package_path, version_str): m = rgx_dev_ver.fullmatch(version_str) - if m.group(2) == '': + if m.group(2) == "": curr_dev_ver = 0 else: curr_dev_ver = int(m.group(2)) - new_version_str = '{}-dev{}'.format(m.group(1), str(curr_dev_ver + 1)) + new_version_str = "{}-dev{}".format(m.group(1), str(curr_dev_ver + 1)) lines = [] - with package_path.joinpath(VERSION_FILE_PATH).open('r') as f: + with package_path.joinpath(VERSION_FILE_PATH).open("r") as f: for line in f.readlines(): - if not line.startswith('__version__'): + if not line.startswith("__version__"): lines.append(line) else: - lines.append(f'__version__ = \"{new_version_str}\"\n') + lines.append(f'__version__ = "{new_version_str}"\n') - with package_path.joinpath(VERSION_FILE_PATH).open('w') as f: - f.write(''.join(lines)) + with package_path.joinpath(VERSION_FILE_PATH).open("w") as f: + f.write("".join(lines)) if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("--pr-path", dest = "pr", type=str, required=True, help="Path to the PR dir") - parser.add_argument("--master-path", dest = "master", type=str, required=True, help="Path to the master dir") + parser.add_argument("--pr-path", dest="pr", type=str, required=True, help="Path to the PR dir") + parser.add_argument( + "--master-path", dest="master", type=str, required=True, help="Path to the master dir" + ) args = parser.parse_args() pr_version = extract_version(Path(args.pr)) master_version = extract_version(Path(args.master)) - + if pr_version == master_version: if is_dev(pr_version): print("Automatically update version string.") update_dev_version(Path(args.pr), pr_version) else: - print("Even though version of this PR is different from the master, as the PR is not dev, we do nothing.") + print( + "Even though version of this PR is different from the master, as the PR is not dev, we do nothing." + ) else: print("Version of this PR is already different from master. Do nothing.") diff --git a/.github/workflows/vb_script.py b/.github/workflows/vb_script.py index 722cb31add..2595bfd850 100644 --- a/.github/workflows/vb_script.py +++ b/.github/workflows/vb_script.py @@ -13,20 +13,21 @@ # limitations under the License. import argparse import pennylane as qml + pl_version = '"' + qml.version() + '"' def remove_quotes(my_str): - """ A helper function to remove the quote chars (',") + """A helper function to remove the quote chars (',") from the provided str. """ - clean_str = my_str.replace('"', '') # remove " + clean_str = my_str.replace('"', "") # remove " clean_str = clean_str.replace("'", "") # remove ' return clean_str def bump_version(version_line, pre_release): - """ A helper function which takes the current version string and + """A helper function which takes the current version string and replaces it with the bumped version depending on the pre/post release flag. @@ -42,16 +43,20 @@ def bump_version(version_line, pre_release): bumped_version (string): The bumped version string. """ data = version_line.split(" ") - curr_version = data[-1].replace('\n', '') # remove any newline characters + curr_version = data[-1].replace("\n", "") # remove any newline characters if pre_release: curr_version = pl_version # get current Pennylane version split_version = curr_version.split(".") # "0.17.0" --> ["0,17,0"] - split_version[1] = str(int(split_version[1]) + 1) # take middle value and cast as int and bump it by 1 + split_version[1] = str( + int(split_version[1]) + 1 + ) # take middle value and cast as int and bump it by 1 if not pre_release: - split_version[2] = split_version[2].replace('"', '-dev"') # add -dev, ["0,18,0"] --> ["0,18,0-dev"] + split_version[2] = split_version[2].replace( + '"', '-dev"' + ) # add -dev, ["0,18,0"] --> ["0,18,0-dev"] bumped_version = ".".join(split_version) data[-1] = bumped_version @@ -61,7 +66,7 @@ def bump_version(version_line, pre_release): def update_version_file(path, pre_release=True): - """ Updates the __version__ attribute in a specific version file. + """Updates the __version__ attribute in a specific version file. Args: path (str): The path to the version file. @@ -71,21 +76,21 @@ def update_version_file(path, pre_release=True): Return: new_version (str): The bumped version string. """ - with open(path, 'r', encoding="utf8") as f: + with open(path, "r", encoding="utf8") as f: lines = f.readlines() - with open(path, 'w', encoding="utf8") as f: + with open(path, "w", encoding="utf8") as f: for line in lines: - if "__version__" in line.split(' '): + if "__version__" in line.split(" "): new_line, new_version = bump_version(line, pre_release) - f.write(new_line + '\n') + f.write(new_line + "\n") else: f.write(line) return new_version def remove_empty_headers(lines): - """ Takes a paragraph (list of strings) and removes sections which are empty. + """Takes a paragraph (list of strings) and removes sections which are empty. Where a section begins with a header (### Header_Title). Args: @@ -109,20 +114,20 @@ def remove_empty_headers(lines): pntr1 = pntr2 is_empty = True # reset the empty flag - elif line2 == '\n': + elif line2 == "\n": pass else: is_empty = False - cleaned_lines.extend(lines[pntr1:pntr1+1]) + cleaned_lines.extend(lines[pntr1 : pntr1 + 1]) pntr1 += 1 return cleaned_lines def update_changelog(path, new_version, pre_release=True): - """ Updates the Changelog file depending on whether it's a pre-release + """Updates the Changelog file depending on whether it's a pre-release or post-release version bump. Args: @@ -131,7 +136,7 @@ def update_changelog(path, new_version, pre_release=True): pre_release (bool): A flag which determines if this is a pre-release or post-release version bump. """ - with open(path, 'r', encoding="utf8") as f: + with open(path, "r", encoding="utf8") as f: lines = f.readlines() end_of_section_index = 0 for index, line in enumerate(lines): @@ -139,11 +144,13 @@ def update_changelog(path, new_version, pre_release=True): end_of_section_index = index break - with open(path, 'w', encoding="utf8") as f: + with open(path, "w", encoding="utf8") as f: if not pre_release: # post_release append template to top of the changelog - with open("./.github/workflows/changelog_template.txt", 'r', encoding="utf8") as template_f: + with open( + "./.github/workflows/changelog_template.txt", "r", encoding="utf8" + ) as template_f: template_lines = template_f.readlines() - template_lines[0] = template_lines[0].replace('x.x.x-dev', new_version) + template_lines[0] = template_lines[0].replace("x.x.x-dev", new_version) f.writelines(template_lines) f.writelines(lines) @@ -152,7 +159,7 @@ def update_changelog(path, new_version, pre_release=True): line = lines[0] split_line = line.split(" ") split_line[-1] = new_version # replace version (split_line = [#, Release, 0.17.0-dev]) - new_line = " ".join(split_line) + '\n' + new_line = " ".join(split_line) + "\n" f.write(new_line) # remover empty headers @@ -166,12 +173,22 @@ def update_changelog(path, new_version, pre_release=True): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("--version_path", type=str, required=True, help="Path to the _version.py file") + parser.add_argument( + "--version_path", type=str, required=True, help="Path to the _version.py file" + ) parser.add_argument("--changelog_path", type=str, required=True, help="Path to the changelog") - parser.add_argument("--pre_release", dest="release_status", action="store_true", - help="True if this is a pre-release version bump, False if it is post release") - parser.add_argument("--post_release", dest="release_status", action="store_false", - help="True if this is a pre-release version bump, False if it is post release") + parser.add_argument( + "--pre_release", + dest="release_status", + action="store_true", + help="True if this is a pre-release version bump, False if it is post release", + ) + parser.add_argument( + "--post_release", + dest="release_status", + action="store_false", + help="True if this is a pre-release version bump, False if it is post release", + ) args = parser.parse_args() updated_version = update_version_file(args.version_path, args.release_status) diff --git a/bin/utils.py b/bin/utils.py index 6834078976..f33bf6a159 100644 --- a/bin/utils.py +++ b/bin/utils.py @@ -9,17 +9,18 @@ rgx_gitignore_comment = re_compile("#.*$") -def get_cpp_files_from_path(path, ignore_patterns = None, use_gitignore = True, header_only = False): + +def get_cpp_files_from_path(path, ignore_patterns=None, use_gitignore=True, header_only=False): """return set of C++ source files from a path Args: - paths (pathlib.Path or str): a path to process + paths (pathlib.Path or str): a path to process ignore_patterns: patterns to ignore use_gitignore: find ignore patterns from .gitignore header_only: find only header files when true """ path = Path(path) - files_rel = set() # file paths relative to path + files_rel = set() # file paths relative to path exts = HEADERFILE_EXT if not header_only: @@ -33,15 +34,15 @@ def get_cpp_files_from_path(path, ignore_patterns = None, use_gitignore = True, if use_gitignore: # simple gitignore parser - gitignore_file = path.joinpath('.gitignore') + gitignore_file = path.joinpath(".gitignore") if gitignore_file.exists(): with gitignore_file.open() as f: for line in f.readlines(): - line = rgx_gitignore_comment.sub('', line) + line = rgx_gitignore_comment.sub("", line) line = line.strip() if line: ignore_patterns.append(line) - + files_to_remove = set() for ignore_pattern in ignore_patterns: for f in files_rel: @@ -51,8 +52,9 @@ def get_cpp_files_from_path(path, ignore_patterns = None, use_gitignore = True, files_rel -= files_to_remove return set(str(path.joinpath(f)) for f in files_rel) - -def get_cpp_files(paths, ignore_patterns = None, use_gitignore = True, header_only = False): + + +def get_cpp_files(paths, ignore_patterns=None, use_gitignore=True, header_only=False): """return list of C++ source files from paths. Args: diff --git a/doc/conf.py b/doc/conf.py index 7a78043867..6ce30e22e2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -105,7 +105,9 @@ def __getattr__(cls, name): breathe_projects = {"Lightning-Qubit": "./doxyoutput/xml"} breathe_default_project = "Lightning-Qubit" -mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" +mathjax_path = ( + "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" +) # Exhale extension # Setup the exhale extension @@ -130,6 +132,7 @@ def __getattr__(cls, name): # Add any paths that contain templates here, relative to this directory. from pennylane_sphinx_theme import templates_dir + templates_path = [templates_dir()] # The suffix(es) of source filenames. @@ -197,7 +200,7 @@ def __getattr__(cls, name): html_static_path = ["_static"] html_css_files = [ - 'css/custom.css', + "css/custom.css", ] # -- html theme --------------------------------------------------------- @@ -209,10 +212,9 @@ def __getattr__(cls, name): "navbar_active_link": 3, "google_analytics_tracking_id": "UA-130507810-1", "extra_copyrights": [ - "TensorFlow, the TensorFlow logo, and any related marks are trademarks " - "of Google Inc." + "TensorFlow, the TensorFlow logo, and any related marks are trademarks " "of Google Inc." ], - "toc_overview": True + "toc_overview": True, } edit_on_github_project = "PennyLaneAI/pennylane-lightning" diff --git a/setup.py b/setup.py index be99550330..c3204ea85c 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ from setuptools import setup, Extension, find_packages from setuptools.command.build_ext import build_ext + class CMakeExtension(Extension): def __init__(self, name, sourcedir=""): Extension.__init__(self, name, sources=[]) @@ -53,8 +54,8 @@ def build_extension(self, ext: CMakeExtension): # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON configure_args = [ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}", - f"-DPython_EXECUTABLE={sys.executable}", # (Windows) - f"-DPYTHON_EXECUTABLE={sys.executable}", # (Ubuntu) + f"-DPython_EXECUTABLE={sys.executable}", # (Windows) + f"-DPYTHON_EXECUTABLE={sys.executable}", # (Ubuntu) "-DENABLE_WARNINGS=OFF", # Ignore warnings ] @@ -82,17 +83,19 @@ def build_extension(self, ext: CMakeExtension): # Add more platform dependent options if platform.system() == "Darwin": - #To support ARM64 - if os.getenv('ARCHS') == "arm64": - configure_args += ["-DCMAKE_CXX_COMPILER_TARGET=arm64-apple-macos11", - "-DCMAKE_SYSTEM_NAME=Darwin", - "-DCMAKE_SYSTEM_PROCESSOR=ARM64"] - else: # X64 arch + # To support ARM64 + if os.getenv("ARCHS") == "arm64": + configure_args += [ + "-DCMAKE_CXX_COMPILER_TARGET=arm64-apple-macos11", + "-DCMAKE_SYSTEM_NAME=Darwin", + "-DCMAKE_SYSTEM_PROCESSOR=ARM64", + ] + else: # X64 arch llvmpath = subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip() configure_args += [ - f"-DCMAKE_CXX_COMPILER={llvmpath}/bin/clang++", - f"-DCMAKE_LINKER={llvmpath}/bin/lld", - ] # Use clang instead of appleclang + f"-DCMAKE_CXX_COMPILER={llvmpath}/bin/clang++", + f"-DCMAKE_LINKER={llvmpath}/bin/lld", + ] # Use clang instead of appleclang # Disable OpenMP in M1 Macs if os.environ.get("USE_OMP"): configure_args += [] @@ -108,7 +111,10 @@ def build_extension(self, ext: CMakeExtension): os.makedirs(self.build_temp) subprocess.check_call(["cmake", str(ext.sourcedir)] + configure_args, cwd=self.build_temp) - subprocess.check_call(["cmake", "--build", ".", "--verbose"] + build_args, cwd=self.build_temp) + subprocess.check_call( + ["cmake", "--build", ".", "--verbose"] + build_args, cwd=self.build_temp + ) + with open(os.path.join("pennylane_lightning", "_version.py")) as f: version = f.readlines()[-1].split()[-1].strip("\"'") @@ -126,7 +132,9 @@ def build_extension(self, ext: CMakeExtension): "url": "https://github.com/XanaduAI/pennylane-lightning", "license": "Apache License 2.0", "packages": find_packages(where="."), - "package_data": {"pennylane_lightning": [os.path.join("src", "*"), os.path.join("src", "**", "*")]}, + "package_data": { + "pennylane_lightning": [os.path.join("src", "*"), os.path.join("src", "**", "*")] + }, "include_package_data": True, "entry_points": { "pennylane.plugins": [ @@ -143,7 +151,7 @@ def build_extension(self, ext: CMakeExtension): else [], "cmdclass": {"build_ext": CMakeBuild}, "ext_package": "pennylane_lightning", - "extras_require": {"gpu" : ["pennylane-lightning-gpu"]} + "extras_require": {"gpu": ["pennylane-lightning-gpu"]}, } classifiers = [ From c0819249584e9dfeec5ceab75cf97aef942c7600 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Fri, 3 Feb 2023 14:04:13 -0500 Subject: [PATCH 02/14] Add LLVM_ROOT_DIR variable that allows specifying a custom llvm path on Darwin systems. --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c3204ea85c..9180fefe1b 100644 --- a/setup.py +++ b/setup.py @@ -91,7 +91,11 @@ def build_extension(self, ext: CMakeExtension): "-DCMAKE_SYSTEM_PROCESSOR=ARM64", ] else: # X64 arch - llvmpath = subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip() + llvmpath = os.environ.get("LLVM_ROOT_DIR") + if llvmpath is None: + llvmpath = ( + subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip() + ) configure_args += [ f"-DCMAKE_CXX_COMPILER={llvmpath}/bin/clang++", f"-DCMAKE_LINKER={llvmpath}/bin/lld", From 7f09d3d5a6694ddfe6da355b0234c1cbc02969f7 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Fri, 3 Feb 2023 14:09:08 -0500 Subject: [PATCH 03/14] Fix a couple typos in README file. --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 3fce0afcc7..8e08bc8b63 100644 --- a/README.rst +++ b/README.rst @@ -95,7 +95,7 @@ You can also pass ``cmake`` options with ``build_ext``: $ python3 setup.py build_ext -i --define="ENABLE_OPENMP=OFF;ENABLE_NATIVE=ON" -and install the compilied library with +and install the compiled library with .. code-block:: console @@ -202,7 +202,7 @@ Contributing We welcome contributions - simply fork the repository of this plugin, and then make a `pull request `_ containing your contribution. -All contributers to this plugin will be listed as authors on the releases. +All contributors to this plugin will be listed as authors on the releases. We also encourage bug reports, suggestions for new features and enhancements, and even links to cool projects or applications built on PennyLane. From 728efa0babef4a02349179eb00239892c01630f5 Mon Sep 17 00:00:00 2001 From: Dev version update bot Date: Fri, 3 Feb 2023 19:28:05 +0000 Subject: [PATCH 04/14] Auto update version --- pennylane_lightning/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/_version.py b/pennylane_lightning/_version.py index 6052145646..4784f68305 100644 --- a/pennylane_lightning/_version.py +++ b/pennylane_lightning/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.29.0-dev5" +__version__ = "0.29.0-dev6" From 5db93c517b788b7e9f6872457839d53565687a62 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Fri, 3 Feb 2023 17:15:37 -0500 Subject: [PATCH 05/14] Update doc/conf.py Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com> --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 6ce30e22e2..d9d5e0cc3d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -212,7 +212,7 @@ def __getattr__(cls, name): "navbar_active_link": 3, "google_analytics_tracking_id": "UA-130507810-1", "extra_copyrights": [ - "TensorFlow, the TensorFlow logo, and any related marks are trademarks " "of Google Inc." + "TensorFlow, the TensorFlow logo, and any related marks are trademarks of Google Inc." ], "toc_overview": True, } From f117379842d0020e3498848daf5952e92b2ae08d Mon Sep 17 00:00:00 2001 From: Dev version update bot Date: Fri, 3 Feb 2023 22:15:57 +0000 Subject: [PATCH 06/14] Auto update version --- pennylane_lightning/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/_version.py b/pennylane_lightning/_version.py index 4784f68305..caaa8b541b 100644 --- a/pennylane_lightning/_version.py +++ b/pennylane_lightning/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.29.0-dev6" +__version__ = "0.29.0-dev7" From fafb5fbfe52c18308defc56099b9ada21bd1e890 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Fri, 3 Feb 2023 17:19:17 -0500 Subject: [PATCH 07/14] Update changelog --- .github/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 94e8213f55..16eb5737a4 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -12,6 +12,9 @@ * Remove explicit Numpy and Scipy requirements. [(#412)](https://github.com/PennyLaneAI/pennylane-lightning/pull/412) +* Get `llvm` installation root from the environment variable `LLVM_ROOT_DIR` (or fallback to `brew`). +[(#413)](https://github.com/PennyLaneAI/pennylane-lightning/pull/413) + ### Documentation ### Bug fixes @@ -21,7 +24,7 @@ ### Contributors -Amintor Dusko, Lee James O'Riordan, Chae-Yeun Park +Amintor Dusko, Lee James O'Riordan, Chae-Yeun Park, Vincent Michaud-Rioux --- From 013b7c8c51138175fe9307ec00d231d6f150f590 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Mon, 6 Feb 2023 08:52:12 -0500 Subject: [PATCH 08/14] Trigger CI. From 757fb91146a7b899f01a18204f252e12c1459e34 Mon Sep 17 00:00:00 2001 From: Dev version update bot Date: Mon, 6 Feb 2023 20:55:18 +0000 Subject: [PATCH 09/14] Auto update version --- pennylane_lightning/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/_version.py b/pennylane_lightning/_version.py index 143a7c36ed..e0b04f640b 100644 --- a/pennylane_lightning/_version.py +++ b/pennylane_lightning/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.29.0-dev8" +__version__ = "0.29.0-dev9" From f63c5fee81f1ef4b565a58ddf68894639ec7ddfd Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Tue, 7 Feb 2023 08:32:04 -0500 Subject: [PATCH 10/14] Update .github/CHANGELOG.md Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com> --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 97db77e6f2..2832834cda 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -33,7 +33,7 @@ ### Contributors -Amintor Dusko, Lee James O'Riordan, Chae-Yeun Park, Vincent Michaud-Rioux +Amintor Dusko, Vincent Michaud-Rioux, Lee James O'Riordan, Chae-Yeun Park --- From 69900a635df12d53269c60e026b35a7238e08062 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Tue, 7 Feb 2023 10:16:47 -0500 Subject: [PATCH 11/14] If brew not found, find path using which clang++. --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4ff2d8df24..b7cb02d584 100644 --- a/setup.py +++ b/setup.py @@ -92,11 +92,14 @@ def build_extension(self, ext: CMakeExtension): "-DCMAKE_SYSTEM_PROCESSOR=ARM64", ] else: # X64 arch - llvmpath = os.environ.get("LLVM_ROOT_DIR") - if llvmpath is None: + brewpath = shutil.which("brew") + if brewpath: llvmpath = ( subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip() ) + else: + llvmpath = shutil.which("clang++") + llvmpath = Path(llvmpath).parent.parent configure_args += [ f"-DCMAKE_CXX_COMPILER={llvmpath}/bin/clang++", f"-DCMAKE_LINKER={llvmpath}/bin/lld", From f7f38366ef02ac024192dabd503f91ff8eeb2d3e Mon Sep 17 00:00:00 2001 From: Dev version update bot Date: Tue, 7 Feb 2023 19:31:09 +0000 Subject: [PATCH 12/14] Auto update version --- pennylane_lightning/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/_version.py b/pennylane_lightning/_version.py index e0b04f640b..e7b9c36e20 100644 --- a/pennylane_lightning/_version.py +++ b/pennylane_lightning/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.29.0-dev9" +__version__ = "0.29.0-dev10" From b3a6791c8d9620c8ac16b0a36181a2443e1ed007 Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Tue, 14 Feb 2023 14:17:27 -0500 Subject: [PATCH 13/14] Remove tmp var brewpath and merge few elseif clauses. --- setup.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index b7cb02d584..91c6aa8765 100644 --- a/setup.py +++ b/setup.py @@ -65,12 +65,11 @@ def build_extension(self, ext: CMakeExtension): configure_args += [ "-T clangcl", ] - else: - if ninja_path: - configure_args += [ - "-GNinja", - f"-DCMAKE_MAKE_PROGRAM={ninja_path}", - ] + elif ninja_path: + configure_args += [ + "-GNinja", + f"-DCMAKE_MAKE_PROGRAM={ninja_path}", + ] build_args = [] @@ -92,8 +91,7 @@ def build_extension(self, ext: CMakeExtension): "-DCMAKE_SYSTEM_PROCESSOR=ARM64", ] else: # X64 arch - brewpath = shutil.which("brew") - if brewpath: + if shutil.which("brew"): llvmpath = ( subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip() ) @@ -105,15 +103,11 @@ def build_extension(self, ext: CMakeExtension): f"-DCMAKE_LINKER={llvmpath}/bin/lld", ] # Use clang instead of appleclang # Disable OpenMP in M1 Macs - if os.environ.get("USE_OMP"): - configure_args += [] - else: - configure_args += ["-DENABLE_OPENMP=OFF"] + configure_args += [] if os.environ.get("USE_OMP") else ["-DENABLE_OPENMP=OFF"] elif platform.system() == "Windows": configure_args += ["-DENABLE_OPENMP=OFF", "-DENABLE_BLAS=OFF"] - else: - if platform.system() != "Linux": - raise RuntimeError(f"Unsupported '{platform.system()}' platform") + elif platform.system() != "Linux": + raise RuntimeError(f"Unsupported '{platform.system()}' platform") if not Path(self.build_temp).exists(): os.makedirs(self.build_temp) From f5d31960b1e3e5b54902979d8ed7a20a391db867 Mon Sep 17 00:00:00 2001 From: Dev version update bot Date: Tue, 21 Feb 2023 22:48:26 +0000 Subject: [PATCH 14/14] Auto update version --- pennylane_lightning/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/_version.py b/pennylane_lightning/_version.py index e7b9c36e20..18af774154 100644 --- a/pennylane_lightning/_version.py +++ b/pennylane_lightning/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.29.0-dev10" +__version__ = "0.29.0-dev11"