Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pip support #35

Merged
merged 2 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#!/bin/bash
# This is a helper script to upload new versions of the SDK
# Author: Juan Gomez

# Please provide a valid username and password to connect to PyPi for uploading
# the QISKit SDK distributable packaged
USERNAME=""
PASSWORD=""



usage(){
echo "Usage:"
echo "$0 [OPTION]"
echo "Helper script to create and upload QISKit SDK distributable package"
echo "to PyPi severs."
echo ""
echo "Options:"
echo "-u <username> Specify a registered PyPi username"
echo "-p <password> The password of the username"
echo "-h Shows this help"
echo ""
exit 1
}

while getopts "u:p:h" optname
do
case "$optname" in
"h")
usage
;;
"u")
USERNAME=$OPTARG
;;
"p")
PASSWORD=$OPTARG
;;
":")
echo "No argument value for option $OPTARG"
usage
;;
*)
# Should not occur
echo "Unknown error while processing options"
usage
;;
esac
done

self=$0
date > $self.log
echo "**********************" >> $self.log

confirm() {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case "$response" in
[yY])
return 1
;;
*)
return 0
;;
esac
}

check_twine() {
twine upload -h &>> $self.log
if [[ $? != 0 ]]
then
return 0
else
return 1
fi
}

install_twine() {
pip install twine &>> $self.log
if [[ $? != 0 ]]
then
return 0
else
return 1
fi
}

diagnose() {
echo "Let's see if I can figure out what happened..."
echo -n "Is there a USERNAME?..."
if [[ $USERNAME == "" ]]
then
echo -e "[NO]"
echo "-----------------------"
echo "Seems like you haven't provide a USERNAME!"
echo "Please edit $self and add a registered username and password"
echo "or use the command options: -u <USERNAME> -p <PASSWORD>"
return
fi
echo -e "[YES]"
echo -n "Is there a PASSWORD?..."
if [[ $PASSWORD == "" ]]
then
echo -e "[NO]"
echo "-----------------------"
echo "Ok, so you provided a USERNAME but I can't seem to find the"
echo "the corresponding PASSWORD."
echo "Please edit $self and add the correct password"
echo "or use the command options: -u <USERNAME> -p <PASSWORD>"
return
fi

echo -e "[YES]"
echo -n "Is there connection to upload.pypi.org?..."
wget -q https://upload.pypi.org/ -O /dev/null &>> $self.log
if [[ $? != 0 ]]
then
echo -e "[NO]"
echo "-----------------------"
echo "Seems like there's no connection to PyPi, or PyPi is down."
echo "Please make sure there's a working internet connection."
echo "If you have internet connection, the PyPi site may be down."
echo "Please try again later."
return

fi
echo -e "[YES]"
echo "Seems like your credentials may be incorrect."
echo "Please make sure you have introduced the correct username and "
echo "password in the $self script."
}

echo -n "Clobbering build..."
# Clobbering build to rebuild it later
rm -rf qiskit.egg-info build dist
echo -e "[OK]"

echo -n "Building distributable package..."
# Let's build the wheel package
python setup.py sdist bdist_wheel &>> $self.log
if [ $? != 0 ]
then
echo -e "[ERROR]"
echo "--------------------------"
echo "Something wrong has happened!!. Please make sure that you are in the "
echo "project root directory and there's a setup.py file in there."
exit 2
fi
echo -e "[OK]"

echo -n "Checking for twine tool..."
check_twine
if [[ $? == 0 ]] # if it's ... false :)
then
echo -e "[ERROR]"
echo "Seems like you don't have Twine installed in yout system."
echo "Twine tool is necessary for uploading the package to PyPi."
echo ""
confirm "Do you want to install Twine? [Y/n]"
if [[ $? == 1 ]]
then
install_twine
if [[ $? == 0 ]]
then
echo "Couldn't install Twine, please try to install twine by yourself:"
echo "$ pip install twine"
exit 3
else
echo "Twine successfully installed!"
fi
else
echo "Install Twine by yourself and try again later!"
exit 4
fi
fi
echo -e "[OK]"

echo -n "Uploading distributable package to PyPi..."
twine upload -u $USERNAME -p $PASSWORD sdist/* &>> $self.log
if [[ $? != 0 ]]
then
echo -e "[ERROR]"
echo "--------------------------"
echo "Error! Couldn't upload the distributed package to PyPi!!"
diagnose
exit 5
fi

echo -e "[OK]"
echo "Done!"
echo "Remember to create a TAG in the repo with the same version you just uploaded!"
rm -f $self.log
exit 0
16 changes: 8 additions & 8 deletions requires.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
IBMQuantumExperience
requests
networkx
ply
numpy
scipy
matplotlib
sphinx
IBMQuantumExperience>=1.8
requests>=1.11,<.12
networkx>=1.11,<2.0
ply==3.10
numpy>=1.13,<1.14
scipy>=0.19,<0.20
matplotlib>=2.0,<2.1
sphinx>=1.6,<1.7
46 changes: 46 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from setuptools import setup

packages = ["qiskit",
"qiskit.dagcircuit",
"qiskit.extensions",
"qiskit.extensions.standard",
"qiskit.mapper",
"qiskit.qasm",
"qiskit.qasm._node",
"qiskit.simulators",
"qiskit.unroll"]

requirements = ["IBMQuantumExperience>=1.8",
"requests>=2.18,<2.19",
"networkx>=1.11,<1.12",
"ply==3.10",
"numpy>=1.13,<1.14",
"scipy>=0.19,<0.20",
"matplotlib>=2.0,<2.1",
"sphinx>=1.6,<1.7"]

setup(
name="qiskit",
version="0.3.1",
description="Software for developing quantum computing programs",
long_description="""QISKit is a software development kit for writing quantum
computing experiments, programs, and applications. Works with Python 3.5 and 3.6""",
url="https://github.com/IBM/qiskit-sdk-py",
author="QISKit Development Team",
author_email="[email protected]",
license="Apache 2.0",
classifiers=[
"Environment :: Console",
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"
"Topic :: Software Development :: SDK",
"Topic :: Scientific",
],
keywords="qiskit sdk quantum",
packages=packages,
install_requires=requirements,
python_requires=">=3.5",
)