Skip to content

Commit 9876ae8

Browse files
committed
Readme and linter changes
1 parent 52710b1 commit 9876ae8

5 files changed

Lines changed: 32 additions & 13 deletions

File tree

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ Then you can install Python 3.12 and the Python development package:
2424
```shell
2525
sudo apt-get install python3.12-full python3.12-dev
2626
```
27-
2827
Additionally, you will need the `build-essential` package, to install tools used when building some SimulaQron dependencies:
2928

3029
```shell
3130
sudo apt-get install build-essential cmake vim linux-headers-generic
3231
```
33-
3432
After this point, you should have all the required dependencies.
3533

3634

@@ -64,13 +62,11 @@ by using the Makefile:
6462
```shell
6563
make install
6664
```
67-
6865
Additionally, you can install SimulaQron with extra dependencies:
6966
```shell
7067
make install-optional
7168
```
7269

73-
7470
Finally, if you would like to contribute to the development of SimulaQron, please install the development dependencies:
7571
```shell
7672
make install-development
@@ -94,7 +90,7 @@ In Windows, SimulaQron can be installed in two similar ways:
9490

9591
#### Native installation
9692

97-
SimulaQron has also been tested working on macOS Tahoe (26.5) on an M3 pro CPU.
93+
SimulaQron has also been tested working on macOS Tahoe (26.5) on an M3 Pro CPU.
9894

9995
Before proceeding with the SimulaQron install, you need to install python 3.12, which is available from the
10096
[Homebrew package manager](https://brew.sh/). Once that homebrew has been installed, you can install Python
@@ -104,8 +100,15 @@ Before proceeding with the SimulaQron install, you need to install python 3.12,
104100
brew install python@3.12
105101
```
106102

107-
After this, you can follow the instructions to install SimulaQron either [from PyPI](#installing-from-pypi)
108-
or directly [from this repository](#installing-from-this-repository).
103+
Additionally, to install the optional dependencies, you will need to install *XCode COmmand Line Tools*. To do
104+
so, run the following command in a terminal:
105+
106+
```shell
107+
xcode-select --install
108+
```
109+
110+
And follow the instructions on the screen. After this, you can follow the instructions to install SimulaQron
111+
either [from PyPI](#installing-from-pypi) or directly [from this repository](#installing-from-this-repository).
109112

110113

111114
#### Using the provided virtual machines

simulaqron/cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
Path.mkdir(PID_FOLDER)
2626

2727

28+
# The following two classes (SimulaQronDaemon and RunningSimulaQronDaemon) are 2 classes that
29+
# implement the simulaqron daemon process.
30+
# The former class models a daemon process used to launch the backend processes
31+
# (1 Vnode and 1 QNodeOS process per node starting), and then it simply goes to sleep.
32+
# The latter class is used when invoking "simulaqron stop" to "reattach" to the launching
33+
# daemon process, and kill all the backend processes.
34+
# Both of the mentioned classes rely on the python "daemons" package, **which is designed
35+
# to run on Unix platforms** (Linux/macOS). Implementing a similar behavior in Windows
36+
# will require a heavy reimplementation of these 2 classes.
37+
38+
2839
class RunningSimulaQronDaemon(run.RunDaemon):
2940
"""
3041
SimulaQronDaemon class used to represent SimulaQron daemons that are already running.

simulaqron/network.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,24 @@
2828
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

3030
import random
31+
import sys
3132
import time
3233
from timeit import default_timer as timer
3334
from typing import List, Dict
3435

3536
import networkx as nx
36-
from multiprocess.context import ForkProcess as Process
37+
38+
if sys.platform == "win32":
39+
# Windows does not support "fork", so new processes need to be created with
40+
# the spawn method.
41+
from multiprocess.context import SpawnProcess as Process
42+
else:
43+
from multiprocess.context import ForkProcess as Process
3744
import logging
3845
from pathlib import Path
3946

4047
from simulaqron.settings import network_config
4148
from simulaqron.settings.network_config import NodeConfig
42-
from simulaqron.settings import simulaqron_settings
4349
from simulaqron.start import start_vnode, start_qnodeos
4450
# WARNING - this import *needs* to be after importing start_vnode and start_qnodeos
4551
# Otherwise the code that patches some netqasm internal definitions will not work correctly!

simulaqron/start/start_qnodeos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from timeit import default_timer as timer
66

77
import logging
8-
from twisted.internet.error import ConnectionRefusedError, CannotListenError
8+
from twisted.internet.error import CannotListenError
99
from twisted.spread import pb
1010
from pathlib import Path
1111

@@ -30,7 +30,7 @@ def _init_register(virt_root, my_name: str, node: NetQASMFactory):
3030
_setup_netqasm_server(my_name, node)
3131

3232

33-
def _connect_to_virt_node(my_name: str, netqasm_factory: NetQASMFactory, virtual_network: SocketsConfig, attempt: int = 0):
33+
def _connect_to_virt_node(my_name: str, netqasm_factory: NetQASMFactory, virtual_network: SocketsConfig, attempt: int):
3434
"""Tries to connect to local virtual node.
3535
3636
If connection is refused, we try again after a set amount of time
@@ -178,7 +178,7 @@ def start_qnodeos(node_name: str, network_config_file: Path, network_name: str):
178178

179179
# Connect to the local virtual node simulating the "local" qubits
180180
logger.debug(f"START_QNODEOS: Connect to virtual node {node_name}")
181-
_connect_to_virt_node(node_name, netqasm_factory, virtual_network)
181+
_connect_to_virt_node(node_name, netqasm_factory, virtual_network, 0)
182182

183183
# Run reactor
184184
reactor.run()

simulaqron/virtual_node/virtual.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ def handle_connection_error(self, reason, node: Host):
318318
self._attempt = self._attempt + 1
319319
reactor.callLater(simulaqron_settings.conn_retry_time, self.connect_to_node, node)
320320

321-
322321
def _get_virtual_id(self):
323322
"""
324323
This is a crude and horrible cludge to generate unique IDs for virtual qubits.

0 commit comments

Comments
 (0)