Skip to content

Commit

Permalink
chore: Move from Poetry to UV
Browse files Browse the repository at this point in the history
Bumping to Poetry 2 seems to be more problematic than switching to uv
https://github.com/astral-sh/uv

Given the main maintainer of poetry2nix now works on uv2nix it does not
seem to be a bad bet to switch.
nix-community/poetry2nix@f554d27

Part of request #41796 Update dev/build environment [W07 2025]
  • Loading branch information
LeSuisse committed Feb 24, 2025
1 parent 1e14b39 commit d179e3b
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 623 deletions.
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN touch .bash_profile \

RUN echo '. /home/gitpod/.nix-profile/etc/profile.d/nix.sh' >> /home/gitpod/.bashrc

COPY shell.nix pyproject.toml poetry.lock /tmp/
COPY shell.nix pyproject.toml uv.lock /tmp/
COPY build-support/*.nix /tmp/build-support/

RUN . /home/gitpod/.nix-profile/etc/profile.d/nix.sh && nix-build --no-out-link /tmp/shell.nix
58 changes: 19 additions & 39 deletions build-support/build-tools.nix
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
{ pkgs ? (import ./pinned-nixpkgs.nix) { } }:
[
let
pythonWorkspace = pkgs.uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ../.; };
pythonSet = (pkgs.callPackage pkgs.pyproject-nix.build.packages {
python = pkgs.python3;
}).overrideScope
(
pkgs.lib.composeManyExtensions [
pkgs.pyproject-build-systems
(pythonWorkspace.mkPyprojectOverlay { sourcePreference = "wheel"; })
(final: prev: {
markupsafe = prev.markupsafe.overrideAttrs(old: {
buildInputs = (old.buildInputs or [ ]) ++ final.resolveBuildSystem ( {setuptools = [];});
});
})
]
);
pythonVirtualenv = pythonSet.mkVirtualEnv "build-deps" pythonWorkspace.deps.all;
in [
pkgs.gnumake
pkgs.gnugrep
pkgs.gnused
pkgs.gawk
(pkgs.poetry2nix.mkPoetryEnv {
projectDir = ../.;
# Some overrides are needed because some packages does not define their build deps correctly
# or do not respect PEP 440 when defining the version
# https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md
overrides = pkgs.poetry2nix.defaultPoetryOverrides.extend (
self: super: {
sphinx = super.sphinx.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
sphinx-autobuild = super.sphinx-autobuild.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
sphinx-notfound-page = super.sphinx-notfound-page.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
sphinxcontrib-jquery = super.sphinxcontrib-jquery.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
sphinxext-rediraffe = super.sphinxext-rediraffe.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
postPatch = ''
substituteInPlace setup.py --replace 'version = "main"' 'version = "${old.version}"'
'';
}
);
}
);
})
pythonVirtualenv
]
2 changes: 1 addition & 1 deletion build-support/dev-tools.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs }:
[
pkgs.poetry
pkgs.uv
pkgs.nodejs-slim
pkgs.nodePackages.npm
]
6 changes: 3 additions & 3 deletions build-support/linkcheck-docker.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM nixos/nix:2.26.2@sha256:3bb728719e2c4e478df4c50b80f93adbe27d5c561d1417c3a2306eb914d910da

COPY build-support/*.nix /build-support/
COPY pyproject.toml poetry.lock /
COPY pyproject.toml uv.lock /doc/
COPY build-support/*.nix /doc/build-support/

RUN nix-env -i -f build-support/build-tools.nix
RUN nix-env -i -f /doc/build-support/build-tools.nix
21 changes: 13 additions & 8 deletions build-support/pinned-nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ let
url = "https://github.com/NixOS/nixpkgs/archive/5083ec887760adfe12af64830a66807423a859a7.tar.gz";
sha256 = "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=";
} ) {};
poetry2nixsrc = builtins.fetchTarball {
url = "https://github.com/nix-community/poetry2nix/archive/refs/tags/2024.11.109713.tar.gz";
sha256 = "sha256:04nvlp0lp2kxycdywq0avzxpvyj69iij8xvl6havjmpm26dpbcqp";
};
poetry2nix = import poetry2nixsrc {
pkgs = pinnedNixpkgs;
};
in pinnedNixpkgs // { inherit poetry2nix; }
pyproject-nix = import (builtins.fetchTarball {
url = "https://github.com/pyproject-nix/pyproject.nix/archive/1329712f7f9af3a8b270764ba338a455b7323811.tar.gz";
sha256 = "sha256:1yvqfc6akbimflhgp5b6b4q57rmahgs96m81zbx7gv0299sbi1h2";
}) { lib = pinnedNixpkgs.lib; };
uv2nix = import (builtins.fetchTarball {
url = "https://github.com/pyproject-nix/uv2nix/archive/846ad27167bf6a855c56753ba8360759bfb6f456.tar.gz";
sha256 = "sha256:0ivbg4szn2p6xvjrm9qg9xh8nhd3p7lh88qln596f2kchvv4aysm";
}) { lib = pinnedNixpkgs.lib; inherit pyproject-nix; };
pyproject-build-systems = import (builtins.fetchTarball {
url = "https://github.com/pyproject-nix/build-system-pkgs/archive/53700950d05fc2dd67228277ff1729964d2e7ffd.tar.gz";
sha256 = "sha256:1aipbbwpidzyb4gxpgsc5fr7hiv2xy1zp3400rzzqqkjxd0vr0s8";
}) { lib = pinnedNixpkgs.lib; inherit pyproject-nix uv2nix; };
in pinnedNixpkgs // { inherit pyproject-nix uv2nix pyproject-build-systems; }
Loading

0 comments on commit d179e3b

Please sign in to comment.