From 6146320250dc4be78e815fe1183bbeb58a9a5593 Mon Sep 17 00:00:00 2001 From: "Reza (Shahin) Khanipour" Date: Wed, 17 Jul 2024 15:55:42 +0200 Subject: [PATCH] refactor(python): install dependencies inside the virtualenv. This is in order to prevent long compilation time required for development dependencies. --- devenv.nix | 23 ++++++++----------- pyproject.toml | 3 ++- .../devenv.nix.jinja | 21 ++++++++--------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/devenv.nix b/devenv.nix index b0c7e1d..1667b17 100644 --- a/devenv.nix +++ b/devenv.nix @@ -6,24 +6,21 @@ ... }: -let - python-packages = - p: with p; [ - python-lsp-server - importmagic - epc - ]; -in { # https://devenv.sh/packages/ - packages = with pkgs; [ - pdm - (python3.withPackages python-packages) - ]; + packages = with pkgs; [ ]; languages.python = { enable = true; - venv.enable = true; + venv = { + enable = true; + requirements = '' + pdm + python-lsp-server + importmagic + epc + ''; + }; }; # Make diffs fantastic diff --git a/pyproject.toml b/pyproject.toml index 9ccb752..5770a6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,11 +4,12 @@ version = "1.0.0" description = "Default template for PDM package" authors = [ {name = "Reza (Shahin) Khanipour", email = "shahin@DataChef.co"}, + {name = "Reza (Shahin) Khanipour", email = "shahin@datachef.co"}, ] dependencies = [ "copier>=9.3.1", ] -requires-python = "==3.12.*" +requires-python = "==3.11.*" readme = "README.md" license = {text = "MIT"} diff --git a/template/{% if language == 'Python' %}{{ project_name }}{% endif %}/devenv.nix.jinja b/template/{% if language == 'Python' %}{{ project_name }}{% endif %}/devenv.nix.jinja index c837eaf..1fa8b8a 100644 --- a/template/{% if language == 'Python' %}{{ project_name }}{% endif %}/devenv.nix.jinja +++ b/template/{% if language == 'Python' %}{{ project_name }}{% endif %}/devenv.nix.jinja @@ -1,16 +1,5 @@ {% extends pathjoin("includes", "base.nix.jinja") %} -{% block variables %} -let - python-packages = - p: with p; [ - python-lsp-server - importmagic - epc - ]; -in -{% endblock %} - {% block packages %} pdm (python3.withPackages python-packages) @@ -19,7 +8,15 @@ in {% block languages %} python = { enable = true; - venv.enable = true; + venv = { + enable = true; + requirements = '' +pdm +python-lsp-server +importmagic +epc +''; + }; }; {% endblock %}