Skip to content

Commit

Permalink
Improve Wheel Building Process (#55)
Browse files Browse the repository at this point in the history
- Pruned directories from external submodules in MANIFEST.in to reduce size of sdist to below one megabyte.
- Use ninja as generator target on supported plattforms in setup.py to improve wheel build times
- Stop building wheels for python3.6 as it's eol since a couple months
  • Loading branch information
hillmich authored Apr 6, 2022
1 parent 5fbecf2 commit 49383f3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
submodules: recursive
- uses: ilammy/msvc-dev-cmd@v1
- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
uses: pypa/cibuildwheel@v2.4.0
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14...3.22)

project(ddsim
LANGUAGES CXX
VERSION 1.11.2
VERSION 1.11.3
DESCRIPTION "DDSIM - A JKQ quantum simulator based on decision diagrams"
)

Expand All @@ -11,6 +11,8 @@ option(COVERAGE "Configure for coverage report generation")
option(BINDINGS "Configure for building Python bindings")
option(DEPLOY "Configure for deployment")

message("-- Generator is set to ${CMAKE_GENERATOR}")

if (DEFINED ENV{DEPLOY})
set(DEPLOY $ENV{DEPLOY} CACHE BOOL "Use deployment configuration from environment" FORCE)
message(STATUS "Setting deployment configuration to '${DEPLOY}' from environment")
Expand Down
14 changes: 14 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ include include/*
include apps/*
graft jkq/*
graft mqt/*
global-exclude __pycache__/
global-exclude *.py[cod]
global-exclude *.so

# Include relevant files from other JKQ projects
include extern/qfr/CMakeLists.txt
Expand All @@ -17,6 +20,9 @@ graft extern/qfr/extern/dd_package/include
graft extern/qfr/extern/json
prune extern/qfr/extern/json/doc
prune extern/qfr/extern/json/test
prune extern/qfr/extern/json/benchmarks
prune extern/qfr/extern/json/third_party
prune extern/qfr/extern/json/include

graft extern/qfr/extern/pybind11
prune extern/qfr/extern/pybind11/docs
Expand All @@ -28,5 +34,13 @@ prune extern/qfr/extern/pybind11_json/test
graft extern/taskflow
prune extern/taskflow/docs
prune extern/taskflow/image
prune extern/taskflow/benchmarks
prune extern/taskflow/doxygen
prune extern/taskflow/3rd-party
prune extern/taskflow/tfprof
prune extern/taskflow/sandbox
prune extern/taskflow/unittests
prune extern/taskflow/examples

graft extern/cxxopts
prune extern/cxxopts/test
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[build-system]
requires = ["setuptools", "wheel", "cmake"]
requires = [
"setuptools>=45",
"wheel>=0.37",
"ninja>=1.10; sys_platform != 'win32'",
"cmake>=3.14",
]
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
build = "cp3*"
skip = "*-win32 *-musllinux_i686 *-manylinux_i686"
archs = "auto64"
test-skip = "*_arm64 *-musllinux_x86_64 *_universal2:arm64"
test-command = "python -c \"from mqt import ddsim\""
test-requires = ["qiskit-terra"]
Expand Down
28 changes: 14 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ def __init__(self, name, sourcedir='', namespace=''):


class CMakeBuild(build_ext):
def run(self):
try:
subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))

for ext in self.extensions:
self.build_extension(ext)

def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.namespace+ext.name)))
# required for auto-detection of auxiliary "native" libs
Expand All @@ -35,6 +25,15 @@ def build_extension(self, ext):
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable,
'-DBINDINGS=ON']
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+.
cmake_generator = os.environ.get("CMAKE_GENERATOR", "")
if not cmake_generator:
cmake_args += ["-GNinja"]

cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
Expand Down Expand Up @@ -75,18 +74,19 @@ def build_extension(self, ext):

setup(
name='mqt.ddsim',
version='1.11.2',
version='1.11.3',
author='Stefan Hillmich',
author_email='stefan.hillmich@jku.at',
description='MQT DDSIM - A quantum simulator based on decision diagrams written in C++',
long_description=README,
long_description_content_type='text/markdown',
license='MIT',
url='https://iic.jku.at/eda/research/quantum_simulation/',
url='https://www.cda.cit.tum.de/research/quantum_simulation/',
ext_modules=[CMakeExtension('pyddsim', namespace='mqt.ddsim.')],
cmdclass=dict(build_ext=CMakeBuild),
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
packages=find_namespace_packages(include=['mqt.*']),
python_requires=">=3.7",
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 3',
Expand All @@ -103,7 +103,7 @@ def build_extension(self, ext):
project_urls={
'Source': 'https://github.com/cda-tum/ddsim/',
'Tracker': 'https://github.com/cda-tum/ddsim/issues',
'Research': 'https://iic.jku.at/eda/research/quantum_simulation/',
'Research': 'https://www.cda.cit.tum.de/research/quantum_simulation/',
},
extras_require={
"tnflow": ["sparse", "opt-einsum", "quimb", "pandas", "numpy"]
Expand Down

0 comments on commit 49383f3

Please sign in to comment.