diff --git a/README.md b/README.md index 9dc494c..aa63bd8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,39 @@ The design goals are to have: - Minimizes *a priori* knowledge that is needed of the internal heirarchical structure, reducing friction for users to load data. - Transparently return both raw and processed data, where the levels of post-processing can be selected by the user. -To install, +## Installation + +### Using pip +To install using pip: ```bash pip install git+https://github.com/OpenQuantumDesign/oqd-dataschema.git ``` + +### Using Nix + +If you have Nix package manager with flakes enabled, you can install and use this package directly from the repository: + +```bash +# Run in a development shell +nix develop github:OpenQuantumDesign/oqd-dataschema + +# Or install the package +nix profile install github:OpenQuantumDesign/oqd-dataschema +``` + +#### Development Environment + +For development, clone the repository and use the provided development shell: + +```bash +git clone https://github.com/OpenQuantumDesign/oqd-dataschema.git +cd oqd-dataschema +nix develop +``` + +This will provide you with a complete development environment including: +- All runtime dependencies (pydantic, h5py, bidict) +- Development tools (black, ruff, mypy) +- Documentation tools (mkdocs with required extensions) + +The development shell automatically sets up your PYTHONPATH and provides all necessary tools to build, test, and document the project. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bcaa61c --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1747327360, + "narHash": "sha256-LSmTbiq/nqZR9B2t4MRnWG7cb0KVNU70dB7RT4+wYK4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e06158e58f3adee28b139e9c2bcfcc41f8625b46", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7d15b2d --- /dev/null +++ b/flake.nix @@ -0,0 +1,70 @@ +# 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 Data Schema"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + python = pkgs.python311; + pythonPackages = python.pkgs; + in + { + packages.default = pythonPackages.callPackage ./pkgs/derivation.nix { }; + + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + # Python with dependencies + (python.withPackages (ps: with ps; [ + # Core dependencies + pydantic + h5py + bidict + + # Documentation dependencies + pymdown-extensions + mkdocstrings + mkdocs-material + mkdocstrings-python + mdx-truly-sane-lists + + # Test dependencies + pytest + + # Development tools + pip + black + ruff + mypy + ])) + + # Additional development tools + git + ]; + + shellHook = '' + export PYTHONPATH="$PWD/src:$PYTHONPATH" + echo "OpenQuantum Design Data Schema development environment" + echo "Python version: $(python --version)" + ''; + }; + } + ); +} diff --git a/pkgs/derivation.nix b/pkgs/derivation.nix new file mode 100644 index 0000000..7ca4aba --- /dev/null +++ b/pkgs/derivation.nix @@ -0,0 +1,64 @@ +# 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 +, h5py +, bidict +, pytest +, pymdown-extensions +, mkdocstrings +, mkdocs-material +, mkdocstrings-python +, mdx-truly-sane-lists +}: + +buildPythonPackage rec { + pname = "oqd-dataschema"; + version = "0.1.0"; + format = "pyproject"; + + disabled = pythonOlder "3.10"; + + src = ./..; + + propagatedBuildInputs = [ + pydantic + h5py + bidict + ]; + + checkInputs = [ + pytest + ]; + + nativeBuildInputs = [ + pymdown-extensions + mkdocstrings + mkdocs-material + mkdocstrings-python + mdx-truly-sane-lists + ]; + + pythonImportsCheck = [ "oqd_dataschema" ]; + + meta = with lib; { + description = "OpenQuantum Design Data Schema"; + homepage = "https://github.com/OpenQuantumDesign/oqd-dataschema"; + license = licenses.asl20; + maintainers = with maintainers; [ ]; + }; +}