Skip to content

Commit

Permalink
Bump version, restructure package and refresh CI
Browse files Browse the repository at this point in the history
* Bumped version, restructured package directory

* Build extension in circleci and support python3.8

* Refactor osx circleci tests

* Use packages in setup rather than py_modules

This makes sure that all of the files (like package_info.py)
are included.

* Use python 3.7.4 in osx circleci tests

* Refactor deploy in circleci

* Build package in-place in appveyor
  • Loading branch information
arcondello authored and boothby committed Oct 31, 2019
1 parent bc22bed commit f58d49f
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 295 deletions.
444 changes: 169 additions & 275 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
python/minorminer.cpp
minorminer/_minorminer.cpp

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
10 changes: 5 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ environment:
# /E:ON and /V:ON options are not enabled in the batch script intepreter
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C %APPVEYOR_BUILD_FOLDER%\\ci\\appveyor\\run_with_env.cmd"
TRUE_MM_BUILD_DIR: "%APPVEYOR_BUILD_FOLDER%\\python\\dist"
DEBUG_MM_BUILD_DIR: "%APPVEYOR_BUILD_FOLDER%\\python\\debug_dist"
TRUE_MM_BUILD_DIR: "%APPVEYOR_BUILD_FOLDER%\\minorminer\\dist"
DEBUG_MM_BUILD_DIR: "%APPVEYOR_BUILD_FOLDER%\\minorminer\\debug_dist"

# PyPI login
username: dwtools
Expand Down Expand Up @@ -143,7 +143,7 @@ build_script:
# Build the compiled extension
- "%CMD_IN_ENV% python setup.py bdist_wheel -d %MM_BUILD_DIR%"
- "dir %MM_BUILD_DIR%"
- "pip install minorminer --no-index -f %MM_BUILD_DIR%"
- python setup.py build_ext --inplace

test_script:
# Run the project tests
Expand All @@ -156,11 +156,11 @@ after_test:

artifacts:
# Archive the generated packages in the ci.appveyor.com build report.
- path: "python\\dist"
- path: "minorminer\\dist"

deploy_script:
- "echo [pypi] > %USERPROFILE%\\.pypirc"
- "echo username: %username% >> %USERPROFILE%\\.pypirc"
- "echo password: %password% >> %USERPROFILE%\\.pypirc"
- "%CMD_IN_ENV% pip install twine"
- cmd: "if [%APPVEYOR_REPO_TAG%]==[true] if NOT [%CPPDEBUG%]==[1] twine upload --skip-existing python\\dist\\*.whl"
- cmd: "if [%APPVEYOR_REPO_TAG%]==[true] if NOT [%CPPDEBUG%]==[1] twine upload --skip-existing minorminer\\dist\\*.whl"
21 changes: 21 additions & 0 deletions minorminer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019 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 __future__ import absolute_import as __absolute_import

from minorminer.minorminer import miner, VARORDER, find_embedding

from minorminer.package_info import __version__, __author__, __authoremail__, __description__
5 changes: 4 additions & 1 deletion python/minorminer_c.pyx → minorminer/_minorminer.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# distutils: language = c++
# cython: language_level=2
# Note: chosing to use language_level=2 because of how `enum VARORDER` is exposed
"""
`minorminer` is a tool for finding graph minor embeddings, developed to embed Ising problems onto quantum annealers (QA). While it can be used to find minors in arbitrary graphs, it is particularly geared toward state-of-the-art QA: problem graphs of a few to a few hundred variables, and hardware graphs of a few thousand qubits.
Expand Down Expand Up @@ -39,7 +42,7 @@ This implementation adds several useful features:
[1] https://arxiv.org/abs/1406.2741
"""
include "minorminer_h.pxi"
include "_minorminer_h.pxi"
import os

def find_embedding(S, T, **params):
Expand Down
2 changes: 1 addition & 1 deletion python/minorminer_h.pxi → minorminer/_minorminer_h.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ cdef extern from "../include/find_embedding.hpp" namespace "find_embedding":
int findEmbedding(input_graph, input_graph, optional_parameters, vector[vector[int]]&) except +


cdef extern from "minorminer.pyx.hpp" namespace "":
cdef extern from "src/pyutil.hpp" namespace "":
cppclass LocalInteractionPython(LocalInteraction):
LocalInteractionPython()
3 changes: 2 additions & 1 deletion python/minorminer.py → minorminer/minorminer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from minorminer_c import miner, VARORDER, find_embedding as __find_embedding
from __future__ import absolute_import as __absolute_import
from minorminer._minorminer import miner, VARORDER, find_embedding as __find_embedding
from functools import wraps as __wraps

# This wrapper exists to overcome a curious limitation of Cython, and make
Expand Down
2 changes: 1 addition & 1 deletion package_info.py → minorminer/package_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.8"
__version__ = "0.1.9"
__author__ = "Kelly Boothby"
__authoremail__ = "[email protected]"
__description__ = "heuristic algorithm to find graph minor embeddings"
2 changes: 1 addition & 1 deletion python/minorminer.pyx.hpp → minorminer/src/pyutil.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "../include/util.hpp"
#include "../../include/util.hpp"

namespace {

Expand Down
6 changes: 3 additions & 3 deletions parameter_checklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ because, as you'll see, it's gotten to be a fairly tedious process.
[ ] component constructor in the `optional_parameters` class
[ ] optional -- create exceptions involving bad values etc.

2) python/minorminer_h.pyx:
2) minorminer/minorminer_h.pyx:
[ ] member declaration of the `optional_parameters` class

3) python/minorminer_c.pyx:
3) minorminer/minorminer_c.pyx:
[ ] document the parameter (with default) in the docstring of `find_embedding`
[ ] add the parameter to the set `names`
[ ] populate and cast the parameter found in `params`

4) python/minorminer.py:
4) minorminer/minorminer.py:
[ ] add the parameter (with default) to the wrapper function signature
[ ] pass the parameter to `minorminer_c.find_embedding`

Expand Down
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
import os
import platform

cwd = os.path.abspath(os.path.dirname(__file__))

if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
try:
from Cython.Build import cythonize
Expand All @@ -21,7 +21,7 @@
os.chdir(setup_folder_loc)

# Add __version__, __author__, __authoremail__, __description__ to this namespace
path_to_package_info = os.path.join('.', 'package_info.py')
path_to_package_info = os.path.join('.', 'minorminer', 'package_info.py')
if _PY2:
execfile(path_to_package_info)
else:
Expand Down Expand Up @@ -65,8 +65,8 @@ class Extension(extension.Extension, object):
ext = '.pyx' if USE_CYTHON else '.cpp'

extensions = [Extension(
name="minorminer_c",
sources=["./python/minorminer_c" + ext],
name="minorminer._minorminer",
sources=["./minorminer/_minorminer" + ext],
include_dirs=['', './include/'],
language='c++',
)]
Expand Down Expand Up @@ -100,8 +100,7 @@ class Extension(extension.Extension, object):
version=__version__,
license="Apache 2.0",
ext_modules=extensions,
py_modules=['minorminer'],
package_dir={'': 'python'},
packages=['minorminer'],
classifiers=classifiers,
python_requires=python_requires,
cmdclass={'build_ext': build_ext_compiler_check}
Expand Down

0 comments on commit f58d49f

Please sign in to comment.