The following installation guide is generic and therefore needs to be adapted to the particular package that you want to install. This is easily done by replacing:
- The template repo url
https://github.com/pedrorrivero/pyproject-qiskit.git
with the url of the remote git repository hosting the package (e.g.https://github.com/Qiskit-Extensions/staged-primitives.git
). - The template name
pyproject-qiskit
with the name of the desired package (e.g.staged-primitives
). - The template import name
pyproject_qiskit
with the import name of the desired package (e.g.staged_primitives
).
To follow along, make sure that your local environment is compatible with the package:
- Supported operating system (Linux, macOS, or Windows).
- Supported Python version (3.8 – 3.11).
- (Optional) We recommend updating
pip
to its latest version:pip install -U pip
- Setting up a Python environment
- Basic PyPI installation
- Installation from source
- Optional dependencies
- Testing the installation
Although not strictly required, it can be useful to create a new virtual environment with a custom name (here referred to as <VENV-NAME>
, common names are venv
and .venv
) to avoid dependency conflicts. We recommend using the latest Python version supported by the package. There are several alternatives to do this within the terminal:
- Using
venv
from the python standard library:To deactivate and delete the virtual environment afterwards do:python -m venv <VENV-NAME> source <VENV-NAME>/bin/activate
deactivate rm -r <VENV-NAME>
- Using
virtualenv
after installation:To deactivate and delete the virtual environment afterwards do:python -m virtualenv <VENV-NAME> source <VENV-NAME>/bin/activate
deactivate rm -r <VENV-NAME>
- Using
conda
after installing Miniconda:To deactivate and delete the virtual environment afterwards do:conda create -n <VENV-NAME> python=<PYTHON-VERSION> conda activate <VENV-NAME>
conda deactivate conda env remove -n <VENV-NAME>
The easiest way to install this package is from the PyPI public repository. This will install the latest stable version available, which will provide a higher level of robustness, although patches and updates might take longer to be available. From the terminal, use pip to install the package:
pip install pyproject-qiskit
To update the package to its latest release (i.e. at a later point in time):
pip install -U pyproject-qiskit
To get the latest features and patches as soon as they are released, or to contribute, you will need to install from source. Please note that bleeding-edge software is less tested and therefore more likely to include bugs despite our best efforts.
- Make sure you have git installed for version control.
- From the terminal, clone the repository. This will add the provided URL to the list of remotes under the name
origin
:Alternatively, instead of cloning the original repository, you may choose to clone your personal fork —provided that this functionality is enabled. You can do so by using the appropriate URL and adding the original repository to the list of remotes (here under the namegit clone https://github.com/pedrorrivero/pyproject-qiskit.git
upstream
). This will be required for contribution unless you are granted write permissions for the original repository.git clone <YOUR-FORK-URL> git remote add upstream https://github.com/pedrorrivero/pyproject-qiskit.git
- Change directory to the freshly cloned repository:
cd pyproject-qiskit
- Install the package and required dependencies:
pip install .
- (Optional) If you plan to make changes to the code, you can install it in editable mode by passing the
-e
flag to thepip install
command. This will slightly impact performance, but it will also make sure that you do not need to reinstall the package after every edit for it to work as intended. This is also useful in order to pull new versions and updates from the repository without need to reinstall.pip install -e .
- To update the package to its latest release (i.e. at a later point in time) you will need to pull new changes to the source code from the desired remote repository (e.g.
origin
,upstream
). From the local directory holding the cloned repository (i.e. usecd
) run:If you did not install in editable mode, after this, you will also need to reinstall:git pull <REMOTE-REPO> main
This last command can be skipped by installing the package in editable mode.pip install .
For users:
notebook
→ for jupyter notebooks (e.g.jupyter
)
For developers:
dev
→ for development (e.g.tox
)test
→ for testing (e.g.pytest
)lint
→ for lint checks (e.g.pylint
)docs
→ for documentation (e.g.sphinx
)
If you wish to install any of these bundles of optional dependencies (e.g. <OPT-BUN>
) from PyPI use the following format in your installation/update commands:
pip install [-U] pyproject-qiskit[<OPT-BUN>]
Or, for multiple optional bundles:
pip install [-U] pyproject-qiskit[<OPT-BUN-1>,<OPT-BUN-2>]
If running zsh
on the terminal (e.g. default shell on macOS devices), you will instead need to enclose the target in between quotation marks:
pip install [-U] "pyproject-qiskit[<OPT-BUN>]"
This can be checked by running the following command:
echo $0
The same format can be used for installation of these bundles from source by simply substituting pyproject-qiskit
for .
in the install commands. For example:
pip install .[<OPT-BUN-1>,<OPT-BUN-2>]
Editable mode can also be enabled:
pip install -e ".[<OPT-BUN-1>,<OPT-BUN-2>]"
Users may now run the demo notebooks on their local machine (optional dependencies apply), or use the package in their own software by simply importing it:
import pyproject_qiskit
From the terminal:
$ python
Python 3.10.5 (main, Jun 23 2022, 17:15:25) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyproject_qiskit
>>> print(pyproject_qiskit)
<module 'pyproject_qiskit' from '.venv/lib/python3.10/site-packages/pyproject_qiskit/__init__.py'>
For instructions on how to use this package see here.