Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Created May 10, 2024 09:32
Show Gist options
  • Save rgoulter/c9536efea5a76dd30fd64c3daa5765d5 to your computer and use it in GitHub Desktop.
Save rgoulter/c9536efea5a76dd30fd64c3daa5765d5 to your computer and use it in GitHub Desktop.
{ buildPythonPackage
, foo
}:
buildPythonPackage {
pname = "bar";
version = "1.0.0";
src = ./bar;
doCheck = false;
pythonImportsCheck = ["bar"];
nativeBuildInputs = [foo];
}
from foo import foo
def bar(name):
return f"bar {foo(name)}"
{ pkgs ? import <nixpkgs> {} }:
let
packageOverrides = self: super: {
foo = self.callPackage ./foo.nix {};
bar = self.callPackage ./bar.nix {};
};
pythonWithMyPackages = (pkgs.python3.override { inherit packageOverrides; }).withPackages (ps:
[
ps.foo
ps.bar
]
);
in
pythonWithMyPackages
{ buildPythonPackage
}:
buildPythonPackage {
pname = "foo";
version = "1.0.0";
src = ./foo;
pythonImportsCheck = ["foo"];
doCheck = false;
}
def foo(name):
return f"foo {name}"
from setuptools import setup
setup(
name="bar",
version="1.0.0",
py_modules=["bar"],
install_requires=[
"foo>=1.0.0",
],
)
@rgoulter
Copy link
Author

e.g.

git clone https://gist.github.com/rgoulter/c9536efea5a76dd30fd64c3daa5765d5 nix-python-packages
cd nix-python-packages
nix-build
cd ..
./nix-python-packages/result/bin/python
>>> from bar import bar
>>> bar("x")
'bar foo x'
>>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment