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

uhd: fix for python module failing to install #306273

Closed
wants to merge 1 commit into from

Conversation

systemofapwne
Copy link

Description of changes

This PR fixes the python module failing to install by patching the upstream build process.

I kept the enablePythonApi flag off however, to respect established uhd package default options.

Detail of this fix:

  • It avoids upstreams build process to use pythons setuptools directly by omitting the virtual-env check.
  • It rewrites upstreams derived installation path for the python module (/nix/store/-uhd/../-python-3.XY-env/lib/python-3.XY/site-packages -> /nix/store/-uhd/lib/python-3.XY/site-packages) to avoid permission problems.

Things done

Only tested on x86_64-linux

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@NixOSInfra NixOSInfra added the 12. first-time contribution This PR is the author's first one; please be gentle! label Apr 23, 2024
@hexchen
Copy link
Member

hexchen commented Apr 25, 2024

@ofborg eval

Copy link
Contributor

@bjornfor bjornfor left a comment

Choose a reason for hiding this comment

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

LGTM. Didn't test.

@wegank wegank added 12.approvals: 1 This PR was reviewed and approved by one reputable person 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package labels Apr 26, 2024
Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

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

Hello @systemofapwne ! Thanks for debugging this issue, and attempting to solve it. Also, welcome to Nixpkgs.

It rewrites upstreams derived installation path for the python module (/nix/store/-uhd/../-python-3.XY-env/lib/python-3.XY/site-packages -> /nix/store/-uhd/lib/python-3.XY/site-packages) to avoid permission problems.

I read upstream's CMake files to get some context for your patch, and I think that now, since we have a better understanding of how they work, we can suggest to them a fix that will be acceptable by them as well.

My main comment is below. In general, I dislike using such patches, as they are easy to become inapplicable when versions are bumped. I also read upstream's source code for their master branch, vs the v4.6.0.0 tag, and I'm afraid your patch will become a maintenance burden on the next uhd release, or the releases afterwards.

Additionally, I think that if this enablePythonApi feature will be properly fixed, we can set it to true by default, so that we will be forced to test that it works on every release of uhd.

DEPENDS ${PYUHD_FILES})

add_custom_target(pyuhd_library ALL DEPENDS ${TIMESTAMP_FILE} pyuhd)
+set(HAVE_PYTHON_VIRTUALENV FALSE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps instead of this, and the string(REGEX REPLACE, we can modify the command upstream uses here:

https://github.com/EttusResearch/uhd/blob/50fa3baa2e11ea3b30d5a7e397558e9ae76d8b00/host/python/CMakeLists.txt#L179-L180

? What do you think? Perhaps upstream will also accept such a change..

Copy link
Author

Choose a reason for hiding this comment

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

Do you have a suggestion on how to utilize upstreams direct call to setuptools for this package here? I am rather fresh to nix and still learning about the details.

@systemofapwne
Copy link
Author

Hello @systemofapwne ! Thanks for debugging this issue, and attempting to solve it. Also, welcome to Nixpkgs.

It rewrites upstreams derived installation path for the python module (/nix/store/-uhd/../-python-3.XY-env/lib/python-3.XY/site-packages -> /nix/store/-uhd/lib/python-3.XY/site-packages) to avoid permission problems.

I read upstream's CMake files to get some context for your patch, and I think that now, since we have a better understanding of how they work, we can suggest to them a fix that will be acceptable by them as well.

My main comment is below. In general, I dislike using such patches, as they are easy to become inapplicable when versions are bumped. I also read upstream's source code for their master branch, vs the v4.6.0.0 tag, and I'm afraid your patch will become a maintenance burden on the next uhd release, or the releases afterwards.

Additionally, I think that if this enablePythonApi feature will be properly fixed, we can set it to true by default, so that we will be forced to test that it works on every release of uhd.

I have absolutely the same view on this as you, since I noticed the same change between master and the uhd-4.6 branch. A change of upstream is most welcome. E.g. by allowing an override for the VENV detection by a build parameter.

To the regexp: I think this mostly became necessary due to this packages structure of handling the python env:

pythonEnvArg = (ps: with ps; [ mako ]
. For UHD 3.5, this regexp was not necessary (https://github.com/NixOS/nixpkgs/blob/nixos-21.11/pkgs/applications/radio/uhd/3.5.nix).

Little sidenote: UHD 3.5 (nixpkgs 21.11) was properly installing the uhd python bindungs due to the VENV check failing upstream and the python-env of this package being differently defined. That together lead to my patch.

@doronbehar
Copy link
Contributor

OK so I investigated this a bit further, and I found a solution already supported by upstream's cmake option UHD_PYTHON_DIR. I opened #307435 as an alternative to this PR. I also checked that gnuradio{,3_{8,9}}{,Minimal}, which all depend on uhdMinimal (that doesn't install the Python API), still build with this change. Your approval that it produces a desired layout is welcome.

@systemofapwne
Copy link
Author

Closed in favour of this more solid PR: #307435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 11-100 10.rebuild-linux: 11-100 12.approvals: 1 This PR was reviewed and approved by one reputable person 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants