Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.ffcv: init at 0.0.3 #160441

Merged
merged 2 commits into from
Feb 19, 2022
Merged

python3Packages.ffcv: init at 0.0.3 #160441

merged 2 commits into from
Feb 19, 2022

Conversation

samuela
Copy link
Member

@samuela samuela commented Feb 17, 2022

Motivation for this change

Introduce python3Packages.ffcv. FFCV is an exciting new data loading library for computer vision applications.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@samuela
Copy link
Member Author

samuela commented Feb 17, 2022

It's almost working. The package includes a C++ bit that is compiled and linked via distutils called ffcv._libffcv. That builds fine, but the tests don't seem to find it in PYTHONPATH:

____________________ ERROR collecting tests/test_writer.py _____________________
ImportError while importing test module '/build/source/tests/test_writer.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/afi0ysqw20yiiw2gr2d28dx40bc4ddf8-python3-3.9.10/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
...
ffcv/libffcv.py:5: in <module>
    import ffcv._libffcv
E   ModuleNotFoundError: No module named 'ffcv._libffcv'

Anyone have any idea what could be going on here? IIRC @jonringer you mentioned something about this (or maybe it was cython?) a while back?

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/packaging-a-python-library-with-c-distutils-extension/17732/1

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 labels Feb 17, 2022
--replace "'webdataset'," ""
'';

buildInputs = [ pkgconfig libjpeg ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if pkgconfig the python package should go to nativeBuildInputs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that I should move it to nativeBuildInputs? Or something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we want to move pkgconfig into nativeBuildInputs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving pkgconfig into nativeBuildInputs doesn't work unfortunately:

Executing setuptoolsBuildPhase
Traceback (most recent call last):
  File "/build/source/nix_run_setup", line 8, in <module>
    exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
  File "setup.py", line 30, in <module>
    extension_kwargs = pkgconfig('opencv4', extension_kwargs)
  File "setup.py", line 18, in pkgconfig
    raise Exception()
Exception
builder for '/nix/store/zsvvs4ispid5s6viwnpvcfl12p3hmzvl-python3.9-ffcv-0.0.3.drv' failed with exit code 1

@samuela
Copy link
Member Author

samuela commented Feb 18, 2022

@SuperSandro2000 any idea how to deal with the ffcv._libffcv situation?

@SuperSandro2000
Copy link
Member

@SuperSandro2000 any idea how to deal with the ffcv._libffcv situation?

I think you want something similar to export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH" in the prePhase where the error happens.

@samuela
Copy link
Member Author

samuela commented Feb 18, 2022

Adding

  preCheck = ''
    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
  '';

still gives me the same errors unfortunately.

@samuela
Copy link
Member Author

samuela commented Feb 18, 2022

Weirdly enough, $out/${python.sitePackages} is /nix/store/n6ck59zm07s8qk4j1szwlq9jys35n7ks-python3.9-ffcv-0.0.3/lib/python3.9/site-packages and the file does exist in there: $out/${python.sitePackages}/ffcv/_libffcv.cpython-39-x86_64-linux-gnu.so. I guess for some reason it can't be loaded in the nix build environment... possibly because it tries to access CUDA stuff?

@samuela
Copy link
Member Author

samuela commented Feb 18, 2022

Ok well I updated everything based on the feedback thus far in 00dc6dd. I'll mark as "ready for review" and merge tomorrow unless anyone objects.

@samuela samuela marked this pull request as ready for review February 18, 2022 21:25
@samuela samuela merged commit 977360e into NixOS:master Feb 19, 2022
@samuela samuela deleted the samuela/ffcv branch February 19, 2022 19:54
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/packaging-a-python-library-with-c-distutils-extension/17732/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants