From 0e2e0297c8d85045e25a1bfdf3635805225a90d8 Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Thu, 1 Mar 2018 16:54:02 -0800 Subject: [PATCH 1/7] Finish minimize_energy --> MinimizeEnergy Change in __all__ --- dwave_embedding_utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwave_embedding_utilities.py b/dwave_embedding_utilities.py index 55e53cf..0014ab4 100644 --- a/dwave_embedding_utilities.py +++ b/dwave_embedding_utilities.py @@ -99,7 +99,7 @@ def itervalues(d): __all__ = ['target_to_source', 'chain_break_frequency', 'embed_ising', 'edgelist_to_adjacency', 'unembed_samples', - 'discard', 'majority_vote', 'weighted_random', 'minimize_energy', + 'discard', 'majority_vote', 'weighted_random', 'MinimizeEnergy', 'chain_to_quadratic'] __version__ = '0.3.0' From afdeb7927d92f015e8b60348e885937aa781aa7d Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Fri, 2 Mar 2018 10:46:14 -0800 Subject: [PATCH 2/7] Move to dwave.embedding.utilities --- .coveragerc | 2 +- docs/conf.py | 10 +++++----- dwave/__init__.py | 2 ++ dwave/embedding/__init__.py | 2 ++ dwave/embedding/utilities/__init__.py | 8 ++++++++ dwave/embedding/utilities/package_info.py | 4 ++++ .../embedding/utilities/utilities.py | 0 setup.py | 13 ++++++++++++- tests/test_embedding_utilities.py | 2 +- 9 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 dwave/__init__.py create mode 100644 dwave/embedding/__init__.py create mode 100644 dwave/embedding/utilities/__init__.py create mode 100644 dwave/embedding/utilities/package_info.py rename dwave_embedding_utilities.py => dwave/embedding/utilities/utilities.py (100%) diff --git a/.coveragerc b/.coveragerc index ac51b5c..4d00f14 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,4 @@ [run] # omit virtualenv and test files omit = venv/*, */tests/* -source=dwave_embedding_utilities +source=dwave diff --git a/docs/conf.py b/docs/conf.py index e79c9c3..cbddcde 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -63,11 +63,11 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -import dwave_embedding_utilities +import dwave.embedding.utilities.utilities # The short X.Y version. -version = dwave_embedding_utilities.__version__ +version = dwave.embedding.utilities.package_info.__version__ # The full version, including alpha/beta/rc tags. -release = dwave_embedding_utilities.__version__ +release = dwave.embedding.utilities.package_info.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -89,9 +89,9 @@ # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True -modindex_common_prefix = ['dwave_embedding_utilities.'] +modindex_common_prefix = ['dwave.embedding.utilities.'] -doctest_global_setup = "from dwave_embedding_utilities import *" +doctest_global_setup = "from dwave.embedding.utilities import *" # -- Options for HTML output ---------------------------------------------- diff --git a/dwave/__init__.py b/dwave/__init__.py new file mode 100644 index 0000000..bb61062 --- /dev/null +++ b/dwave/__init__.py @@ -0,0 +1,2 @@ +import pkgutil +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/dwave/embedding/__init__.py b/dwave/embedding/__init__.py new file mode 100644 index 0000000..bb61062 --- /dev/null +++ b/dwave/embedding/__init__.py @@ -0,0 +1,2 @@ +import pkgutil +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/dwave/embedding/utilities/__init__.py b/dwave/embedding/utilities/__init__.py new file mode 100644 index 0000000..df00fd9 --- /dev/null +++ b/dwave/embedding/utilities/__init__.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from dwave.embedding.utilities.package_info import __version__, __author__, __authoremail__, __description__ + +# for each module in this package, import __all__ + +from dwave.embedding.utilities.utilities import * +import dwave.embedding.utilities.utilities diff --git a/dwave/embedding/utilities/package_info.py b/dwave/embedding/utilities/package_info.py new file mode 100644 index 0000000..5059d59 --- /dev/null +++ b/dwave/embedding/utilities/package_info.py @@ -0,0 +1,4 @@ +__version__ = '0.3.0' +__author__ = 'D-Wave Systems Inc.' +__authoremail__ = 'acondello@dwavesys.com' +__description__ = 'Utilities to manage embedding for the D-Wave System' diff --git a/dwave_embedding_utilities.py b/dwave/embedding/utilities/utilities.py similarity index 100% rename from dwave_embedding_utilities.py rename to dwave/embedding/utilities/utilities.py diff --git a/setup.py b/setup.py index 126a70d..c00c9e7 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,18 @@ +import sys +import os from setuptools import setup -from dwave_embedding_utilities import __version__, __author__, __description__, __authoremail__ +# add __version__, __author__, __authoremail__, __description__ to this namespace +_PY2 = sys.version_info.major == 2 +# change directories so this works when called from other locations. Useful in build systems. +setup_folder_loc = os.path.dirname(os.path.abspath(__file__)) +os.chdir(setup_folder_loc) + +if _PY2: + execfile(os.path.join(".", "dwave", "embedding", "utilities", "package_info.py")) +else: + exec(open(os.path.join(".", "dwave", "embedding", "utilities", "package_info.py")).read()) setup( name='dwave_embedding_utilities', diff --git a/tests/test_embedding_utilities.py b/tests/test_embedding_utilities.py index dc0580d..496e36f 100644 --- a/tests/test_embedding_utilities.py +++ b/tests/test_embedding_utilities.py @@ -6,7 +6,7 @@ import dwave_networkx as dnx import dimod -import dwave_embedding_utilities as eutil +import dwave.embedding.utilities as eutil class TestTargetToSource(unittest.TestCase): From 2be6edff26c3b0ff9b615b9eb8b951ba72baef17 Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Fri, 2 Mar 2018 11:24:43 -0800 Subject: [PATCH 3/7] Tidy requirements --- docs/requirements.txt | 2 ++ requirements.txt | 2 -- setup.py | 29 ++++++++++++++++++++++++----- tests/requirements.txt | 4 ++++ 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 docs/requirements.txt create mode 100644 tests/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..8213302 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx +sphinx_rtd_theme diff --git a/requirements.txt b/requirements.txt index 6a33fb9..8171964 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,3 @@ dimod==0.5.0 dwave_networkx==0.6.0 networkx==2.0 - -coveralls \ No newline at end of file diff --git a/setup.py b/setup.py index c00c9e7..1812f6d 100644 --- a/setup.py +++ b/setup.py @@ -2,17 +2,31 @@ import os from setuptools import setup -# add __version__, __author__, __authoremail__, __description__ to this namespace _PY2 = sys.version_info.major == 2 -# change directories so this works when called from other locations. Useful in build systems. +# Change directories so this works when called from other locations. Useful in build systems that build from source. setup_folder_loc = os.path.dirname(os.path.abspath(__file__)) os.chdir(setup_folder_loc) +# Add __version__, __author__, __authoremail__, __description__ to this namespace +path_to_package_info = os.path.join('.', 'dwave', 'embedding', 'utilities', 'package_info.py') if _PY2: - execfile(os.path.join(".", "dwave", "embedding", "utilities", "package_info.py")) + execfile(path_to_package_info) else: - exec(open(os.path.join(".", "dwave", "embedding", "utilities", "package_info.py")).read()) + exec(open(path_to_package_info).read()) + +# These should be minimal requiments for the package to work, and avoid pinning dependencies unless required. See +# https://packaging.python.org/discussions/install-requires-vs-requirements/ +install_requires = ['dimod>=0.5.0,<0.6.0', + 'dwave_networkx>=0.6.0,<0.7.0', + 'networkx>=2.0,<3.0'] + +# Any extra requirements, to be used by pip install PACKAGENAME['keyname'] +extras_require = {} + +# The packages in this repo that are to be installed. Either list these explictly, or use setuptools.find_packages. If +# the latter, take care to filter unwanted packages (e.g. tests) +packages = ['dwave.embedding.utilities'] setup( name='dwave_embedding_utilities', @@ -20,7 +34,12 @@ author=__author__, author_email=__authoremail__, description=__description__, + long_description=open('README.rst').read(), url='https://github.com/dwavesystems/dwave_embedding_utilities', license='Apache 2.0', - py_modules=['dwave_embedding_utilities'] + packages=packages, + install_requires=install_requires, + extras_require=extras_require, + # Required to make this a namespace package. If this package is at lower level, include all packages above it. + namespace_packages=['dwave', 'dwave.embedding'] ) diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..131c54e --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,4 @@ +-r ../requirements.txt + +coverage +coveralls From 2a91d6503e2687efe77fc624e55bdbbd9be6be81 Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Fri, 2 Mar 2018 18:18:18 -0800 Subject: [PATCH 4/7] Fix setup to follow pypa example https://github.com/pypa/sample-namespace-packages/tree/master/pkgutil --- setup.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 1812f6d..f98b434 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import sys import os -from setuptools import setup +from setuptools import setup, find_packages _PY2 = sys.version_info.major == 2 @@ -24,10 +24,6 @@ # Any extra requirements, to be used by pip install PACKAGENAME['keyname'] extras_require = {} -# The packages in this repo that are to be installed. Either list these explictly, or use setuptools.find_packages. If -# the latter, take care to filter unwanted packages (e.g. tests) -packages = ['dwave.embedding.utilities'] - setup( name='dwave_embedding_utilities', version=__version__, @@ -37,9 +33,8 @@ long_description=open('README.rst').read(), url='https://github.com/dwavesystems/dwave_embedding_utilities', license='Apache 2.0', - packages=packages, + packages=find_packages(exclude=['tests']), install_requires=install_requires, extras_require=extras_require, - # Required to make this a namespace package. If this package is at lower level, include all packages above it. - namespace_packages=['dwave', 'dwave.embedding'] + zip_safe=False, ) From 365006a92f016f24d877c06143c560a2e5220386 Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Fri, 2 Mar 2018 18:19:40 -0800 Subject: [PATCH 5/7] Fix cyclic import --- dwave/__init__.py | 3 +-- dwave/embedding/__init__.py | 3 +-- dwave/embedding/utilities/__init__.py | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/dwave/__init__.py b/dwave/__init__.py index bb61062..69e3be5 100644 --- a/dwave/__init__.py +++ b/dwave/__init__.py @@ -1,2 +1 @@ -import pkgutil -__path__ = pkgutil.extend_path(__path__, __name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/dwave/embedding/__init__.py b/dwave/embedding/__init__.py index bb61062..69e3be5 100644 --- a/dwave/embedding/__init__.py +++ b/dwave/embedding/__init__.py @@ -1,2 +1 @@ -import pkgutil -__path__ = pkgutil.extend_path(__path__, __name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/dwave/embedding/utilities/__init__.py b/dwave/embedding/utilities/__init__.py index df00fd9..a802038 100644 --- a/dwave/embedding/utilities/__init__.py +++ b/dwave/embedding/utilities/__init__.py @@ -1,8 +1,5 @@ from __future__ import absolute_import -from dwave.embedding.utilities.package_info import __version__, __author__, __authoremail__, __description__ - # for each module in this package, import __all__ from dwave.embedding.utilities.utilities import * -import dwave.embedding.utilities.utilities From 93a90b362aec65eeb7994f9134c5d5d89b8dccd6 Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Mon, 5 Mar 2018 16:00:35 -0800 Subject: [PATCH 6/7] Install test requirements in Travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a9550e..acc6c9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,9 +44,9 @@ matrix: deploy: install: - - pip install -r requirements.txt + - pip install -r tests/requirements.txt - pip install . - + script: - coverage run -m unittest discover From 3260d11cf4c25a9ccc391a72e018ed0ea41ec3e6 Mon Sep 17 00:00:00 2001 From: Bradley Ellert Date: Mon, 5 Mar 2018 16:43:22 -0800 Subject: [PATCH 7/7] Change 'brew install python3' to 'brew upgrade python' --- .travis.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index acc6c9d..4fb387d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ matrix: # sudo: required # python: "nightly" # env: TOXENV=pynightly + # deploy: - os: linux sudo: required python: "3.6" @@ -27,19 +28,20 @@ matrix: deploy: - os: osx language: generic - env: TOXENV=py27 + env: TOXENV=py36 before_install: - brew update - - virtualenv env -p python2 + - brew upgrade python + - pip install virtualenv + - virtualenv env -p python - source env/bin/activate deploy: - os: osx language: generic - env: TOXENV=py36 + env: TOXENV=py27 before_install: - brew update - - brew install python3 - - virtualenv env -p python3 + - virtualenv env -p python2 - source env/bin/activate deploy: