From 36bad537e263f75e736cb667cc68062f108ff7f5 Mon Sep 17 00:00:00 2001 From: Alexander Condello Date: Wed, 8 Dec 2021 10:38:39 -0800 Subject: [PATCH 1/3] Support python 3.10 Raise minimum dimod version to 0.10.8 Add dwave-preprocessing as a dependency Raise minimum networkx version to 2.4 --- .circleci/config.yml | 40 +++++++++++++++++++---------- dwave_networkx/algorithms/markov.py | 7 ++--- requirements.txt | 3 ++- setup.py | 6 +++-- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dc12519f..cd00a863 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,8 @@ jobs: parameters: dimod-version: type: string + networkx-version: + type: string python-version: type: string @@ -30,10 +32,11 @@ jobs: pip install -r requirements.txt -r tests/requirements.txt - run: - name: Install specified dimod version + name: Install dependencies command: | . env/bin/activate pip install --upgrade 'dimod<< parameters.dimod-version >>' + pip install --upgrade 'networkx<< parameters.networkx-version >>' - save_cache: &save-cache-env key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }} @@ -58,7 +61,7 @@ jobs: type: string macos: - xcode: "12.2.0" + xcode: "13.2.0" environment: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -72,27 +75,37 @@ jobs: brew install pyenv - restore_cache: &restore-cache-pyenv - key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-12.2.0 + key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-13.2.0 + + - when: + # see https://github.com/pyenv/pyenv/issues/1643 + condition: + equal: [3.6.8, << parameters.python-version >>] + steps: + - run: pyenv install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch) - run: name: Install python command: | pyenv install << parameters.python-version>> -s - - run: - name: Set system python - command: | - pyenv global << parameters.python-version >> - echo 'eval "$(pyenv init -)"' >> ~/.bash_profile - - save_cache: &save-cache-pyenv - key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-12.2.0 + key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-13.2.0 paths: - ~/.pyenv - restore_cache: *restore-cache-env - - run: *create-venv-install-deps + - run: + name: Create virtualenv and install dependencies + command: | + eval "$(pyenv init --path)" + pyenv local << parameters.python-version >> + python -m venv env + . env/bin/activate + python --version + pip install pip --upgrade + pip install -r requirements.txt -r tests/requirements.txt - save_cache: *save-cache-env @@ -207,8 +220,9 @@ workflows: - test-linux: matrix: parameters: - python-version: &python-versions [3.6.8, 3.7.9, 3.8.9, 3.9.4] - dimod-version: [==0.8.0, <0.9, <0.10, <0.11] + python-version: &python-versions [3.6.8, 3.7.9, 3.8.9, 3.9.4, 3.10.0] + dimod-version: [==0.10.8, ~=0.10.0] + networkx-version: [==2.4, <3.0] - test-osx: matrix: parameters: diff --git a/dwave_networkx/algorithms/markov.py b/dwave_networkx/algorithms/markov.py index a945b316..c5c8592b 100644 --- a/dwave_networkx/algorithms/markov.py +++ b/dwave_networkx/algorithms/markov.py @@ -13,11 +13,8 @@ # limitations under the License. import dimod -try: - from dwave.preprocessing import FixVariablesComposite -except ImportError: - # fall back on dimod (<0.10) if dwave.preprocessing not installed - from dimod import FixedVariableComposite as FixVariablesComposite + +from dwave.preprocessing import FixVariablesComposite from dwave_networkx.utils import binary_quadratic_model_sampler diff --git a/requirements.txt b/requirements.txt index ec0b31fa..ed4186ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ networkx==2.4 -dimod==0.8.0 \ No newline at end of file +dimod==0.10.8 +dwave-preprocessing==0.3.2 diff --git a/setup.py b/setup.py index dccca341..1151ba69 100644 --- a/setup.py +++ b/setup.py @@ -29,8 +29,9 @@ 'dwave_networkx.generators', ] -install_requires = ['networkx>=2.0,<3.0', - 'dimod>=0.8.0,!=0.10.0,!=0.10.1,!=0.10.2,!=0.10.3,!=0.10.4', +install_requires = ['networkx>=2.4,<3.0', + 'dimod>=0.10.8,<0.11.0', + 'dwave-preprocessing>=0.3.2,<0.4.0' ] python_requires = ">=3.6" @@ -43,6 +44,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ] setup( From 8713df7ca8ef61cb43c17934ce30bb1798ab1b82 Mon Sep 17 00:00:00 2001 From: Alexander Condello Date: Wed, 8 Dec 2021 11:41:25 -0800 Subject: [PATCH 2/3] Save cache in CI rather than full venv --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cd00a863..94e88570 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ jobs: - checkout - restore_cache: &restore-cache-env - key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }} + key: pip-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }} - run: &create-venv-install-deps name: Create virtual environment and install dependencies @@ -39,9 +39,9 @@ jobs: pip install --upgrade 'networkx<< parameters.networkx-version >>' - save_cache: &save-cache-env - key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }} + key: pip-{{ checksum "requirements.txt" }}-{{ checksum "tests/requirements.txt" }}-{{ .Environment.CIRCLE_JOB }} paths: - - env + - ~/.cache/pip - run: &run-tests name: Run unittests From 307dbf6256d21e375186ad6121e118a1c8dda4e5 Mon Sep 17 00:00:00 2001 From: Alexander Condello Date: Wed, 8 Dec 2021 12:02:55 -0800 Subject: [PATCH 3/3] Fix CI py3.6 install --- .circleci/config.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94e88570..cfdee0dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,11 +78,16 @@ jobs: key: v1-pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-13.2.0 - when: - # see https://github.com/pyenv/pyenv/issues/1643 + # see https://github.com/pyenv/pyenv/issues/1643. We use an intermediate + # file so we can use the --skip-existing without raising errors from curl condition: equal: [3.6.8, << parameters.python-version >>] steps: - - run: pyenv install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch) + - run: + name: Install Python 3.6 with a patch + command: | + curl -sSL https://github.com/python/cpython/commit/8ea6353.patch > tmp.txt + pyenv install -s --patch 3.6.8 < tmp.txt - run: name: Install python