Compare commits
No commits in common. "fa7249eea27a02266fca14420257915a5f72c623" and "d4fe6b77179a43e63043b6c732d69f12b8a6e937" have entirely different histories.
fa7249eea2
...
d4fe6b7717
37
default.nix
37
default.nix
|
|
@ -11,12 +11,11 @@ let
|
||||||
libxkbcommonStorePath = lib.getLib libxkbcommon;
|
libxkbcommonStorePath = lib.getLib libxkbcommon;
|
||||||
xcbutilcursorStorePath = lib.getLib xcb-util-cursor;
|
xcbutilcursorStorePath = lib.getLib xcb-util-cursor;
|
||||||
|
|
||||||
pypkgs = python313Packages;
|
qtpyStorePath = lib.getLib python312Packages.qtpy;
|
||||||
qtpyStorePath = lib.getLib pypkgs.qtpy;
|
pyqt6StorePath = lib.getLib python312Packages.pyqt6;
|
||||||
pyqt6StorePath = lib.getLib pypkgs.pyqt6;
|
pyqt6SipStorePath = lib.getLib python312Packages.pyqt6-sip;
|
||||||
pyqt6SipStorePath = lib.getLib pypkgs.pyqt6-sip;
|
rapidfuzzStorePath = lib.getLib python312Packages.rapidfuzz;
|
||||||
rapidfuzzStorePath = lib.getLib pypkgs.rapidfuzz;
|
qdarkstyleStorePath = lib.getLib python312Packages.qdarkstyle;
|
||||||
qdarkstyleStorePath = lib.getLib pypkgs.qdarkstyle;
|
|
||||||
|
|
||||||
xorgLibX11StorePath = lib.getLib xorg.libX11;
|
xorgLibX11StorePath = lib.getLib xorg.libX11;
|
||||||
xorgLibxcbStorePath = lib.getLib xorg.libxcb;
|
xorgLibxcbStorePath = lib.getLib xorg.libxcb;
|
||||||
|
|
@ -52,12 +51,12 @@ stdenv.mkDerivation {
|
||||||
xorg.xcbutilrenderutil
|
xorg.xcbutilrenderutil
|
||||||
|
|
||||||
# Python requirements.
|
# Python requirements.
|
||||||
python313
|
python312Full
|
||||||
uv
|
python312Packages.uv
|
||||||
pypkgs.qdarkstyle
|
python312Packages.qdarkstyle
|
||||||
pypkgs.rapidfuzz
|
python312Packages.rapidfuzz
|
||||||
pypkgs.pyqt6
|
python312Packages.pyqt6
|
||||||
pypkgs.qtpy
|
python312Packages.qtpy
|
||||||
];
|
];
|
||||||
src = null;
|
src = null;
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
@ -114,11 +113,11 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
export LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH
|
||||||
|
|
||||||
RPDFUZZ_PATH="${rapidfuzzStorePath}/lib/python3.13/site-packages"
|
RPDFUZZ_PATH="${rapidfuzzStorePath}/lib/python3.12/site-packages"
|
||||||
QDRKSTYLE_PATH="${qdarkstyleStorePath}/lib/python3.13/site-packages"
|
QDRKSTYLE_PATH="${qdarkstyleStorePath}/lib/python3.12/site-packages"
|
||||||
QTPY_PATH="${qtpyStorePath}/lib/python3.13/site-packages"
|
QTPY_PATH="${qtpyStorePath}/lib/python3.12/site-packages"
|
||||||
PYQT6_PATH="${pyqt6StorePath}/lib/python3.13/site-packages"
|
PYQT6_PATH="${pyqt6StorePath}/lib/python3.12/site-packages"
|
||||||
PYQT6_SIP_PATH="${pyqt6SipStorePath}/lib/python3.13/site-packages"
|
PYQT6_SIP_PATH="${pyqt6SipStorePath}/lib/python3.12/site-packages"
|
||||||
|
|
||||||
PATCH="$PATCH:$RPDFUZZ_PATH"
|
PATCH="$PATCH:$RPDFUZZ_PATH"
|
||||||
PATCH="$PATCH:$QDRKSTYLE_PATH"
|
PATCH="$PATCH:$QDRKSTYLE_PATH"
|
||||||
|
|
@ -128,8 +127,8 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
export PATCH
|
export PATCH
|
||||||
|
|
||||||
# install all dev and extras
|
# Install deps
|
||||||
uv sync --dev --all-extras
|
uv lock
|
||||||
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
127
flake.lock
127
flake.lock
|
|
@ -1,24 +1,135 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1765779637,
|
"lastModified": 1689068808,
|
||||||
"narHash": "sha256-KJ2wa/BLSrTqDjbfyNx70ov/HdgNBCBBSQP3BIzKnv4=",
|
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||||
"owner": "nixos",
|
"owner": "numtide",
|
||||||
"repo": "nixpkgs",
|
"repo": "flake-utils",
|
||||||
"rev": "1306659b587dc277866c7b69eb97e5f07864d8c4",
|
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1689068808,
|
||||||
|
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix-github-actions": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"poetry2nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688870561,
|
||||||
|
"narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nix-github-actions",
|
||||||
|
"rev": "165b1650b753316aa7f1787f3005a8d2da0f5301",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nix-github-actions",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1692174805,
|
||||||
|
"narHash": "sha256-xmNPFDi/AUMIxwgOH/IVom55Dks34u1g7sFKKebxUm0=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "caac0eb6bdcad0b32cb2522e03e4002c8975c62e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
"ref": "nixos-unstable",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"poetry2nix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
|
"nix-github-actions": "nix-github-actions",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1692048894,
|
||||||
|
"narHash": "sha256-cDw03rso2V4CDc3Mll0cHN+ztzysAvdI8pJ7ybbz714=",
|
||||||
|
"ref": "refs/heads/pyqt6",
|
||||||
|
"rev": "b059ad4c3051f45d6c912e17747aae37a9ec1544",
|
||||||
|
"revCount": 2276,
|
||||||
|
"type": "git",
|
||||||
|
"url": "file:///home/lord_fomo/repos/poetry2nix"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "file:///home/lord_fomo/repos/poetry2nix"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"poetry2nix": "poetry2nix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
235
flake.nix
235
flake.nix
|
|
@ -1,95 +1,180 @@
|
||||||
# An "impure" template thx to `pyproject.nix`,
|
# NOTE: to convert to a poetry2nix env like this here are the
|
||||||
# https://pyproject-nix.github.io/pyproject.nix/templates.html#impure
|
# steps:
|
||||||
# https://github.com/pyproject-nix/pyproject.nix/blob/master/templates/impure/flake.nix
|
# - install poetry in your system nix config
|
||||||
{
|
# - convert the repo to use poetry using `poetry init`:
|
||||||
description = "An impure `piker` overlay using `uv` with Nix(OS)";
|
# https://python-poetry.org/docs/basic-usage/#initialising-a-pre-existing-project
|
||||||
|
# - then manually ensuring all deps are converted over:
|
||||||
|
# - add this file to the repo and commit it
|
||||||
|
# -
|
||||||
|
|
||||||
inputs = {
|
# GROKin tips:
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
# - CLI eps are (ostensibly) added via an `entry_points.txt`:
|
||||||
|
# - https://packaging.python.org/en/latest/specifications/entry-points/#file-format
|
||||||
|
# - https://github.com/nix-community/poetry2nix/blob/master/editable.nix#L49
|
||||||
|
{
|
||||||
|
description = "piker: trading gear for hackers (pkged with poetry2nix)";
|
||||||
|
|
||||||
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
# see https://github.com/nix-community/poetry2nix/tree/master#api
|
||||||
|
inputs.poetry2nix = {
|
||||||
|
# url = "github:nix-community/poetry2nix";
|
||||||
|
# url = "github:K900/poetry2nix/qt5-explicit-deps";
|
||||||
|
url = "/home/lord_fomo/repos/poetry2nix";
|
||||||
|
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = {
|
||||||
{ nixpkgs, ... }:
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
poetry2nix,
|
||||||
|
}:
|
||||||
|
# TODO: build cross-OS and use the `${system}` var thingy..
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
# use PWD as sources
|
||||||
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
|
projectDir = ./.;
|
||||||
in
|
pyproject = ./pyproject.toml;
|
||||||
{
|
poetrylock = ./poetry.lock;
|
||||||
devShells = forAllSystems (
|
|
||||||
system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
|
|
||||||
# do store-path extractions
|
# TODO: port to 3.11 and support both versions?
|
||||||
qt6baseStorePath = lib.getLib pkgs.qt6.qtbase;
|
python = "python3.10";
|
||||||
# ?TODO? can remove below since manual linking not needed?
|
|
||||||
# qt6QtWaylandStorePath = lib.getLib pkgs.qt6.qtwayland;
|
|
||||||
|
|
||||||
# XXX NOTE XXX, for now we overlay specific pkgs via
|
# for more functions and examples.
|
||||||
# a major-version-pinned-`cpython`
|
# inherit
|
||||||
cpython = "python313";
|
# (poetry2nix.legacyPackages.${system})
|
||||||
pypkgs = pkgs."${cpython}Packages";
|
# mkPoetryApplication;
|
||||||
in
|
# pkgs = nixpkgs.legacyPackages.${system};
|
||||||
{
|
|
||||||
default = pkgs.mkShell {
|
|
||||||
|
|
||||||
packages = with pkgs; [
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
qt6.qtwayland
|
lib = pkgs.lib;
|
||||||
qt6.qtbase
|
p2npkgs = poetry2nix.legacyPackages.x86_64-linux;
|
||||||
|
|
||||||
uv
|
# define all pkg overrides per dep, see edgecases.md:
|
||||||
python313 # ?TODO^ how to set from `cpython` above?
|
# https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md
|
||||||
pypkgs.pyqt6
|
# TODO: add these into the json file:
|
||||||
pypkgs.pyqt6-sip
|
# https://github.com/nix-community/poetry2nix/blob/master/overrides/build-systems.json
|
||||||
pypkgs.qtpy
|
pypkgs-build-requirements = {
|
||||||
pypkgs.qdarkstyle
|
asyncvnc = [ "setuptools" ];
|
||||||
pypkgs.rapidfuzz
|
eventkit = [ "setuptools" ];
|
||||||
];
|
ib-insync = [ "setuptools" "flake8" ];
|
||||||
|
msgspec = [ "setuptools"];
|
||||||
|
pdbp = [ "setuptools" ];
|
||||||
|
pyqt6-sip = [ "setuptools" ];
|
||||||
|
tabcompleter = [ "setuptools" ];
|
||||||
|
tractor = [ "setuptools" ];
|
||||||
|
tricycle = [ "setuptools" ];
|
||||||
|
trio-typing = [ "setuptools" ];
|
||||||
|
trio-util = [ "setuptools" ];
|
||||||
|
xonsh = [ "setuptools" ];
|
||||||
|
};
|
||||||
|
|
||||||
shellHook = ''
|
# auto-generate override entries
|
||||||
# unmask to debug **this** dev-shell-hook
|
p2n-overrides = p2npkgs.defaultPoetryOverrides.extend (self: super:
|
||||||
# set -e
|
builtins.mapAttrs (package: build-requirements:
|
||||||
|
(builtins.getAttr package super).overridePythonAttrs (old: {
|
||||||
|
buildInputs = (
|
||||||
|
old.buildInputs or [ ]
|
||||||
|
) ++ (
|
||||||
|
builtins.map (
|
||||||
|
pkg: if builtins.isString pkg then builtins.getAttr pkg super else pkg
|
||||||
|
) build-requirements
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) pypkgs-build-requirements
|
||||||
|
);
|
||||||
|
|
||||||
# set qt-base/plugin path(s)
|
# override some ahead-of-time compiled extensions
|
||||||
QTBASE_PATH="${qt6baseStorePath}/lib"
|
# to be built with their wheels.
|
||||||
QT_PLUGIN_PATH="${qt6baseStorePath}/lib/qt-6/plugins"
|
ahot_overrides = p2n-overrides.extend(
|
||||||
QT_QPA_PLATFORM_PLUGIN_PATH="$QT_PLUGIN_PATH/platforms"
|
final: prev: {
|
||||||
|
|
||||||
# link in Qt cc lib paths from <nixpkgs>
|
# llvmlite = prev.llvmlite.override {
|
||||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QTBASE_PATH"
|
# preferWheel = false;
|
||||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QT_PLUGIN_PATH"
|
# };
|
||||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QT_QPA_PLATFORM_PLUGIN_PATH"
|
|
||||||
|
|
||||||
# link-in c++ stdlib for various AOT-ext-pkgs (numpy, etc.)
|
# TODO: get this workin with p2n and nixpkgs..
|
||||||
LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"
|
# pyqt6 = prev.pyqt6.override {
|
||||||
|
# preferWheel = true;
|
||||||
|
# };
|
||||||
|
|
||||||
export LD_LIBRARY_PATH
|
# 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;
|
||||||
|
};
|
||||||
|
|
||||||
# RUNTIME-SETTINGS
|
# see PR from @k900:
|
||||||
#
|
# https://github.com/nix-community/poetry2nix/pull/1257
|
||||||
# ------ Qt ------
|
# pyqt5-qt5 = prev.pyqt5-qt5.override {
|
||||||
# XXX, unmask to debug qt .so linking/loading deats
|
# withWebkit = false;
|
||||||
# export QT_DEBUG_PLUGINS=1
|
# preferWheel = true;
|
||||||
#
|
# };
|
||||||
# ALSO, for *modern linux* DEs,
|
|
||||||
# - maybe set wayland-mode (TODO, parametrtize this!)
|
|
||||||
# * a chosen wayland-mode shell-integration
|
|
||||||
export QT_QPA_PLATFORM="wayland"
|
|
||||||
export QT_WAYLAND_SHELL_INTEGRATION="xdg-shell"
|
|
||||||
|
|
||||||
# ------ uv ------
|
# TODO: patch in an override for polars to build
|
||||||
# - always use the ./py313/ venv-subdir
|
# from src! See the details likely needed from
|
||||||
export UV_PROJECT_ENVIRONMENT="py313"
|
# the cryptography entry:
|
||||||
# sync project-env with all extras
|
# https://github.com/nix-community/poetry2nix/blob/master/overrides/default.nix#L426-L435
|
||||||
uv sync --dev --all-extras
|
polars = prev.polars.override {
|
||||||
|
preferWheel = true;
|
||||||
# ------ TIPS ------
|
|
||||||
# NOTE, to launch the py-venv installed `xonsh` (like @goodboy)
|
|
||||||
# run the `nix develop` cmd with,
|
|
||||||
# >> nix develop -c uv run xonsh
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# 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
|
||||||
|
rec {
|
||||||
|
packages = {
|
||||||
|
# piker = poetry2nix.legacyPackages.x86_64-linux.mkPoetryEditablePackage {
|
||||||
|
# editablePackageSources = { piker = ./piker; };
|
||||||
|
|
||||||
|
piker = p2npkgs.mkPoetryApplication {
|
||||||
|
projectDir = projectDir;
|
||||||
|
|
||||||
|
# SEE ABOVE for auto-genned input set, override
|
||||||
|
# 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 = ahot_overrides;
|
||||||
|
|
||||||
|
# XXX: won't work on llvmlite..
|
||||||
|
# preferWheels = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# devShells.default = pkgs.mkShell {
|
||||||
|
# projectDir = projectDir;
|
||||||
|
# python = "python3.10";
|
||||||
|
# overrides = ahot_overrides;
|
||||||
|
# inputsFrom = [ self.packages.x86_64-linux.piker ];
|
||||||
|
# packages = packages;
|
||||||
|
# # packages = [ poetry2nix.packages.${system}.poetry ];
|
||||||
|
# };
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
# - boot a usable xonsh inside the poetry virtualenv when
|
||||||
|
# defined via a custom entry point?
|
||||||
|
devShells.default = p2npkgs.mkPoetryEnv {
|
||||||
|
# env = p2npkgs.mkPoetryEnv {
|
||||||
|
projectDir = projectDir;
|
||||||
|
python = pkgs.python310;
|
||||||
|
overrides = ahot_overrides;
|
||||||
|
editablePackageSources = packages;
|
||||||
|
# piker = "./";
|
||||||
|
# tractor = "../tractor/";
|
||||||
|
# }; # wut?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
); # end of .outputs scope
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,6 @@ class Pair(Struct, frozen=True, kw_only=True):
|
||||||
# https://developers.binance.com/docs/binance-spot-api-docs#future-changes
|
# https://developers.binance.com/docs/binance-spot-api-docs#future-changes
|
||||||
pegInstructionsAllowed: bool = False
|
pegInstructionsAllowed: bool = False
|
||||||
|
|
||||||
# https://developers.binance.com/docs/binance-spot-api-docs#2025-12-02
|
|
||||||
opoAllowed: bool = False
|
|
||||||
|
|
||||||
filters: dict[
|
filters: dict[
|
||||||
str,
|
str,
|
||||||
str | int | float,
|
str | int | float,
|
||||||
|
|
@ -223,10 +220,7 @@ class FutesPair(Pair):
|
||||||
assert pair == self.pair # sanity
|
assert pair == self.pair # sanity
|
||||||
return f'{expiry}'
|
return f'{expiry}'
|
||||||
|
|
||||||
case (
|
case 'PERPETUAL':
|
||||||
'PERPETUAL'
|
|
||||||
| 'TRADIFI_PERPETUAL'
|
|
||||||
):
|
|
||||||
return 'PERP'
|
return 'PERP'
|
||||||
|
|
||||||
case '':
|
case '':
|
||||||
|
|
@ -255,10 +249,7 @@ class FutesPair(Pair):
|
||||||
margin: str = self.marginAsset
|
margin: str = self.marginAsset
|
||||||
|
|
||||||
match ctype:
|
match ctype:
|
||||||
case (
|
case 'PERPETUAL':
|
||||||
'PERPETUAL'
|
|
||||||
| 'TRADIFI_PERPETUAL'
|
|
||||||
):
|
|
||||||
return f'{margin}M'
|
return f'{margin}M'
|
||||||
|
|
||||||
case (
|
case (
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ def load(
|
||||||
MutableMapping,
|
MutableMapping,
|
||||||
] = tomllib.loads,
|
] = tomllib.loads,
|
||||||
|
|
||||||
touch_if_dne: bool = True,
|
touch_if_dne: bool = False,
|
||||||
|
|
||||||
**tomlkws,
|
**tomlkws,
|
||||||
|
|
||||||
|
|
@ -270,7 +270,7 @@ def load(
|
||||||
Load config file by name.
|
Load config file by name.
|
||||||
|
|
||||||
If desired config is not in the top level piker-user config path then
|
If desired config is not in the top level piker-user config path then
|
||||||
pass the `path: Path` explicitly.
|
pass the ``path: Path`` explicitly.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
# create the $HOME/.config/piker dir if dne
|
# create the $HOME/.config/piker dir if dne
|
||||||
|
|
@ -285,8 +285,7 @@ def load(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not path.is_file()
|
not path.is_file()
|
||||||
and
|
and touch_if_dne
|
||||||
touch_if_dne
|
|
||||||
):
|
):
|
||||||
# only do a template if no path provided,
|
# only do a template if no path provided,
|
||||||
# just touch an empty file with same name.
|
# just touch an empty file with same name.
|
||||||
|
|
|
||||||
|
|
@ -184,25 +184,22 @@ class DpiAwareFont:
|
||||||
self._font_inches = inches
|
self._font_inches = inches
|
||||||
font_size = math.floor(inches * pdpi)
|
font_size = math.floor(inches * pdpi)
|
||||||
|
|
||||||
ftype: str = f'{type(self)!r}'
|
log.debug(
|
||||||
log.info(
|
f"screen:{screen.name()}\n"
|
||||||
f'screen: {screen.name()}\n'
|
f"pDPI: {pdpi}, lDPI: {ldpi}, scale: {scale}\n"
|
||||||
f'pDPI: {pdpi!r}\n'
|
f"\nOur best guess font size is {font_size}\n"
|
||||||
f'lDPI: {ldpi!r}\n'
|
|
||||||
f'scale: {scale!r}\n'
|
|
||||||
f'{ftype}._font_inches={self._font_inches!r}\n'
|
|
||||||
f'\n'
|
|
||||||
f"Our best guess for an auto-font-size is,\n"
|
|
||||||
f'font_size: {font_size!r}\n'
|
|
||||||
)
|
)
|
||||||
# apply the size
|
# apply the size
|
||||||
self._set_qfont_px_size(font_size)
|
self._set_qfont_px_size(font_size)
|
||||||
|
|
||||||
def boundingRect(self, value: str) -> QtCore.QRectF:
|
def boundingRect(self, value: str) -> QtCore.QRectF:
|
||||||
if (screen := self.screen) is None:
|
|
||||||
|
screen = self.screen
|
||||||
|
if screen is None:
|
||||||
raise RuntimeError("You must call .configure_to_dpi() first!")
|
raise RuntimeError("You must call .configure_to_dpi() first!")
|
||||||
|
|
||||||
unscaled_br: QtCore.QRectF = self._qfm.boundingRect(value)
|
unscaled_br = self._qfm.boundingRect(value)
|
||||||
|
|
||||||
return QtCore.QRectF(
|
return QtCore.QRectF(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ Resource list for mucking with DPIs on multiple screens:
|
||||||
- https://doc.qt.io/qt-5/qguiapplication.html#screenAt
|
- https://doc.qt.io/qt-5/qguiapplication.html#screenAt
|
||||||
|
|
||||||
'''
|
'''
|
||||||
import os
|
|
||||||
|
|
||||||
|
from pyqtgraph import QtGui
|
||||||
from PyQt6 import (
|
from PyQt6 import (
|
||||||
QtCore,
|
QtCore,
|
||||||
QtWidgets,
|
QtWidgets,
|
||||||
|
|
@ -43,11 +43,6 @@ from PyQt6.QtCore import (
|
||||||
QSize,
|
QSize,
|
||||||
QRect,
|
QRect,
|
||||||
)
|
)
|
||||||
from pyqtgraph import QtGui
|
|
||||||
|
|
||||||
|
|
||||||
# https://doc.qt.io/qt-6/highdpi.html#environment-variable-reference
|
|
||||||
os.environ['QT_USE_PHYSICAL_DPI'] = '1'
|
|
||||||
|
|
||||||
# Proper high DPI scaling is available in Qt >= 5.6.0. This attibute
|
# Proper high DPI scaling is available in Qt >= 5.6.0. This attibute
|
||||||
# must be set before creating the application
|
# must be set before creating the application
|
||||||
|
|
@ -63,22 +58,13 @@ if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# NOTE, inherits `QGuiApplication`
|
|
||||||
# https://doc.qt.io/qt-6/qapplication.html
|
|
||||||
# https://doc.qt.io/qt-6/qguiapplication.html
|
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
#
|
|
||||||
# ^TODO? various global DPI settings?
|
|
||||||
# [ ] DPI rounding policy,
|
|
||||||
# - https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum
|
|
||||||
# - https://doc.qt.io/qt-6/qguiapplication.html#setHighDpiScaleFactorRoundingPolicy
|
|
||||||
|
|
||||||
window = QtWidgets.QMainWindow()
|
window = QtWidgets.QMainWindow()
|
||||||
main_widget = QtWidgets.QWidget()
|
main_widget = QtWidgets.QWidget()
|
||||||
window.setCentralWidget(main_widget)
|
window.setCentralWidget(main_widget)
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
_main_pxr: float = main_widget.devicePixelRatioF()
|
pxr: float = main_widget.devicePixelRatioF()
|
||||||
|
|
||||||
# explicitly get main widget and primary displays
|
# explicitly get main widget and primary displays
|
||||||
current_screen: QtGui.QScreen = app.screenAt(
|
current_screen: QtGui.QScreen = app.screenAt(
|
||||||
|
|
@ -91,13 +77,7 @@ for screen in app.screens():
|
||||||
name: str = screen.name()
|
name: str = screen.name()
|
||||||
model: str = screen.model().rstrip()
|
model: str = screen.model().rstrip()
|
||||||
size: QSize = screen.size()
|
size: QSize = screen.size()
|
||||||
geo: QRect = screen.geometry()
|
geo: QRect = screen.availableGeometry()
|
||||||
|
|
||||||
# device-pixel-ratio
|
|
||||||
# https://doc.qt.io/qt-6/highdpi.html
|
|
||||||
pxr: float = screen.devicePixelRatio()
|
|
||||||
|
|
||||||
unscaled_size: QSize = pxr * size
|
|
||||||
phydpi: float = screen.physicalDotsPerInch()
|
phydpi: float = screen.physicalDotsPerInch()
|
||||||
logdpi: float = screen.logicalDotsPerInch()
|
logdpi: float = screen.logicalDotsPerInch()
|
||||||
is_primary: bool = screen is primary_screen
|
is_primary: bool = screen is primary_screen
|
||||||
|
|
@ -108,12 +88,11 @@ for screen in app.screens():
|
||||||
f'|_primary: {is_primary}\n'
|
f'|_primary: {is_primary}\n'
|
||||||
f' _current: {is_current}\n'
|
f' _current: {is_current}\n'
|
||||||
f' _model: {model}\n'
|
f' _model: {model}\n'
|
||||||
f' _size: {size}\n'
|
f' _screen size: {size}\n'
|
||||||
f' _geometry: {geo}\n'
|
f' _screen geometry: {geo}\n'
|
||||||
f' _devicePixelRatio(): {pxr}\n'
|
f' _devicePixelRationF(): {pxr}\n'
|
||||||
f' _unscaled-size: {unscaled_size!r}\n'
|
f' _physical dpi: {phydpi}\n'
|
||||||
f' _physical-dpi: {phydpi}\n'
|
f' _logical dpi: {logdpi}\n'
|
||||||
f' _logical-dpi: {logdpi}\n'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# app-wide font info
|
# app-wide font info
|
||||||
|
|
@ -131,8 +110,8 @@ str_w: int = str_br.width()
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f'------ global font settings ------\n'
|
f'------ global font settings ------\n'
|
||||||
f'font dpi: {fontdpi!r}\n'
|
f'font dpi: {fontdpi}\n'
|
||||||
f'font height: {font_h!r}\n'
|
f'font height: {font_h}\n'
|
||||||
f'string bounding rect: {str_br!r}\n'
|
f'string bounding rect: {str_br}\n'
|
||||||
f'string width : {str_w!r}\n'
|
f'string width : {str_w}\n'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue