Skip to content

Commit

Permalink
Use psycopg-c on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmohrin committed Nov 27, 2024
1 parent 33c0a0f commit 0ee9736
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
10 changes: 6 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@
devShells = forAllSystems (system:
let
pkgs = pkgsFor.${system};
dependency-groups = if pkgs.stdenv.isDarwin then [ "psycopg-c" ] else [ "psycopg-binary" ];
in
rec {
evap = pkgs.callPackage ./nix/shell.nix {
inherit (self.packages.${system}) python3;
inherit (inputs) pyproject-nix uv2nix pyproject-build-systems;
dependency-groups = lib.optionals (!pkgs.stdenv.isDarwin) [ "psycopg-binary" ];
inherit dependency-groups;
workspaceRoot = ./.;
};
evap-dev = evap.override (prev: { dependency-groups = (prev.dependency-groups or [ ]) ++ [ "dev" ]; });
default = evap-dev;

impure = pkgs.mkShell {
packages = [
pkgs.python310
pkgs.uv
packages = with pkgs; [
(self.packages.${system}.python3)
uv
postgresql
];
shellHook = ''
unset PYTHONPATH
Expand Down
7 changes: 6 additions & 1 deletion nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ let

workspace = uv2nix.lib.workspace.loadWorkspace { inherit workspaceRoot; };
overlay = workspace.mkPyprojectOverlay { sourcePreference = "wheel"; };
package-overrides = final: prev: {
psycopg-c = prev.psycopg-c.overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ final.setuptools pkgs.postgresql ];
});
};
baseSet = pkgs.callPackage pyproject-nix.build.packages { python = python3; };
pythonSet = baseSet.overrideScope (lib.composeManyExtensions [ pyproject-build-systems.overlays.default overlay ]);
pythonSet = baseSet.overrideScope (lib.composeManyExtensions [ pyproject-build-systems.overlays.default overlay package-overrides ]);

editableOverlay = workspace.mkEditablePyprojectOverlay { root = "$REPO_ROOT"; };
editablePythonSet = pythonSet.overrideScope editableOverlay;
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies = [

[project.optional-dependencies]
psycopg-binary = ["psycopg[binary]"]
psycopg-c = ["psycopg[c]"]

[dependency-groups]
dev = [
Expand All @@ -42,6 +43,11 @@ dev = [
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
no-binary-package = [
"psycopg-c",
]

##############################################

[tool.black]
Expand Down
13 changes: 13 additions & 0 deletions uv.lock

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

0 comments on commit 0ee9736

Please sign in to comment.