Skip to content
Open
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
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

## Installation <a name="installation"></a>

### Using pip
```bash
pip install oqd-core
```
Expand All @@ -23,7 +24,36 @@ or through `git`,
pip install git+https://github.com/OpenQuantumDesign/oqd-core.git
```

To develop, clone the repository locally:
### Using Nix
If you have Nix installed with flakes enabled, you can create a development environment with all dependencies using:

```bash
# Clone the repository
git clone https://github.com/OpenQuantumDesign/oqd-core
cd oqd-core

# Enter the development shell with all dependencies
nix develop

# You can also directly develop without cloning using:
nix develop github:OpenQuantumDesign/oqd-core

# Once in the development shell, you can:
# 1. Run tests: pytest
# 2. Build documentation: mkdocs serve
# 3. Use the package directly in Python

# The development environment includes:
# - Python with all required dependencies
# - Development tools (ruff, black, isort, mypy)
# - Documentation tools (mkdocs)
# - Testing tools (pytest)
```

The `nix develop` command will create an isolated development environment with all the necessary dependencies. This is the recommended way to develop and contribute to the project, as it ensures a consistent development environment across all contributors.

### Development Installation
To develop without Nix, clone the repository locally:

```bash
git clone https://github.com/OpenQuantumDesign/oqd-core
Expand Down Expand Up @@ -152,4 +182,3 @@ block-beta

class Interface,IRAnalog,IRAtomic highlight
```
The stack components highlighted in red are contained in this repository.
117 changes: 117 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2024-2025 Open Quantum Design

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
description = "OpenQuantum Design Core Library";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
oqd-compiler-infrastructure = {
url = "github:OpenQuantumDesign/oqd-compiler-infrastructure/Mahmoud-Yasser-18-patch-1";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, oqd-compiler-infrastructure }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python311;
pythonPackages = python.pkgs;
oqdCompilerInfra = oqd-compiler-infrastructure.packages.${system}.default;
in
{
packages.default = pythonPackages.callPackage ./pkgs/derivation.nix {
inherit (pythonPackages) setuptools;
oqd-compiler-infrastructure = oqdCompilerInfra;
};

devShells.default = pkgs.mkShell {
packages = with pkgs; [
# Python with dependencies
(python.withPackages (ps: with ps; [
# Core dependencies
pydantic
numpy

# Documentation dependencies
pymdown-extensions
mkdocstrings
mkdocs-material
mkdocstrings-python
mdx-truly-sane-lists

# Test dependencies
pytest

# Development tools
pip
black
isort
mypy
]))
oqdCompilerInfra

# Additional development tools
git
];

shellHook = ''
export PYTHONPATH="$PWD/src:$PYTHONPATH"
echo "OpenQuantum Design Core Library development environment"
echo "Python version: $(python --version)"
'';
};
}
);
}
66 changes: 66 additions & 0 deletions pkgs/derivation.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2024-2025 Open Quantum Design

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{ lib
, buildPythonPackage
, pythonOlder
, pydantic
, numpy
, pytest
, pymdown-extensions
, mkdocstrings
, mkdocs-material
, mkdocstrings-python
, mdx-truly-sane-lists
, oqd-compiler-infrastructure
, setuptools
}:

buildPythonPackage rec {
pname = "oqd-core";
version = "0.1.0";
format = "pyproject";

disabled = pythonOlder "3.10";

src = ./..;

propagatedBuildInputs = [
pydantic
numpy
oqd-compiler-infrastructure
];

checkInputs = [
pytest
];

nativeBuildInputs = [
pymdown-extensions
mkdocstrings
mkdocs-material
mkdocstrings-python
mdx-truly-sane-lists
setuptools
];

pythonImportsCheck = [ "oqd_core" ];

meta = with lib; {
description = "OpenQuantum Design Core Library";
homepage = "https://github.com/OpenQuantumDesign/oqd-core";
license = licenses.asl20;
maintainers = with maintainers; [ ];
};
}
Loading