Hi there,
I’m trying to get my head around nix develop
for setting up Python development environments. At the moment, I’m just trying to get the html-to-json
package to work. Following the wiki, I have come up with the following:
# shell.nix
# See https://wiki.nixos.org/wiki/Python
let
pkgs = import <nixpkgs> {};
python = pkgs.python3.override {
self = python;
packageOverrides = pyfinal: pyprev: {
html-to-json = pyfinal.callPackage ./html-to-json.nix { };
};
};
in pkgs.mkShell {
packages = [
(python.withPackages (python-pkgs: [
# select Python packages here
python-pkgs.beautifulsoup4
python-pkgs.html-to-json
]))
];
}
# html-to-json.nix
{
lib,
buildPythonPackage,
fetchPypi,
setuptools,
wheel,
beautifulsoup4
}:
buildPythonPackage rec {
pname = "html-to-json";
version = "2.0.0";
src = fetchPypi {
inherit version;
pname = "html_to_json";
sha256 = "P8hI9AYY9ET46ZcfiKIv7wQdDLRWlGTeAY3Pjjw3Zp4=";
};
# Ensure required dependencies are included
propagatedBuildInputs = [ beautifulsoup4 ];
# do not run tests
doCheck = false;
# specific to buildPythonPackage, see its reference
pyproject = true;
build-system = [
setuptools
wheel
];
}
When I run nix develop -f shell.nix
, I get the error
> Checking runtime dependencies for html_to_json-2.0.0-py2.py3-none-any.whl
> - bs4 not installed
I’m a bit confused by this, because
- bs4 (beautifulsoup4) is included in
propagatedBuildInputs
, which I thought was where you’re meant to put dependencies. - When I comment out the
python-pkgs.html-to-json
, I am rewarded with a working shell, which hasbs4
available to import in Python.
I’m at a bit of a loss at this point, so any help would be appreciated! Maybe I’m just dumb, but this seems like a lot of work just to get python up and running