numtide / devshell

Per project developer environments
https://numtide.github.io/devshell/
MIT License
1.22k stars 87 forks source link

Skipping Python package tests? #229

Open denizdogan opened 1 year ago

denizdogan commented 1 year ago

I've just started out using this for some internal projects, but I've hit a roadblock that I can't figure out.

One of our Python projects uses Poetry for dependency management, and when I'm trying to install it, some Poetry tests fail due to some strange but common issues that urllib has related to macOS and proxies. A piece of the log has been attached below, mainly for googleability.

I've searched far and wide for solutions to this issue, and many suggest setting the environment variable OBJC_DISABLE_INITIALIZE_FORK_SAFETY to YES. This doesn't seem to work for me, for some reason. I use a Macbook Pro with M1/Apple Silicon.

In a different project that doesn't use numtide/devshell, I am able to skip the Poetry build tests using this as my shell.nix file:

with import <nixpkgs> { };
let
  # util to disable tests during python package installation
  skip-setup-tests = drv: drv.overridePythonAttrs (old: { doCheck = false; });
in
mkShell {
  packages = [
    # build requirements for pscyopg2
    postgresql
    openssl

    # python + poetry
    (python39.withPackages (ps: with ps; [
      # skip testing poetry since it's a bit problematic on macOS:
      # https://stackoverflow.com/a/52230415
      (skip-setup-tests poetry)
    ]))
  ];

  shellHook = ''
    export DJANGO_SETTINGS_MODULE=[...]
    [...etc...]
  '';
}

However, I haven't been able to figure out how to do this using numtide/devshell. Is there any easy way?

Current thread 0x0000000100634580 (most recent call first):
  File "/nix/store/rxp6p62b0zlbzann51p3qf0vkkfl89g6-python3-3.9.14/lib/python3.9/urllib/request.py", line 2623 in proxy_bypass_macosx_sysconf
  File "/nix/store/rxp6p62b0zlbzann51p3qf0vkkfl89g6-python3-3.9.14/lib/python3.9/urllib/request.py", line 2647 in proxy_bypass
  File "/nix/store/kc0f8iz24rw3iq35hvvlg72axbclwjyd-python3.9-requests-2.28.1/lib/python3.9/site-packages/requests/utils.py", line 809 in should_bypass_proxies
  File "/nix/store/kc0f8iz24rw3iq35hvvlg72axbclwjyd-python3.9-requests-2.28.1/lib/python3.9/site-packages/requests/utils.py", line 825 in get_environ_proxies
  File "/nix/store/kc0f8iz24rw3iq35hvvlg72axbclwjyd-python3.9-requests-2.28.1/lib/python3.9/site-packages/requests/sessions.py", line 759 in merge_environment_settings
  File "/nix/store/9vshllxw9bw28pdak0n4l8qmm4vygqgs-python3.9-poetry-1.2.0/lib/python3.9/site-packages/poetry/utils/authenticator.py", line 209 in request
  File "/private/tmp/nix-build-python3.9-poetry-1.2.0.drv-2/source/tests/utils/test_authenticator.py", line 90 in test_authenticator_uses_username_only_credentials

If it should matter, my network settings don't have any proxies of any kind configured.