Skip to content

Commit

Permalink
added setup files
Browse files Browse the repository at this point in the history
  • Loading branch information
sid committed Feb 9, 2021
1 parent b595315 commit d5d6bfc
Show file tree
Hide file tree
Showing 23 changed files with 404 additions and 44 deletions.
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST


src/qip/version.py


# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2020, QuTiP
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.md
include LICENSE.txt
include requirements.txt
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# qutip-qip
The QuTiP quantum information processing package
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numpy>=1.12
scipy>=1.0
qutip>=4.5
190 changes: 190 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#!/usr/bin/env python
"""QuTiP: The Quantum Toolbox in Python
QuTiP is open-source software for simulating the dynamics of closed and open
quantum systems. The QuTiP library depends on the excellent Numpy, Scipy, and
Cython numerical packages. In addition, graphical output is provided by
Matplotlib. QuTiP aims to provide user-friendly and efficient numerical
simulations of a wide variety of quantum mechanical problems, including those
with Hamiltonians and/or collapse operators with arbitrary time-dependence,
commonly found in a wide range of physics applications. QuTiP is freely
available for use and/or modification on all common platforms. Being free of
any licensing fees, QuTiP is ideal for exploring quantum mechanics in research
as well as in the classroom.
"""

DOCLINES = __doc__.split('\n')

CLASSIFIERS = """\
Development Status :: 4 - Beta
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Programming Language :: Python
Programming Language :: Python :: 3
Topic :: Scientific/Engineering
Operating System :: MacOS
Operating System :: POSIX
Operating System :: Unix
Operating System :: Microsoft :: Windows
"""

# import statements
import os
import sys
# The following is required to get unit tests up and running.
# If the user doesn't have, then that's OK, we'll just skip unit tests.
try:
from setuptools import setup, Extension
EXTRA_KWARGS = {
'setup_require': ['pytest-runner'],
'tests_require': ['pytest']
}
except:
from distutils.core import setup
from distutils.extension import Extension
EXTRA_KWARGS = {}

try:
import numpy as np
except ImportError as e:
raise ImportError("numpy is required at installation") from e

#from Cython.Build import cythonize
#from Cython.Distutils import build_ext

# all information about QuTiP goes here
MAJOR = 0
MINOR = 0
MICRO = 1
ISRELEASED = False
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
REQUIRES = ['numpy (>=1.12)', 'scipy (>=1.0)', 'qutip (>=4.5)']
EXTRAS_REQUIRE = {'graphics': ['matplotlib(>=1.2.1)']}
INSTALL_REQUIRES = ['numpy>=1.12', 'scipy>=1.0', 'qutip>=4.5']
PACKAGES = ['src/qip', 'src/qip/device', 'src/qip/operations', 'src/qip/compiler',
'src/qip/algorithms']
PACKAGE_DATA = {}

# If we're missing numpy, exclude import directories until we can
# figure them out properly.
INCLUDE_DIRS = [np.get_include()] if np is not None else []
NAME = "qutip_qip"
AUTHOR = ("Alexander Pitchford, Paul D. Nation, Robert J. Johansson, "
"Chris Granade, Arne Grimsmo, Nathan Shammah, Shahnawaz Ahmed, "
"Neill Lambert, Eric Giguere, Boxi Li")
AUTHOR_EMAIL = ("[email protected], [email protected], "
"[email protected], [email protected], "
"[email protected], [email protected], "
"[email protected], [email protected], "
"[email protected], [email protected]")
LICENSE = "BSD"
DESCRIPTION = DOCLINES[0]
LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
KEYWORDS = "quantum physics dynamics"
URL = "http://qutip.org"
CLASSIFIERS = [_f for _f in CLASSIFIERS.split('\n') if _f]
PLATFORMS = ["Linux", "Mac OSX", "Unix", "Windows"]


def git_short_hash():
try:
git_str = "+" + os.popen('git log -1 --format="%h"').read().strip()
except:
git_str = ""
else:
if git_str == '+': #fixes setuptools PEP issues with versioning
git_str = ''
return git_str

FULLVERSION = VERSION
if not ISRELEASED:
FULLVERSION += '.dev'+str(MICRO)+git_short_hash()

# NumPy's distutils reads in versions differently than
# our fallback. To make sure that versions are added to
# egg-info correctly, we need to add FULLVERSION to
# EXTRA_KWARGS if NumPy wasn't imported correctly.
if np is None:
EXTRA_KWARGS['version'] = FULLVERSION


def write_version_py(filename='src/qip/version.py'):
cnt = """\
# THIS FILE IS GENERATED FROM QUTIP SETUP.PY
short_version = '%(version)s'
version = '%(fullversion)s'
release = %(isrelease)s
"""
a = open(filename, 'w')
try:
a.write(cnt % {'version': VERSION, 'fullversion':
FULLVERSION, 'isrelease': str(ISRELEASED)})
finally:
a.close()

local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
print(local_path)
os.chdir(local_path)
sys.path.insert(0, local_path)
print(local_path)
sys.path.insert(0, os.path.join(local_path, 'src/qip')) # to retrive _version
print(local_path)


# always rewrite _version
if os.path.exists('src/qip/version.py'):
os.remove('src/qip/version.py')

write_version_py()

# Add Cython extensions here
cy_exts = []

# Extra link args
_link_flags = []

# If on Win and Python version >= 3.5 and not in MSYS2
# (i.e. Visual studio compile)
if (sys.platform == 'win32'
and int(str(sys.version_info[0])+str(sys.version_info[1])) >= 35
and os.environ.get('MSYSTEM') is None):
_compiler_flags = ['/w', '/Ox']
# Everything else
else:
_compiler_flags = ['-w', '-O3', '-funroll-loops']
if sys.platform == 'darwin':
# These are needed for compiling on OSX 10.14+
_compiler_flags.append('-mmacosx-version-min=10.9')
_link_flags.append('-mmacosx-version-min=10.9')

# Setup commands go here
setup(name = NAME,
version = FULLVERSION,
packages = PACKAGES,
include_package_data=True,
include_dirs = INCLUDE_DIRS,
# headers = HEADERS,
author = AUTHOR,
author_email = AUTHOR_EMAIL,
license = LICENSE,
description = DESCRIPTION,
long_description = LONG_DESCRIPTION,
keywords = KEYWORDS,
url = URL,
classifiers = CLASSIFIERS,
platforms = PLATFORMS,
requires = REQUIRES,
extras_require = EXTRAS_REQUIRE,
package_data = PACKAGE_DATA,
zip_safe = False,
install_requires=INSTALL_REQUIRES,
**EXTRA_KWARGS
)
_cite = """\
==============================================================================
Installation complete
Please cite QuTiP in your publication.
==============================================================================
For your convenience a bibtex reference can be easily generated using
`qutip.cite()`"""
print(_cite)
2 changes: 1 addition & 1 deletion src/qutip_qip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
# To remove the warning, and finalize the deprecation
# simply delete the file qutip.qip.qip_deprecation.py
# and the line bellow.
from qutip.qip.qip_deprecation import *
from .qip_deprecation import *
4 changes: 2 additions & 2 deletions src/qutip_qip/algorithms/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@


import numpy as np
from qutip.qip.operations.gates import snot, cphase, swap
from qutip.qip.circuit import QubitCircuit
from .operations.gates import snot, cphase, swap
from .circuit import QubitCircuit
from qutip.qobj import Qobj


Expand Down
4 changes: 2 additions & 2 deletions src/qutip_qip/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import numpy as np
from copy import deepcopy

from qutip.qip import circuit_latex as _latex
from qutip.qip.operations.gates import (rx, ry, rz, sqrtnot, snot, phasegate,
from . import circuit_latex as _latex
from .operations.gates import (rx, ry, rz, sqrtnot, snot, phasegate,
x_gate, y_gate, z_gate, cy_gate,
cz_gate, s_gate, t_gate, cs_gate,
qasmu_gate, ct_gate, cphase, cnot,
Expand Down
Loading

0 comments on commit d5d6bfc

Please sign in to comment.