From ea9a5e524c1ff36791d30d33d363d5caa557a5e0 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 17 Aug 2023 15:56:28 -0400 Subject: [PATCH] Factor prefer wheels deps into new `ahot_overrides` Makes it easier to pass the overrides to multiple p2n functions (like hopefully `.mkPoetryEnv`). Also, add some commented attempts at using `mkPoetryEnv` and todo list for "why", remove the `poetry` CLI main point from the pyproject.toml, bump the poetry lock file. --- flake.lock | 6 +-- flake.nix | 131 +++++++++++++++++++++++++++++-------------------- poetry.lock | 49 +++++++++++++++--- pyproject.toml | 2 +- 4 files changed, 125 insertions(+), 63 deletions(-) diff --git a/flake.lock b/flake.lock index 98a129f7..b51fe28a 100644 --- a/flake.lock +++ b/flake.lock @@ -59,11 +59,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1692084312, - "narHash": "sha256-Za++qKVK6ovjNL9poQZtLKRM/re663pxzbJ+9M4Pgwg=", + "lastModified": 1692174805, + "narHash": "sha256-xmNPFDi/AUMIxwgOH/IVom55Dks34u1g7sFKKebxUm0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8353344d3236d3fda429bb471c1ee008857d3b7c", + "rev": "caac0eb6bdcad0b32cb2522e03e4002c8975c62e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index efe50d05..6a460812 100644 --- a/flake.nix +++ b/flake.nix @@ -82,16 +82,53 @@ ) pypkgs-build-requirements ); - in - { - # let - # devEnv = poetry2nix.mkPoetryEnv { - # projectDir = ./.; - # }; + # override some ahead-of-time compiled extensions + # to be built with their wheels. + ahot_overrides = p2n-overrides.extend( + final: prev: { + # llvmlite = prev.llvmlite.override { + # preferWheel = false; + # }; + + # TODO: get this workin with p2n and nixpkgs.. + # pyqt6 = prev.pyqt6.override { + # preferWheel = true; + # }; + + # NOTE: this DOESN'T work atm but after a fix + # to poetry2nix, it will and actually this line + # won't be needed - thanks @k900: + # https://github.com/nix-community/poetry2nix/pull/1257 + pyqt5 = prev.pyqt5.override { + withWebkit = false; + preferWheel = true; + }; + + # see PR from @k900: + # https://github.com/nix-community/poetry2nix/pull/1257 + # pyqt5-qt5 = prev.pyqt5-qt5.override { + # withWebkit = false; + # preferWheel = true; + # }; + + # TODO: patch in an override for polars to build + # from src! See the details likely needed from + # the cryptography entry: + # https://github.com/nix-community/poetry2nix/blob/master/overrides/default.nix#L426-L435 + polars = prev.polars.override { + preferWheel = true; + }; + } + ); + + # WHY!? -> output-attrs that `nix develop` scans for: + # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html#flake-output-attributes + in { packages = { # piker = poetry2nix.legacyPackages.x86_64-linux.mkPoetryEditablePackage { # editablePackageSources = { piker = ./piker; }; + piker = p2npkgs.mkPoetryApplication { projectDir = projectDir; @@ -99,55 +136,43 @@ # buncha deps with extras.. like `setuptools` mostly. # TODO: maybe propose a patch to p2n to show that you # can even do this in the edgecases docs? - overrides = p2n-overrides.extend( - final: prev: { + overrides = ahot_overrides; - # TODO: get this workin with p2n and nixpkgs.. - # pyqt6 = prev.pyqt6.override { - # preferWheel = true; - # }; - - # NOTE: this DOESN'T work atm but after a fix - # to poetry2nix, it will and actually this line - # won't be needed - thanks @k900: - # https://github.com/nix-community/poetry2nix/pull/1257 - pyqt5 = prev.pyqt5.override { - withWebkit = false; - preferWheel = true; - }; - - # see PR from @k900: - # https://github.com/nix-community/poetry2nix/pull/1257 - # pyqt5-qt5 = prev.pyqt5-qt5.override { - # withWebkit = false; - # preferWheel = true; - # }; - - # TODO: patch in an override for polars to build - # from src! See the details likely needed from - # the cryptography entry: - # https://github.com/nix-community/poetry2nix/blob/master/overrides/default.nix#L426-L435 - polars = prev.polars.override { - preferWheel = true; - }; - } - ); + # XXX: won't work on llvmlite.. + # preferWheels = true; }; - }; + }; - # output-attr that `nix-develop` scans for: - # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html#flake-output-attributes - devShells.default = pkgs.mkShell { - # packages = [ poetry2nix.packages.${system}.poetry ]; - packages = [ poetry2nix.packages.x86_64-linux.poetry ]; - inputsFrom = [ self.packages.x86_64-linux.piker ]; + devShells.default = pkgs.mkShell { + # packages = [ poetry2nix.packages.${system}.poetry ]; + packages = [ poetry2nix.packages.x86_64-linux.poetry ]; + inputsFrom = [ self.packages.x86_64-linux.piker ]; - # TODO: boot xonsh inside the poetry virtualenv when - # defined via a custom entry point? - # NOTE XXX: apparently DON'T do these..? - # shellHook = "poetry run xonsh"; - # shellHook = "poetry shell"; - }; - } - ); + # TODO: boot xonsh inside the poetry virtualenv when + # defined via a custom entry point? + # NOTE XXX: apparently DON'T do these..? + # shellHook = "poetry run xonsh"; + # shellHook = "poetry shell"; + }; + + + # TODO: grok the difference here.. + # - avoid re-cloning git repos on every develop entry.. + # - ideally allow hacking on the src code of some deps + # (tractor, pyqtgraph, tomlkit, etc.) WITHOUT having to + # re-install them every time a change is made. + + # devShells.default = (p2npkgs.mkPoetryEnv { + # # let { + # # devEnv = p2npkgs.mkPoetryEnv { + # projectDir = projectDir; + # overrides = ahot_overrides; + # inputsFrom = [ self.packages.x86_64-linux.piker ]; + # }).env.overrideAttrs (old: { + # buildInputs = [ packages.piker ]; + # } + # ); + + } + ); # end of .outputs scope } diff --git a/poetry.lock b/poetry.lock index c2047d86..7c839dff 100644 --- a/poetry.lock +++ b/poetry.lock @@ -179,13 +179,13 @@ pycparser = "*" [[package]] name = "click" -version = "8.1.6" +version = "8.1.7" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" files = [ - {file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"}, - {file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"}, + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, ] [package.dependencies] @@ -410,6 +410,25 @@ files = [ {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, ] +[[package]] +name = "importlib-metadata" +version = "6.8.0" +description = "Read metadata from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_metadata-6.8.0-py3-none-any.whl", hash = "sha256:3ebb78df84a805d7698245025b975d9d67053cd94c79245ba4b3eb694abe68bb"}, + {file = "importlib_metadata-6.8.0.tar.gz", hash = "sha256:dbace7892d8c0c4ac1ad096662232f831d4e64f4c4545bd53016a3e9d4654743"}, +] + +[package.dependencies] +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] + [[package]] name = "keysymdef" version = "1.2.0" @@ -1108,17 +1127,20 @@ sortedcontainers = "*" [[package]] name = "trio-typing" -version = "0.8.0" +version = "0.9.0" description = "Static type checking support for Trio and related projects" optional = false python-versions = "*" files = [ - {file = "trio-typing-0.8.0.tar.gz", hash = "sha256:f14264a27b45cec5dabd25b686255ac7d841984200c54b2057bc98a099318a97"}, - {file = "trio_typing-0.8.0-py3-none-any.whl", hash = "sha256:3734fa3f61cab047fdc97aa0030c72e910455cf85f18ca18c3ff336781b144bb"}, + {file = "trio-typing-0.9.0.tar.gz", hash = "sha256:678d4879205c4d28cbf458cf8a7c60d6feaed0fabfa8bb2129235f769b6df3ec"}, + {file = "trio_typing-0.9.0-py3-none-any.whl", hash = "sha256:219e73f72f07fbc97e7019dad3bd49a8bf13d2e53136f3467ae2ee1fcca7a0b9"}, ] [package.dependencies] +async-generator = "*" +importlib-metadata = "*" mypy-extensions = ">=0.4.2" +packaging = "*" trio = ">=0.16.0" typing-extensions = ">=3.7.4" @@ -1323,6 +1345,21 @@ ptk = ["prompt-toolkit (>=3.0.29)", "pyperclip"] pygments = ["pygments (>=2.2)"] test = ["coverage (>=5.3.1)", "prompt-toolkit (>=3.0.29)", "pygments (>=2.2)", "pyte (>=0.8.0)", "pytest (>=7)", "pytest-cov", "pytest-mock", "pytest-rerunfailures", "pytest-subprocess", "pytest-timeout", "restructuredtext-lint", "virtualenv (>=20.16.2)", "xonsh[bestshell]"] +[[package]] +name = "zipp" +version = "3.16.2" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.8" +files = [ + {file = "zipp-3.16.2-py3-none-any.whl", hash = "sha256:679e51dd4403591b2d6838a48de3d283f3d188412a9782faadf845f298736ba0"}, + {file = "zipp-3.16.2.tar.gz", hash = "sha256:ebc15946aa78bd63458992fc81ec3b6f7b1e92d51c35e6de1c3804e73b799147"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] + [metadata] lock-version = "2.0" python-versions = "^3.10" diff --git a/pyproject.toml b/pyproject.toml index 32233799..e4913153 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] -poetry = "poetry.console.application:main" +# poetry = "poetry.console.application:main" piker = 'piker.cli:cli' pikerd = 'piker.cli:pikerd' ledger = 'pikerd.accounting.cli:ledger'