From d4ae65bb30f9bf1a119bc65a361fd1db27c5eae5 Mon Sep 17 00:00:00 2001 From: Jonathan Berrisch Date: Tue, 28 Oct 2025 11:08:30 +0100 Subject: [PATCH] Init --- .gitignore | 2 ++ README.md | 31 +++++++++++++++++++++++++++++++ entsoe-apy.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++++++++++++++++++++ xsdata-pydantic.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 176 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 entsoe-apy.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 xsdata-pydantic.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09ffb76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +.direnv/* \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..038753a --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Test the build of packages + +```sh +❯ nix build .#entsoe-apy.src +❯ nix build .#entsoe-apy +``` + +# Enter a development shell + +```sh +❯ nix develop +❯ pip show entsoe-apy +Name: entsoe-apy +Version: 0.4.0 +Summary: A Python library for accessing ENTSO-E Transparency Platform API endpoints +``` + +# Inspect flake + +```sh +❯ nix flake show +warning: Git tree '/home/jonathan/git/NIX/packaging' is dirty +git+file:///home/jonathan/git/NIX/packaging +├───devShells +│ └───x86_64-linux +│ └───default: development environment 'Python-ENTSOE-Dev' +└───packages + └───x86_64-linux + ├───entsoe-apy: package 'python3.13-entsoe-apy-0.4.0' + └───xsdata-pydantic: package 'python3.13-xsdata-pydantic-24.5' +``` \ No newline at end of file diff --git a/entsoe-apy.nix b/entsoe-apy.nix new file mode 100644 index 0000000..751f2cd --- /dev/null +++ b/entsoe-apy.nix @@ -0,0 +1,45 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + pytestCheckHook, + httpx, + loguru, + xsdata-pydantic, +}: + +buildPythonPackage rec { + pname = "entsoe-apy"; + version = "0.4.0"; + + src = fetchFromGitHub { + owner = "berrij"; + repo = "entsoe-apy"; + rev = "cb4ebd4ed401268e605b5267347e0e934d048883"; + hash = "sha256-M0W0r7ApJKG0wMczC0kp/jNOa+PcgVGadvEOSQ2hRkU="; + }; + + pyproject = true; + build-system = [ setuptools ]; + + dependencies = [ + httpx + loguru + xsdata-pydantic + ]; + + nativeCheckInputs = [ pytestCheckHook ]; + + pythonImportsCheck = [ + "entsoe" + ]; + + meta = { + description = "Python Package to Query the ENTSO-E API"; + homepage = "https://github.com/berrij/entsoe-apy"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ berrij ]; + platforms = lib.platforms.all; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9226210 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1759632233, + "narHash": "sha256-krgZxGAIIIKFJS+UB0l8do3sYUDWJc75M72tepmVMzE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d7f52a7a640bc54c7bb414cca603835bf8dd4b10", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..34e3d68 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + system = "x86_64-linux"; # Adjust if necessary + pkgs = import nixpkgs { + inherit system; + }; + + in + { + packages.${system} = { + xsdata-pydantic = pkgs.python313Packages.callPackage ./xsdata-pydantic.nix { }; + entsoe-apy = pkgs.python313Packages.callPackage ./entsoe-apy.nix { + xsdata-pydantic = self.packages.${system}.xsdata-pydantic; + }; + }; + + devShells.${system} = { + default = pkgs.mkShell { + name = "packaging"; + venvDir = "./.venv"; + buildInputs = [ pkgs.python313Packages.pip ] ++ builtins.attrValues self.packages.${system}; + }; + }; + }; +} diff --git a/xsdata-pydantic.nix b/xsdata-pydantic.nix new file mode 100644 index 0000000..b95701a --- /dev/null +++ b/xsdata-pydantic.nix @@ -0,0 +1,40 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + xsdata, + pydantic, +}: + +buildPythonPackage rec { + pname = "xsdata-pydantic"; + version = "24.5"; + pyproject = true; + + src = fetchFromGitHub { + owner = "tefra"; + repo = "xsdata-pydantic"; + tag = "v${version}"; + hash = "sha256-ExgAXQRNfGQRSZdMuWc8ldJPqz+3c4Imgu75KXLXHNk="; + }; + + build-system = [ setuptools ]; + + dependencies = [ + xsdata + pydantic + ]; + + pythonImportsCheck = [ + "xsdata_pydantic" + ]; + + meta = { + description = "Naive XML & JSON Bindings for python pydantic classes!"; + homepage = "https://github.com/tefra/xsdata-pydantic"; + maintainers = with lib.maintainers; [ berrij ]; + license = lib.licenses.mit; + platforms = lib.platforms.all; + }; +}