fix: Replace overlays self super with final prev

This commit is contained in:
Malte Neuss 2024-04-14 20:27:42 +02:00 committed by Phillip Cloud
parent beb9518b4d
commit 023a0e045a
No known key found for this signature in database
GPG key ID: D908212070FD785E
23 changed files with 745 additions and 720 deletions

View file

@ -2,6 +2,7 @@
[![Chat on Matrix](https://matrix.to/img/matrix-badge.svg)](https://matrix.to/#/#poetry2nix:blad.is)
# poetry2nix
_poetry2nix_ turns [Poetry](https://python-poetry.org/) projects into Nix derivations without the need to actually write Nix expressions. It does so by parsing `pyproject.toml` and `poetry.lock` and converting them to Nix derivations on the fly.
For more information, see [the announcement post on the Tweag blog](https://www.tweag.io/blog/2020-08-12-poetry2nix/).
@ -110,8 +111,9 @@ myPythonApp = pkgs.poetry2nix.mkPoetryApplication { projectDir = self; };
```
## Table of contents
- [API](#api)
- [FAQ](#FAQ)
- [FAQ](#faq)
- [How-to guides](#how-to-guides)
- [Using the flake](#using-the-flake)
- [Contributing](#contributing)
@ -159,6 +161,7 @@ poetry = "poetry.console.application:main"
```
#### Example
```nix
poetry2nix.mkPoetryApplication {
projectDir = ./.;
@ -191,6 +194,7 @@ If you prefer to build a single binary that runs `gunicorn web:app`, use [`pkgs.
Note: If you need to perform overrides on the application, use `app.dependencyEnv.override { app = app.override { ... }; }`. See [./tests/dependency-environment/default.nix](./tests/dependency-environment/default.nix) for a full example.
### mkPoetryEnv
Creates an environment that provides a Python interpreter along with all dependencies declared by the designated poetry project and lock files. Also allows package sources of an application to be installed in editable mode for fast development. `mkPoetryEnv` takes an attribute set with the following attributes (attributes without default are mandatory):
- **projectDir**: path to the root of the project.
@ -206,6 +210,7 @@ Creates an environment that provides a Python interpreter along with all depende
- **extras**: Which Poetry `extras` to install (_default_: `[ "*" ]`, all extras).
#### Example
```nix
poetry2nix.mkPoetryEnv {
projectDir = ./.;
@ -215,6 +220,7 @@ poetry2nix.mkPoetryEnv {
See [./tests/env/default.nix](./tests/env/default.nix) for a working example.
#### Example with editable packages
```nix
poetry2nix.mkPoetryEnv {
projectDir = ./.;
@ -227,6 +233,7 @@ poetry2nix.mkPoetryEnv {
See [./tests/editable/default.nix](./tests/editable/default.nix) for a working example of an editable package.
#### Example shell.nix
The `env` attribute of the attribute set created by `mkPoetryEnv` contains a shell environment.
```nix
@ -242,7 +249,9 @@ in myAppEnv.env
```
#### Example shell.nix with external dependencies
For a shell environment including external dependencies, override the `env` to add dependency packages (for example, `pkgs.hello`) as build inputs.
```nix
{ pkgs ? import <nixpkgs> {} }:
let
@ -258,6 +267,7 @@ in myAppEnv.env.overrideAttrs (oldAttrs: {
```
### mkPoetryPackages
Creates an attribute set of the shape `{ python, poetryPackages, pyProject, poetryLock }`. Where `python` is the interpreter specified, `poetryPackages` is a list of all generated python packages, `pyProject` is the parsed `pyproject.toml` and `poetryLock` is the parsed `poetry.lock` file. `mkPoetryPackages` takes an attribute set with the following attributes (attributes without default are mandatory):
- **projectDir**: path to the root of the project.
@ -272,6 +282,7 @@ Creates an attribute set of the shape `{ python, poetryPackages, pyProject, poet
- **extras**: Which Poetry `extras` to install (_default_: `[ "*" ]`, all extras).
#### Example
```nix
poetry2nix.mkPoetryPackages {
projectDir = ./.;
@ -280,6 +291,7 @@ poetry2nix.mkPoetryPackages {
```
### mkPoetryScriptsPackage
Creates a package containing the scripts from `tool.poetry.scripts` of the `pyproject.toml`:
- **projectDir**: path to the root of the project.
@ -287,6 +299,7 @@ Creates a package containing the scripts from `tool.poetry.scripts` of the `pypr
- **python**: The Python interpreter to use (_default:_ `pkgs.python3`).
#### Example
```nix
poetry2nix.mkPoetryScriptsPackage {
projectDir = ./.;
@ -295,6 +308,7 @@ poetry2nix.mkPoetryScriptsPackage {
```
### mkPoetryEditablePackage
Creates a package containing editable sources. Changes in the specified paths will be reflected in an interactive nix-shell session without the need to restart it:
- **projectDir**: path to the root of the project.
@ -303,6 +317,7 @@ Creates a package containing editable sources. Changes in the specified paths wi
- **editablePackageSources**: A mapping from package name to source directory, these will be installed in editable mode (_default:_ `{}`).
#### Example
```nix
poetry2nix.mkPoetryEditablePackage {
projectDir = ./.;
@ -318,9 +333,11 @@ poetry2nix.mkPoetryEditablePackage {
_poetry2nix_ bundles a set of default overrides that fix problems with various Python packages. These overrides are implemented in [overrides](./overrides/default.nix).
### overrides.withDefaults
Returns a list containing the specified overlay and `defaultPoetryOverrides`.
Takes an attribute set with the following attributes (attributes without default are mandatory):
- **src**: project source directory
#### Example
@ -328,12 +345,14 @@ Takes an attribute set with the following attributes (attributes without default
```nix
poetry2nix.mkPoetryEnv {
projectDir = ./.;
overrides = poetry2nix.overrides.withDefaults (self: super: { foo = null; });
overrides = poetry2nix.overrides.withDefaults (final: prev: { foo = null; });
}
```
See [./tests/override-support/default.nix](./tests/override-support/default.nix) for a working example.
### overrides.withoutDefaults
Returns a list containing just the specified overlay, ignoring `defaultPoetryOverrides`.
#### Example
@ -341,12 +360,14 @@ Returns a list containing just the specified overlay, ignoring `defaultPoetryOve
```nix
poetry2nix.mkPoetryEnv {
projectDir = ./.;
overrides = poetry2nix.overrides.withoutDefaults (self: super: { foo = null; });
overrides = poetry2nix.overrides.withoutDefaults (final: prev: { foo = null; });
}
```
### cleanPythonSources
Provides a source filtering mechanism that:
- Filters gitignore's
- Filters pycache/pyc files
- Uses cleanSourceFilter to filter out .git/.hg, .o/.so, editor backup files & nix result symlinks
@ -360,18 +381,20 @@ poetry2nix.cleanPythonSources {
```
### Creating a custom Poetry2nix instance
Sometimes when it can be convenient to create a custom instance of `poetry2nix` with a different set of default overrides.
#### Example
```nix
let
# self & super refers to poetry2nix
p2nix = poetry2nix.overrideScope (self: super: {
# final & prev refers to poetry2nix
p2nix = poetry2nix.overrideScope' (final: prev: {
# pyself & pysuper refers to python packages
defaultPoetryOverrides = super.defaultPoetryOverrides.extend (pyself: pysuper: {
# pyself & pyprev refers to python packages
defaultPoetryOverrides = prev.defaultPoetryOverrides.extend (pyfinal: pyprev: {
my-custom-pkg = super.my-custom-pkg.overridePythonAttrs (oldAttrs: { });
my-custom-pkg = prev.my-custom-pkg.overridePythonAttrs (oldAttrs: { });
});
@ -384,20 +407,21 @@ p2nix.mkPoetryApplication {
```
or as a [nixpkgs overlay](https://nixos.org/nixpkgs/manual/#chap-overlays):
```nix
let
pkgs = import <nixpkgs> {
overlays = [
# self & super refers to nixpkgs
(self: super: {
# final & prev refers to nixpkgs
(final: prev: {
# p2self & p2super refers to poetry2nix
poetry2nix = super.poetry2nix.overrideScope (p2nixself: p2nixsuper: {
# p2nixfinal & p2nixprev refers to poetry2nix
poetry2nix = prev.poetry2nix.overrideScope' (p2nixfinal: p2nixprev: {
# pyself & pysuper refers to python packages
defaultPoetryOverrides = p2nixsuper.defaultPoetryOverrides.extend (pyself: pysuper: {
# pyfinal & pyprev refers to python packages
defaultPoetryOverrides = p2nixprev.defaultPoetryOverrides.extend (pyfinal: pyprev: {
my-custom-pkg = super.my-custom-pkg.overridePythonAttrs (oldAttrs: { });
my-custom-pkg = prev.my-custom-pkg.overridePythonAttrs (oldAttrs: { });
});
@ -523,7 +547,7 @@ __poetry2nix__ contains special code to forward this variable as an environment
```shell
# non-flake project
nix-build -I NETRC=/etc/nix/netrc --option extra-sandbox-paths /etc/nix/netrc default.nix
nix-build -I NETRC=/etc/nix/netrc --option extra-sandbox-paths /etc/nix/netrc default.nix
```
Note: The alternative to pass the `NETRC` path environment variable
@ -549,7 +573,7 @@ Any package that is used, but isn't in the `poetry.lock` file (most commonly [bu
poetry2nix.mkPoetryApplication {
projectDir = ./.;
overrides = poetry2nix.overrides.withDefaults (final: prev: {
# Notice that using .overridePythonAttrs or .overrideAttrs wont work!
# Notice that using .overridePythonAttrs or .overrideAttrs won't work!
some-dependency = prev.some-dependency.override {
preferWheel = true;
};
@ -570,6 +594,7 @@ poetry2nix.mkPoetryApplication {
**A.** Have a look at the following document [edgecase.md](./docs/edgecases.md)
## How-to guides
- [Package and deploy Python apps faster with Poetry and Nix](https://www.youtube.com/watch?v=TbIHRHy7_JM)
This is a short (11 minutes) video tutorial by [Steve Purcell](https://github.com/purcell/) from [Tweag](https://tweag.io) walking you through how to get started with a small web development project.
@ -607,10 +632,13 @@ nix-build --expr 'with import <unstable> {}; callPackage ./tests/default.nix {}'
To sort `overrides/build-systems.json` according to the [`sort-build-systems` job](.github/workflows/ci.yml), patch the source with the output of the "Check format" step, like this: `nix-shell [omitted] | patch -p0`.
## Contact
We have a Matrix room at [#poetry2nix:blad.is](https://matrix.to/#/#poetry2nix:blad.is).
## Acknowledgements
Development of `poetry2nix` has been supported by [Tweag](https://tweag.io).
## License
_poetry2nix_ is released under the terms of the MIT license.

View file

@ -42,7 +42,7 @@ class UrlPackage(Package):
def expression(self, output: str) -> str:
sha256 = output.rstrip()
return textwrap.dedent("""
%s = super.%s.overridePythonAttrs (
%s = prev.%s.overridePythonAttrs (
_: {
src = pkgs.fetchzip {
url = "%s";
@ -76,7 +76,7 @@ class GitPackage(Package):
def expression(self, output: str) -> str:
meta = json.loads(output)
return textwrap.dedent("""
%s = super.%s.overridePythonAttrs (
%s = prev.%s.overridePythonAttrs (
_: {
src = pkgs.fetchgit {
url = "%s";
@ -131,7 +131,7 @@ def main() -> None:
lines = [
"{ pkgs }:",
"self: super: {",
"final: prev: {",
]
for f in futures:

View file

@ -196,7 +196,7 @@ lib.makeScope pkgs.newScope (self: {
#
# We need to avoid mixing multiple versions of pythonPackages in the same
# closure as python can only ever have one version of a dependency
baseOverlay = self: super:
baseOverlay = final: prev:
let
lockPkgs = builtins.listToAttrs (
builtins.map
@ -205,14 +205,14 @@ lib.makeScope pkgs.newScope (self: {
let normalizedName = normalizePackageName pkgMeta.name; in
{
name = normalizedName;
value = self.mkPoetryDep (
value = final.mkPoetryDep (
pkgMeta // {
inherit pwd preferWheels;
pos = poetrylockPos;
source = pkgMeta.source or null;
# Default to files from lock file version 2.0 and fall back to 1.1
files = pkgMeta.files or lockFiles.${normalizedName};
pythonPackages = self;
pythonPackages = final;
sourceSpec = (normalizePackageSet pyProject.tool.poetry.dependencies or { }).${normalizedName}
or (normalizePackageSet pyProject.tool.poetry.dev-dependencies or { }).${normalizedName}
@ -224,7 +224,7 @@ lib.makeScope pkgs.newScope (self: {
)
(lib.reverseList compatible)
);
buildSystems = builtins.listToAttrs (builtins.map (x: { name = x; value = super.${x}; }) nixpkgsBuildSystems);
buildSystems = builtins.listToAttrs (builtins.map (x: { name = x; value = prev.${x}; }) nixpkgsBuildSystems);
in
lockPkgs // buildSystems // {
# Create a dummy null package for the current project in case any dependencies depend on the root project (issue #307)
@ -234,45 +234,45 @@ lib.makeScope pkgs.newScope (self: {
getFunctorFn
(
[
(self: super: lib.attrsets.mapAttrs
(final: prev: lib.attrsets.mapAttrs
(
name: value:
if lib.isDerivation value && self.hasPythonModule value && (normalizePackageName name) != name
if lib.isDerivation value && final.hasPythonModule value && (normalizePackageName name) != name
then null
else value
)
super)
prev)
(
self: _super:
final: _prev:
{
mkPoetryDep = self.callPackage ./mk-poetry-dep.nix {
mkPoetryDep = final.callPackage ./mk-poetry-dep.nix {
inherit lib python poetryLib pep508Env pyVersion;
inherit pyproject-nix;
};
__toPluginAble = toPluginAble self;
__toPluginAble = toPluginAble final;
}
)
# Fix infinite recursion in a lot of packages because of checkInputs
(_self: super: lib.mapAttrs
(_final: prev: lib.mapAttrs
(_name: value: (
if lib.isDerivation value && lib.hasAttr "overridePythonAttrs" value
then value.overridePythonAttrs (_: { doCheck = false; })
else value
))
super)
prev)
# Null out any filtered packages, we don't want python.pkgs from nixpkgs
(_self: _super: builtins.listToAttrs (builtins.map (x: { name = normalizePackageName x.name; value = null; }) incompatible))
(_final: _prev: builtins.listToAttrs (builtins.map (x: { name = normalizePackageName x.name; value = null; }) incompatible))
# Create poetry2nix layer
baseOverlay
] ++ # User provided overrides
(if builtins.typeOf overrides == "list" then overrides else [ overrides ])
);
packageOverrides = lib.foldr lib.composeExtensions (_self: _super: { }) overlays;
packageOverrides = lib.foldr lib.composeExtensions (_final: _prev: { }) overlays;
py = python.override { inherit packageOverrides; self = py; };
inputAttrs = mkInputAttrs { inherit py pyProject groups checkGroups extras; attrs = { }; includeBuildSystem = false; };
@ -476,10 +476,10 @@ lib.makeScope pkgs.newScope (self: {
overrideOverlay = fn:
let
overlay = self: super:
overlay = final: prev:
let
defaultSet = defaults self super;
customSet = fn self super;
defaultSet = defaults final prev;
customSet = fn final prev;
in
defaultSet // customSet;
in

View file

@ -128,11 +128,11 @@ In order to be able to build `django-floppyforms` we should modify our nix defin
poetry2nix.mkPoetryApplication {
projectDir = ./.;
overrides = poetry2nix.defaultPoetryOverrides.extend
(self: super: {
django-floppyforms = super.django-floppyforms.overridePythonAttrs
(final: prev: {
django-floppyforms = prev.django-floppyforms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ];
}
);
});
@ -150,17 +150,17 @@ Your file might then look something like this:
poetry2nix.mkPoetryApplication {
projectDir = ./.;
overrides = poetry2nix.defaultPoetryOverrides.extend
(self: super: {
first-dependency = super.first-dependency.overridePythonAttrs
(final: prev: {
first-dependency = prev.first-dependency.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.buildtools ];
buildInputs = (old.buildInputs or [ ]) ++ [ prev.buildtools ];
}
);
second-dependency = super.second-dependency.overridePythonAttrs
second-dependency = prev.second-dependency.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.pdm ];
buildInputs = (old.buildInputs or [ ]) ++ [ prev.pdm ];
}
);
});
@ -180,10 +180,10 @@ let
simpervisor = [ "setuptools" ];
pandas = [ "versioneer" ];
};
p2n-overrides = p2n.defaultPoetryOverrides.extend (self: super:
p2n-overrides = p2n.defaultPoetryOverrides.extend (final: prev:
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);
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements);
})
) pypkgs-build-requirements
);
@ -212,9 +212,9 @@ Resulting override:
```nix
{
python-ulid = super.python-ulid.overridePythonAttrs (
python-ulid = prev.python-ulid.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools-scm ];
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ final.setuptools-scm ];
}
);
}
@ -224,9 +224,9 @@ Resulting override:
**Please update `getCargoHash` and there is a stanza that gives out the hash**
This has known solution https://github.com/nix-community/poetry2nix/pull/1116
This has known solution <https://github.com/nix-community/poetry2nix/pull/1116>
Though, the solution still needs human-in-a-loop as there are many cases where
Though, the solution still needs human-in-a-loop as there are many cases where
there is no expected hash provided.
There are then 2 ways you can solve this while waiting for the PR to merge:
@ -279,7 +279,6 @@ While the ecosystem is growing, we have an escape hatch to use `preferWheels`
if you trust pip wheel dists. `preferWheels` is basically Python's version of
compiled binary, so it is vulnerable to supply chain attacks.
```nix
poetry2nix.mkPoetryApplication {
projectDir = ./.;
@ -333,10 +332,10 @@ files = [
Suppose we override the version in our Nix file as follows:
```nix
let poetryOverrides = self: super: {
foobar = super.foobar.overridePythonAttrs (old: rec {
let poetryOverrides = final: prev: {
foobar = prev.foobar.overridePythonAttrs (old: rec {
version = "2.0";
src = super.pkgs.fetchFromGitHub {
src = prev.pkgs.fetchFromGitHub {
owner = "fakerepo";
repo = "foobar";
rev = "refs/tags/${version}";

File diff suppressed because it is too large Load diff

View file

@ -6,8 +6,8 @@ let
poetrylock = ./poetry.lock;
preferWheels = false;
overrides = poetry2nix.overrides.withDefaults (
_: super: {
cairocffi = super.cairocffi.override {
_: prev: {
cairocffi = prev.cairocffi.override {
preferWheel = true;
};
}

View file

@ -10,8 +10,8 @@ poetry2nix.mkPoetryApplication {
poetry2nix.defaultPoetryOverrides
(import ./poetry-git-overlay.nix { inherit pkgs; })
(
_self: super: {
pyramid-deferred-sqla = super.pyramid-deferred-sqla.overridePythonAttrs (
_final: prev: {
pyramid-deferred-sqla = prev.pyramid-deferred-sqla.overridePythonAttrs (
_old: {
postPatch = ''
touch LICENSE

View file

@ -1,7 +1,7 @@
{ pkgs }:
_self: super: {
_final: prev: {
pyramid-deferred-sqla = super.pyramid-deferred-sqla.overridePythonAttrs (
pyramid-deferred-sqla = prev.pyramid-deferred-sqla.overridePythonAttrs (
_: {
src = pkgs.fetchgit {
url = "https://github.com/niteoweb/pyramid_deferred_sqla.git";

View file

@ -1,18 +1,16 @@
{ poetry2nix, python3 }:
let
p2nix = poetry2nix.overrideScope (_self: super: {
defaultPoetryOverrides = super.defaultPoetryOverrides.extend (_pyself: _pysuper: {
my-custom-pkg = super.my-custom-pkg.overridePythonAttrs (_oldAttrs: { });
p2nix = poetry2nix.overrideScope' (_final: prev: {
defaultPoetryOverrides = prev.defaultPoetryOverrides.extend (_pyfinal: _pyprev: {
my-custom-pkg = prev.my-custom-pkg.overridePythonAttrs (_oldAttrs: { });
});
});
in
p2nix.mkPoetryApplication {
python = python3;
projectDir = ./.;
overrides = p2nix.overrides.withDefaults (_self: super: {
inherit (super) customjox;
overrides = p2nix.overrides.withDefaults (_final: prev: {
inherit (prev) customjox;
});
}

View file

@ -6,8 +6,8 @@ let
poetrylock = ./poetry.lock;
preferWheels = false;
overrides = poetry2nix.overrides.withDefaults (
_: super: {
numpy = super.numpy.override {
_: prev: {
numpy = prev.numpy.override {
preferWheel = true;
};
}

View file

@ -6,11 +6,11 @@ let
poetrylock = ./poetry.lock;
preferWheels = false;
overrides = poetry2nix.overrides.withDefaults (
_: super: {
contourpy = super.contourpy.override {
_: prev: {
contourpy = prev.contourpy.override {
preferWheel = true;
};
numpy = super.numpy.override {
numpy = prev.numpy.override {
preferWheel = true;
};
}

View file

@ -6,7 +6,7 @@ poetry2nix.mkPoetryApplication {
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
pwd = ./.;
overrides = poetry2nix.overrides.withDefaults (self: super: {
trivial = self.addBuildSystem "poetry" super.trivial;
overrides = poetry2nix.overrides.withDefaults (final: prev: {
trivial = final.addBuildSystem "poetry" prev.trivial;
});
}

View file

@ -6,7 +6,7 @@ poetry2nix.mkPoetryApplication {
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
pwd = ./.;
overrides = poetry2nix.overrides.withDefaults (self: super: {
trivial = self.addBuildSystem "poetry" super.trivial;
overrides = poetry2nix.overrides.withDefaults (final: prev: {
trivial = final.addBuildSystem "poetry" prev.trivial;
});
}

View file

@ -1,7 +1,7 @@
{ pkgs }:
_self: super: {
_final: prev: {
alembic = super.alembic.overridePythonAttrs (
alembic = prev.alembic.overridePythonAttrs (
_: {
src = pkgs.fetchgit {
url = "https://github.com/sqlalchemy/alembic.git";
@ -11,7 +11,7 @@ _self: super: {
}
);
colorama = super.colorama.overridePythonAttrs (
colorama = prev.colorama.overridePythonAttrs (
_: {
src = pkgs.fetchgit {
url = "https://github.com/tartley/colorama.git";
@ -21,7 +21,7 @@ _self: super: {
}
);
s3transfer = super.s3transfer.overridePythonAttrs (
s3transfer = prev.s3transfer.overridePythonAttrs (
_: {
src = pkgs.fetchgit {
url = "https://github.com/boto/s3transfer.git";

View file

@ -7,8 +7,8 @@ let
poetrylock = ./poetry.lock;
preferWheels = false;
overrides = poetry2nix.overrides.withDefaults (
_self: super: {
grpcio = super.grpcio.override {
_final: prev: {
grpcio = prev.grpcio.override {
preferWheel = isLinux;
};
}

View file

@ -7,8 +7,8 @@ let
poetrylock = ./poetry.lock;
preferWheels = false;
overrides = poetry2nix.overrides.withDefaults (
_self: super: {
markdown-it-py = super.markdown-it-py.override {
_final: prev: {
markdown-it-py = prev.markdown-it-py.override {
preferWheel = isLinux;
};
}

View file

@ -8,15 +8,15 @@ let
overrides = [
((
poetry2nix.defaultPoetryOverrides.overrideOverlay (
_self: super: {
alembic = super.alembic.overridePythonAttrs (
_final: prev: {
alembic = prev.alembic.overridePythonAttrs (
_old: {
TESTING_FOOBAR = 42;
}
);
}
)
).extend (_pyself: _pysuper: { })) # Test .extend for good measure
).extend (_pyfinal: _pyprev: { })) # Test .extend for good measure
];
};
in

View file

@ -6,8 +6,8 @@ let
poetrylock = ./poetry.lock;
pyproject = ./pyproject.toml;
overrides = poetry2nix.overrides.withDefaults (
_self: super: {
alembic = super.alembic.overridePythonAttrs (
_final: prev: {
alembic = prev.alembic.overridePythonAttrs (
_old: {
TESTING_FOOBAR = 42;
}

View file

@ -11,16 +11,16 @@ let
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
overrides = poetry2nix.overrides.withDefaults (
_self: super: {
bokeh = super.bokeh.override {
_final: prev: {
bokeh = prev.bokeh.override {
preferWheel = true;
};
panel = super.panel.override {
panel = prev.panel.override {
preferWheel = true;
};
pillow = super.pillow.override {
pillow = prev.pillow.override {
preferWheel = true;
};
}

View file

@ -8,9 +8,9 @@ let
dep1 = null;
};
overrides = poetry2nix.overrides.withDefaults (self: super: {
dep1 = super.dep1.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools ];
overrides = poetry2nix.overrides.withDefaults (final: prev: {
dep1 = prev.dep1.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ final.setuptools ];
});
});
};

View file

@ -4,11 +4,11 @@ let
python = python310;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
overrides = poetry2nix.overrides.withDefaults (_: super: {
threadpoolctl = super.threadpoolctl.override { preferWheel = true; };
pandas = super.pandas.override { preferWheel = true; };
pyquaternion = super.pyquaternion.override { preferWheel = true; };
scikit-learn = super.scikit-learn.override { preferWheel = true; };
overrides = poetry2nix.overrides.withDefaults (_final: prev: {
threadpoolctl = prev.threadpoolctl.override { preferWheel = true; };
pandas = prev.pandas.override { preferWheel = true; };
pyquaternion = prev.pyquaternion.override { preferWheel = true; };
scikit-learn = prev.scikit-learn.override { preferWheel = true; };
});
};
in

View file

@ -7,11 +7,11 @@ let
overrides = poetry2nix.overrides.withDefaults
# This is also in overrides.nix but repeated for completeness
(
_self: super: {
maturin = super.maturin.override {
_final: prev: {
maturin = prev.maturin.override {
preferWheel = true;
};
funcy = super.funcy.overridePythonAttrs (_old: {
funcy = prev.funcy.overridePythonAttrs (_old: {
preferWheel = true;
});
}

View file

@ -7,20 +7,20 @@ let
poetrylock = ./poetry.lock;
preferWheels = false;
overrides = poetry2nix.overrides.withDefaults (
_: super: {
rpds-py = super.rpds-py.override {
_: prev: {
rpds-py = prev.rpds-py.override {
preferWheel = isLinux;
};
referencing = super.referencing.override {
referencing = prev.referencing.override {
preferWheel = isLinux;
};
jsonschema-specifications = super.jsonschema-specifications.override {
jsonschema-specifications = prev.jsonschema-specifications.override {
preferWheel = isLinux;
};
jsonschema = super.jsonschema.override {
jsonschema = prev.jsonschema.override {
preferWheel = isLinux;
};
}