Skip to content

Commit

Permalink
Factor prefer wheels deps into new ahot_overrides
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
goodboy committed Aug 17, 2023
1 parent 6b22024 commit ea9a5e5
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 66 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 81 additions & 56 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,72 +82,97 @@
) 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;

# 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 = p2n-overrides.extend(
final: prev: {

# 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;
};
}
);
};
};
overrides = ahot_overrides;

# 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 ];

# 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";
};
}
);
# XXX: won't work on llvmlite..
# preferWheels = true;
};
};

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: 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
}
49 changes: 43 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit ea9a5e5

Please sign in to comment.