From c2ccfd48679171f59ed3be6a1ce706353e74d0b0 Mon Sep 17 00:00:00 2001 From: Alexander Condello Date: Thu, 27 Dec 2018 09:28:23 -0800 Subject: [PATCH] Add dwave.samplers and dwave.composite namespace --- dwave/__init__.py | 17 +++++++++++++++++ dwave/composites/__init__.py | 20 ++++++++++++++++++++ dwave/samplers/__init__.py | 20 ++++++++++++++++++++ setup.py | 10 +++++++++- tests/test_entry_points.py | 9 +++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 dwave/__init__.py create mode 100644 dwave/composites/__init__.py create mode 100644 dwave/samplers/__init__.py create mode 100644 tests/test_entry_points.py diff --git a/dwave/__init__.py b/dwave/__init__.py new file mode 100644 index 00000000..64083cc8 --- /dev/null +++ b/dwave/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2018 D-Wave Systems Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================================ +import pkgutil +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/dwave/composites/__init__.py b/dwave/composites/__init__.py new file mode 100644 index 00000000..84774a81 --- /dev/null +++ b/dwave/composites/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2018 D-Wave Systems Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================================ +from pkg_resources import iter_entry_points + +# add the composites to the module from entrypoints, name conflicts override +globals().update((ep.name, ep.load()) for ep in iter_entry_points('dwave.composites')) +del iter_entry_points # remove from namespace diff --git a/dwave/samplers/__init__.py b/dwave/samplers/__init__.py new file mode 100644 index 00000000..bf0642aa --- /dev/null +++ b/dwave/samplers/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2018 D-Wave Systems Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================================ +from pkg_resources import iter_entry_points + +# add the samplers to the module from entrypoints, name conflicts override +globals().update((ep.name, ep.load()) for ep in iter_entry_points('dwave.samplers')) +del iter_entry_points # remove from namespace diff --git a/setup.py b/setup.py index 33dd610a..8badc0cd 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,9 @@ # ================================================================================================ from __future__ import absolute_import +import os import sys + from setuptools import setup _PY2 = sys.version_info.major == 2 @@ -27,6 +29,8 @@ else: exec(open("./dwaveoceansdk/package_info.py").read()) +os.chdir(os.path.dirname(os.path.abspath(__file__))) + install_requires = [ 'dwave-networkx>=0.6.1,<0.7.0', 'dwave-system>=0.5.0,<0.6.0', @@ -43,7 +47,11 @@ ] } -packages = ['dwaveoceansdk'] +packages = ['dwaveoceansdk', + 'dwave', + 'dwave.samplers', + 'dwave.composites', + ] classifiers = [ 'License :: OSI Approved :: Apache Software License', diff --git a/tests/test_entry_points.py b/tests/test_entry_points.py new file mode 100644 index 00000000..d61c3ada --- /dev/null +++ b/tests/test_entry_points.py @@ -0,0 +1,9 @@ +import unittest + + +class Test_dwave_samplers(unittest.TestCase): + pass + + +class Test_dwave_composites(unittest.TestCase): + pass