diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1f314f3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: python +only: +- master +- Develop +matrix: + include: + - name: Python 3.5 on Linux + python: 3.5 + - name: Python 3.6 on Linux + python: 3.6 + env: + - BUILD=True + - name: Python 3.7 on Xenial Linux + python: 3.7 + dist: xenial + - name: Python 3.7 on macOS + os: osx + osx_image: xcode10.2 + language: shell +before_install: +- make build +install: +- pip3 install dist/*.whl +script: +- make lint +deploy: + provider: pypi + user: adahlberg + password: + secure: cQUlOGHX5ksULLBM2kOE9s2hdaJn4WK8rhD4LUuWndUG7rLeqtVfEMVrqWuMmzWcHXKOti143vgthSgp+akixfnQD7jWupVVSRiz5SFgq+1DRezGlkvYcZz2833on28lNFRiTjuPHkY3WoK0sS1iESxwTBvvi4y+q+AGtFzKE8hr+Pej+HnqFMMeXfqE7d/ZhoOrcBiRRcOrV/2JjpET5CMqimCYR4rz25yzpvVWlakC24vCqGs0Py+JL+VlZszjQz25NAQuuVwOAKnH/bapCV/JFmpvrFF5gKqAly9d1/+ZVgQVT9swMPjwmQs3zQ9E7IlL+4BPhdDly1H/GchyTRvf3uFt6Lok8ySvDyIkZUM2HlIoJIJCAESRCoEK7K7t1ySovBKjXI1Jc8O3QhAvdVMFWPpVxq5ZKwvUAEKtt7vRzN2KVmSi1nJxEzL89iuZkUtihws6DD8Y/6VgcemCFEZlP8ubxxRqR6gSaAhxSHppTdlNK2xUKq5AOwuS8A/3ur7SsMGasmMXTgQ/ElkrlHSZDvub4A89EMxfCMKrutIDPXSdpgYkmAvMFBsop+il/HJwWLc14xiNRsod4XVV5143M3pGg1wNKCifl2tTjbgoho9kFyso6RFkK28Qy3oSqZ+Sdw346M6jD6r2JVm7xsQZI7a5iR2Uq3PESkjkTP0= + on: + tags: true + condition: $BUILD = True diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..00d68a7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +CHANGELOG +========= + +For more details refer to the [documentation](https://softwarequtech.github.io/SimulaQron/html/index.html). + +Upcoming +-------- + +2019-05-29 (v3.0.2) +------------------- +- Updated coinflip example and added CI. diff --git a/cqc/__init__.py b/cqc/__init__.py index b7a5531..da4039b 100644 --- a/cqc/__init__.py +++ b/cqc/__init__.py @@ -1 +1 @@ -__version__ = '3.0.1' +__version__ = '3.0.2' diff --git a/cqc/pythonLib.py b/cqc/pythonLib.py index f7a1351..8c4aa6a 100644 --- a/cqc/pythonLib.py +++ b/cqc/pythonLib.py @@ -97,7 +97,7 @@ from simulaqron.settings import simulaqron_settings _simulaqron_version = simulaqron.__version__ _simulaqron_major = int(_simulaqron_version.split('.')[0]) -except ModuleNotFoundError: +except ImportError: _simulaqron_major = -1 diff --git a/examples/pythonLib/coinflipLeader/README.txt b/examples/pythonLib/coinflipLeader/README.txt index 77795dd..6b17bec 100644 --- a/examples/pythonLib/coinflipLeader/README.txt +++ b/examples/pythonLib/coinflipLeader/README.txt @@ -2,13 +2,28 @@ ## How to run +First make sure that simulaqron is started with the nodes you'd want to include. +This can be done with for example `simulaqron start` which by default starts a network +with the nodes Alice, Bob, Charlie, David and Eve. +Note that you need to be using either the qutip or projectq backend, since single-qubit +rotations are used which are not supported in stabilizer formalism. +To change the backend do `simulaqron set backend projectq`, which of course requires projectq +to be installed (`pip install projectq`). + +In this folder there is both an example with the four nodes Alice, Bob, Charlie and David +and one where you can dynamically choose the nodes that the example uses. + +To start either of the examples do +``` +python3 fourPartyCoinFlip.py +``` +or ``` -sh $NETSIM/run/startAll.sh -./run.sh +python3 nPartyCoinFlip.py ``` -Note that you need to give the nodes a few seconds to start up after running -the first command. +When running `nPartyCoinFlip.py` fill in the names you want to use (note that these needs to +be in the current running network) and press enter when you're finished. ## Explanation diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py new file mode 100644 index 0000000..b01041f --- /dev/null +++ b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py @@ -0,0 +1,33 @@ +from cqc.pythonLib_protocols.coinflip_leader import CoinflipConsensus + + +def main(): + + leaderChooser = CoinflipConsensus(arr) # Elects a leader from array that you declared + return leaderChooser.leader() + +# For 12-13-14-15 lines: After seeing "Add person" sentence, you can add person that how many person you want to add. +# After adding one person you should press "enter" and then you can continue to add person with press enter +# If you want to cancel from adding person you should press enter again +# After enter the all name that you wanted to add you should press "enter" +# Note that: you should use name from cqc's names space such as Alice, Bob, David, Eve Charlie.., you cant't use name randomly such as Gozde, Axel ... +arr = [] # Here an empty array was defined +veri = input("Add person") +while veri: + arr.append(veri) + veri = input("Add person") + + +# giving a value for each leader +d = dict() +for veri in arr: + d[veri] = 0 + +# Runs 20 rounds of leader election and prints the results. +for i in range(0, 20): + if i % 10 == 0: + print(i) + d[main()] += 1 + + +print(d)