From 8c0bd9bbe9f8ef184a94f33ef842feb6d05f78b9 Mon Sep 17 00:00:00 2001 From: Lukas Einhaus Date: Wed, 27 Nov 2024 14:09:04 +0100 Subject: [PATCH] chore: replace flake.nix by devenv --- .envrc | 3 ++ .gitignore | 12 +++++ devenv.lock | 132 ++++++++++++++++++++++++++++++++++++++++++++++ devenv.nix | 85 +++++++++++++++++++++++++++++ devenv.yaml | 16 ++++++ pyproject.toml | 15 +++++- uvPython3.12.lock | 1 + 7 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 .envrc create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml create mode 120000 uvPython3.12.lock diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..894571bf --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k=" + +use devenv diff --git a/.gitignore b/.gitignore index dc10f9ad..a25e3c0e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ simulation simulation/* node_modules .mypy_cache +.pytest_cache +.venv +build/ package-lock.json .coverage @@ -247,3 +250,12 @@ Temporary Items /presentation/presentation.html /presentation/presentation.pdf /vhdl93-bnf.html +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 00000000..a55b2d78 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,132 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1732585607, + "owner": "cachix", + "repo": "devenv", + "rev": "a520f05c40ebecaf5e17064b27e28ba8e70c49fb", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1731797254, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1732238832, + "owner": "nixos", + "repo": "nixpkgs", + "rev": "8edf06bea5bcbee082df1b7369ff973b91618b8d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1732021966, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 00000000..55dcffde --- /dev/null +++ b/devenv.nix @@ -0,0 +1,85 @@ +{ + pkgs, + lib, + config, + inputs, + ... +}: + +let + unstablePkgs = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; }; + rosettaPkgs = + if unstablePkgs.stdenv.isDarwin && unstablePkgs.stdenv.isAarch64 then + unstablePkgs.pkgsx86_64Darwin + else + unstablePkgs; + pyp = unstablePkgs.python312Packages; +in +{ + + packages = [ + pkgs.git + rosettaPkgs.ghdl + pkgs.gtkwave + pyp.python-lsp-server + pyp.pylsp-mypy + pyp.pylsp-rope + unstablePkgs.mypy + unstablePkgs.ruff + + ]; + + languages.python = { + enable = true; + package = unstablePkgs.python312; + uv.enable = true; + uv.package = unstablePkgs.uv; + uv.sync.enable = true; + uv.sync.allExtras = true; + }; + + tasks = { + "bash:link_uv_lock" = { + exec = "ln -s uvPython3.12.lock uv.lock"; + before = ["devenv:enterShell"]; + status = "[ -L uv.lock ]"; + }; + }; + + pre-commit.hooks = { + shellcheck.enable = true; + ripsecrets.enable = true; # don't commit secrets + ruff.enable = true; # lint and automatically fix simple problems/reformat + taplo.enable = true; # reformat toml + nixfmt-rfc-style.enable = true; # reformat nix + ruff-format.enable = true; + mypy = { + enable = false; + }; # check type annotations + end-of-file-fixer.enable = true; + commitizen.enable = true; # help adhering to commit style guidelines + check-toml.enable = true; # check toml syntax + check-case-conflicts.enable = true; + check-added-large-files.enable = true; + }; + + enterTest = + let + runCommandWithPython = + cmd: + ( + version: + "UV_PROJECT_ENVIRONMENT=.venv_${version} uv run --no-env-file --isolated --noprogress --python ${version} ${cmd}" + ); + runPytest = runCommandWithPython "pytest"; + in + '' + rm uv.lock + if [ -f + ln -s uvPython3.11.lock uv.lock + ${runPytest "python3.11"} + rm uv.lock + ln -s uvPython3.12.lock uv.lock + uv run --python python3.12 pytest + ''; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 00000000..9c305dbb --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,16 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + nixpkgs-unstable: + url: github:nixos/nixpkgs/nixpkgs-unstable +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/pyproject.toml b/pyproject.toml index cdf17f81..5510a0ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,13 +3,23 @@ name = "elasticai.creator" version = "0.59.2" description = "Design, train and compile neural networks optimized specifically for FPGAs." readme = "README.md" -repository = "https://github.com/es-ude/elastic-ai.creator" -author = ["Department Embedded Systems - University Duisburg Essen"] +license = "MIT" +authors = [ + {name = "Intelligent Embedded Systems - University Duisburg Essen"}, + ] + +maintainers = [ + {name = "Lukas Einhaus", email="lukas.einhaus@uni-due.de"}, + {name = "Julian Hoever", email="julian.hoever@uni-due.de"}, {name="Leo Buron", email="leo.buron@uni-due.de"} + ] + dependencies = [ "torch>=1.11", "numpy>=1.23.0", ] requires-python = ">=3.10" +keywords = ["fpga", "embedded", "hw accelerators", "neural networks", "embedded ai", "tinyml"] +repository = "https://github.com/es-ude/elastic-ai.creator" [dependency-groups] dev = [ @@ -17,6 +27,7 @@ dev = [ "mypy>=1.13.0", "pylint>=3.3.1", "pytest>=8.3.3", + "ruff>=0.8.0", "semantic-release>=0.1.0", ] diff --git a/uvPython3.12.lock b/uvPython3.12.lock new file mode 120000 index 00000000..07549fb3 --- /dev/null +++ b/uvPython3.12.lock @@ -0,0 +1 @@ +uv.lock \ No newline at end of file