I’m trying to setup a python 3.8 development environment with the gym[atari]
package installed.
Following @jonringer’s Python packaging and development workflow video, I figured out how to do this with venvShellHook
:
with import <nixpkgs> {};
mkShell {
name = "play-dev-env";
buildInputs = (with python38Packages; [
venvShellHook
]) ++ (with pkgs; [
cmake
binutils
util-linux
stdenv.cc.cc.lib
zlib
autoPatchelfHook
]);
venvDir = "venv38";
}
I’d like to use mach-nix
to do this more declaratively. Here’s what I’ve tried:
{ pkgs ? import <nixpkgs> {} }:
let
mach-nix = import (
builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
ref = "refs/tags/3.3.0";
}
) {};
custom-python = mach-nix.mkPython {
python = "python38Full";
requirements = ''
gym[atari]
'';
# I've tried with and without this line.
_.gym.buildInputs.add = [ pkgs.cmake ];
};
in
with pkgs; mkShell {
buildInputs = [
custom-python
];
}
This produces the following output (excluding lines that begin with copying...
trace: removing dependency python3.8-requests-2.25.1 from gym
these derivations will be built:
/nix/store/k6cgalfww07a4dfrs75wcdxfljkl4cvg-opencv_python-4.5.2.52-cp38-cp38-manylinux2014_x86_64.whl.drv
/nix/store/6ad56h7jb3h3gb22kkdg106j3d2f58vb-python3.8-opencv-python-4.5.2.52.drv
/nix/store/vplghxz66sn4c7dhz6cr5rj12jcvlmwn-python3.8-atari-py-0.2.9.drv
/nix/store/ng1vln5c8sln2lm7qfp3xgr71izpsmip-python3.8-gym-0.18.3.drv
/nix/store/0rslwa5gxpkzvj0kk2x63v7bfirwfb05-python3-3.8.9-env.drv
building '/nix/store/vplghxz66sn4c7dhz6cr5rj12jcvlmwn-python3.8-atari-py-0.2.9.drv'...
building '/nix/store/k6cgalfww07a4dfrs75wcdxfljkl4cvg-opencv_python-4.5.2.52-cp38-cp38-manylinux2014_x86_64.whl.drv'...
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
unpacking sources
unpacking source archive /nix/store/8faawz8y35hpyg4w2gzk6xzvwhyhyhiy-atari-py-0.2.9.tar.gz
source root is atari-py-0.2.9
setting SOURCE_DATE_EPOCH to timestamp 1621563593 of file atari-py-0.2.9/setup.cfg
patching sources
configuring
no configure script, doing nothing
building
Executing setuptoolsBuildPhase
trying https://files.pythonhosted.org/packages/cp38/o/opencv-python/opencv_python-4.5.2.52-cp38-cp38-manylinux2014_x86_64.whl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/atari_py
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/common
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/controllers
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/emucore
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/emucore/m6502
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/emucore/m6502/src
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/emucore/m6502/src/bspf
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/emucore/m6502/src/bspf/src
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/emucore/rsynth
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/environment
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/external
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/external/TinyMT
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/games
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/games/supported
creating build/lib.linux-x86_64-3.8/atari_py/ale_interface/src/os_dependent
creating build/lib.linux-x86_64-3.8/atari_py/atari_roms
creating build/lib.linux-x86_64-3.8/atari_py/tests
running build_ext
error: [Errno 2] No such file or directory: 'cmake'
builder for '/nix/store/vplghxz66sn4c7dhz6cr5rj12jcvlmwn-python3.8-atari-py-0.2.9.drv' failed with exit code 1
cannot build derivation '/nix/store/0rslwa5gxpkzvj0kk2x63v7bfirwfb05-python3-3.8.9-env.drv': 1 dependencies couldn't be built
error: build of '/nix/store/0rslwa5gxpkzvj0kk2x63v7bfirwfb05-python3-3.8.9-env.drv' failed
How do I get cmake
to be available during the build process?
It looks like there’s an open mach-nix
issue discussing this, and I’ve reported substantially the same information there, too.
My nix-info
:
- system:
"x86_64-linux"
- host os:
Linux 5.12.10, NixOS, 21.11pre295280.fa0326ce523 (Porcupine)
- multi-user?:
yes
- sandbox:
yes
- version:
nix-env (Nix) 2.3.12
- channels(rule):
"home-manager, nixos-21.11pre304626.8ecc61c91a5"
- channels(root):
"nixos-21.11pre295280.fa0326ce523"
- nixpkgs:
/nix/var/nix/profiles/per-user/root/channels/nixos
Thanks!