From 2a44e8cef3b061c44a460cac763348a768f81673 Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Thu, 7 Nov 2024 11:42:17 +0200 Subject: [PATCH] Move to Antlr 4.9 in newer nix-eda --- default.nix | 31 ++++++++---------------------- flake.lock | 20 ++++++++++++++++++- flake.nix | 52 ++++++++++++++++++++++++++------------------------ pyproject.toml | 8 +++----- 4 files changed, 57 insertions(+), 54 deletions(-) diff --git a/default.nix b/default.nix index 5f69ca1..ee17992 100644 --- a/default.nix +++ b/default.nix @@ -1,46 +1,31 @@ { - antlr4_10, - black, lib, + black, nix-gitignore, buildPythonPackage, poetry-core, setuptools, pytest, coverage, + antlr4_9, + antlr4_9-runtime, }: - -let - antlr4_10-python3-runtime = buildPythonPackage rec { - pname = "antlr4-python3-runtime"; - inherit (antlr4_10.runtime.cpp) version src; - - sourceRoot = "source/runtime/Python3"; - - doCheck = false; - - meta = with lib; { - description = "Runtime for ANTLR"; - homepage = "https://www.antlr.org/"; - license = licenses.bsd3; - }; - }; -in buildPythonPackage { +buildPythonPackage { name = "ioplace_parser"; version = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).tool.poetry.version; format = "pyproject"; src = nix-gitignore.gitignoreSourcePure ./.gitignore ./.; - + nativeBuildInputs = [ poetry-core - antlr4_10 + antlr4_9 ]; propagatedBuildInputs = [ - antlr4_10-python3-runtime + antlr4_9-runtime ]; - + nativeCheckInputs = [ pytest black diff --git a/flake.lock b/flake.lock index d0acca4..89a57c5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "nix-eda": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1730972444, + "narHash": "sha256-6wbOkA/YSF4bG9ZQHUm7zURm0ScwTGGWxH3oWjhBZZg=", + "owner": "efabless", + "repo": "nix-eda", + "rev": "faad81bfd90c90a8b61fc1934cb6413f5ec1cc0d", + "type": "github" + }, + "original": { + "owner": "efabless", + "repo": "nix-eda", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1717144377, @@ -18,7 +36,7 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nix-eda": "nix-eda" } } }, diff --git a/flake.nix b/flake.nix index 062c94a..c8604fa 100644 --- a/flake.nix +++ b/flake.nix @@ -13,37 +13,39 @@ # limitations under the License. { inputs = { - nixpkgs.url = github:nixos/nixpkgs/nixos-24.05; + nix-eda.url = github:efabless/nix-eda; }; outputs = { self, - nixpkgs, + nix-eda, ... - }: { - # Helper functions - forAllSystems = function: - nixpkgs.lib.genAttrs [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ] ( - system: - function (import nixpkgs { - inherit system; - }) - ); + }: let + nixpkgs = nix-eda.inputs.nixpkgs; + lib = nixpkgs.lib; + in { + overlays = { + default = lib.composeManyExtensions [ + (nix-eda.composePythonOverlay (pkgs': pkgs: pypkgs': pypkgs: let + callPythonPackage = lib.callPackageWith (pkgs' // pkgs'.python3.pkgs); + in { + ioplace-parser = callPythonPackage ./default.nix {}; + })) + ]; + }; - # Outputs - packages = self.forAllSystems (pkgs: let - callPackage = pkgs.lib.callPackageWith (pkgs // self.packages.${pkgs.system}); - callPythonPackage = pkgs.lib.callPackageWith (pkgs // pkgs.python3.pkgs // self.packages.${pkgs.system}); - in - rec { - ioplace-parser = callPythonPackage ./default.nix {}; - default = ioplace-parser; - } + legacyPackages = nix-eda.forAllSystems ( + system: + import nixpkgs { + inherit system; + overlays = [nix-eda.overlays.default self.overlays.default]; + } ); + + # Outputs + packages = nix-eda.forAllSystems (system: { + inherit (self.legacyPackages.${system}.python3.pkgs) ioplace-parser; + default = self.packages.${system}.ioplace-parser; + }); }; } diff --git a/pyproject.toml b/pyproject.toml index caa6e14..5c4c72d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ioplace_parser" -version = "0.3.0" +version = "0.4.0" description = "Antlr4-based parser for the OpenLane I/O Placement script" readme = "Readme.md" authors = ["Efabless Corporation "] @@ -11,15 +11,13 @@ classifiers = [ "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", ] -include = [ - "_ioplace_parser_antlr/**/*.py" -] +include = ["_ioplace_parser_antlr/**/*.py"] [tool.poetry.build] [tool.poetry.dependencies] python = ">=3.8" -antlr4-python3-runtime = "~=4.10.0" +antlr4-python3-runtime = "~=4.9.0" [tool.poetry.dev-dependencies] wheel = "^0.38"