cript0nauta / pynixify

Nix expression generator for Python projects
GNU General Public License v3.0
64 stars 11 forks source link

Installation fails with "mypy: command not found" #60

Closed jab closed 1 year ago

jab commented 1 year ago

Just followed the instructions from https://github.com/cript0nauta/pynixify#installation in a freshly-installed nix-darwin environment and it failed with

/nix/store/rwq18lggifjff65sk8jymhsnc11jsqrd-stdenv-darwin/setup: line 1590: mypy: command not found
Screenshot 2023-02-19 at 7 40 30 PM
cript0nauta commented 1 year ago

It looks like the latest nixpkgs is making the test phase fail. I'll investigate the issue during the next days. As a workaround, you can try building the package without running the tests by making the following change:

diff --git a/default.nix b/default.nix
index 8a4f132..a6b6613 100644
--- a/default.nix
+++ b/default.nix
@@ -25,8 +25,7 @@ python3.pkgs.toPythonApplication (python3.pkgs.pynixify.overridePythonAttrs
     checkInputs = drv.checkInputs ++ [ nix chosenNixfmt bats ];

     checkPhase = ''
-      ${if runMypy then "mypy pynixify/ tests/ acceptance_tests/" else ""}
-      pytest tests/ -m 'not usesnix'  # We can't run Nix inside Nix builds
+      true
     '';

     postInstall = ''
jab commented 1 year ago

Thanks, with that workaround I was able to build pynixify and get a little farther. Now pynixify fails when I run it, as follows:

❯ pynixify --local bidict -r dev-deps/dev.txt
error: Unsupported system
(use '--show-trace' to show detailed location information)
Traceback (most recent call last):
  File "/nix/store/4dw4mqplg5r8z41r0q6f59vjl69q7frj-python3.10-pynixify-0.1/bin/..pynixify-wrapped-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/4dw4mqplg5r8z41r0q6f59vjl69q7frj-python3.10-pynixify-0.1/lib/python3.10/site-packages/pynixify/command.py", line 157, in main
    asyncio.run(_main_async(
  File "/nix/store/n3qask6wrby75704dz3vcwnd3f9vkab8-python3-3.10.9/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/n3qask6wrby75704dz3vcwnd3f9vkab8-python3-3.10.9/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/nix/store/4dw4mqplg5r8z41r0q6f59vjl69q7frj-python3.10-pynixify-0.1/lib/python3.10/site-packages/pynixify/command.py", line 188, in _main_async
    version_chooser: VersionChooser = await _build_version_chooser(
  File "/nix/store/4dw4mqplg5r8z41r0q6f59vjl69q7frj-python3.10-pynixify-0.1/lib/python3.10/site-packages/pynixify/command.py", line 60, in _build_version_chooser
    nixpkgs_data = NixpkgsData(await load_nixpkgs_data({}))
  File "/nix/store/4dw4mqplg5r8z41r0q6f59vjl69q7frj-python3.10-pynixify-0.1/lib/python3.10/site-packages/pynixify/nixpkgs_sources.py", line 109, in load_nixpkgs_data
    assert status == 0
AssertionError

Would you like me to open a separate issue for this? My ultimate goal here is to be able to use nix to enter an environment for local development of my Python library, https://github.com/jab/bidict. To do that, I thought I would try converting my pip-tools-based dependency specs into nix expressions via pynixify first.

Thanks again for your help with this.

cript0nauta commented 1 year ago

If you're talking about this dev.txt file, it's likely that pynixify will fail for this usecase. Quoting pynixify's README:

Your requirements file shouldn't be the output of pip freeze because it has == in all requirements. Therefore, it makes reusing Nixpkgs packages harder. You shouldn't treat your requirements file as a lockfile, but as an abstract definition indicating the minimum and maximum versions of each library. Keep in mind that you don't need a lockfile: you can just pin Nixpkgs to have something with the reproducibility of lockfiles. Or even better than it, since Nix also tracks the system dependencies of each library!

So I'd recommend to start with a requirements file without pinned versions (the project's pyproject.toml could be a good starting point for determining the deps), and only add version markers if the chosen versions are incompatible with your project.

cript0nauta commented 1 year ago

Closing the issue. Right now mypy will be used only on nixos-unstable, and just confirmed it builds fine with it after some fixes. Feel free to re-open if you have any related issue.