Skip to content

Commit

Permalink
Merge branch 'fix-cython-install'
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranra committed Jan 28, 2019
2 parents 3c5d585 + f06221d commit 51d36c9
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 14 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include pecos *.c *.cpp *.h *.pyx *.pxd
prune pecos/?/build
Binary file added dist/quantum_pecos-0.1.0-py3.6.egg
Binary file not shown.
7 changes: 7 additions & 0 deletions pecos/simulators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@
from .sparsesim import State as SparseSim

StabSim = SparseSim # Default stabilizer simulator

try:
import cython
from . import compile_cython

except ImportError:
pass
12 changes: 2 additions & 10 deletions pecos/simulators/compile_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import subprocess


def main():

def compile():
# See if Cython has been installed...
try:
import cython
Expand All @@ -30,7 +29,7 @@ def main():

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

print('!!!', current_location)
# print('!!!', current_location)

cython_dirs = [
'cysparsesim',
Expand All @@ -48,13 +47,6 @@ def main():
if p.returncode:
failed[d] = error

return failed, cython_dirs


if __name__ == '__main__':

failed, cython_dirs = main()

successful = set(cython_dirs) - set(failed.keys())

if successful:
Expand Down
2 changes: 1 addition & 1 deletion pecos/simulators/cysparsesim/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build
*.pyd
*.pyd
2 changes: 1 addition & 1 deletion pecos/simulators/cysparsesim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# 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 .cysparsesim import State
Empty file.
2 changes: 1 addition & 1 deletion pecos/simulators/cysparsesim/src/cysparsesim.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# limitations under the License.
# ========================================================================= #

from libcpp cimport bool
cimport cysparsesim_header as s
from cysparsesim_header cimport int_num

from .src.logical_sign import find_logical_signs
from ..


cdef dict gate_dict = {
Expand Down
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[metadata]
description-file = README.md
license-file = LICENSE

[build_ext]
inplace=1

[bdist_wheel]
universal = 1
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
'and study of quantum error correcting codes.',
long_description=long_description,
long_description_content_type="text/markdown",

packages=find_packages(),
include_package_data=True,

python_requires='>=3.5.2',
install_requires=[
'numpy>=1.15.0',
Expand All @@ -66,4 +69,14 @@
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
)
)

try:
import cython
# Have to have Cython already installed before running this setup file
# Otherwise, just run:
from pecos.simulators import compile_cython
compile_cython.compile()
# TODO: compile Cython directly using this setup script ... or could trigger compile at init if Cython is available
except ImportError:
pass

0 comments on commit 51d36c9

Please sign in to comment.