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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.netbox-plugin-prometheus-sd: init at 0.8.0 #307786

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xanderio
Copy link
Contributor

Description of changes

Things done

  • 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.

@xanderio xanderio requested a review from n0emis April 29, 2024 15:53
@xanderio
Copy link
Contributor Author

Currently unable to build on darwin do to: #307790

@xanderio
Copy link
Contributor Author

xanderio commented Apr 29, 2024

Result of nixpkgs-review pr 307786 run on x86_64-linux 1

2 packages failed to build:
  • python312Packages.netbox-plugin-prometheus-sd
  • python312Packages.netbox-plugin-prometheus-sd.dist
2 packages built:
  • python311Packages.netbox-plugin-prometheus-sd
  • python311Packages.netbox-plugin-prometheus-sd.dist

I have no idea why this fails when using python312

netbox-plugin-prometheus-sd> Traceback (most recent call last):
netbox-plugin-prometheus-sd>   File "<string>", line 1, in <module>
netbox-plugin-prometheus-sd>   File "<string>", line 1, in <lambda>
netbox-plugin-prometheus-sd>   File "/nix/store/m51f0kclg01xdc0mjxqs5cpyaxqbqhg5-python3-3.12.3/lib/python3.12/importlib/__init__.py", line 90, in import_module
netbox-plugin-prometheus-sd>     return _bootstrap._gcd_import(name[level:], package, level)
netbox-plugin-prometheus-sd>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-plugin-prometheus-sd>   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
netbox-plugin-prometheus-sd>   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
netbox-plugin-prometheus-sd>   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
netbox-plugin-prometheus-sd>   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
netbox-plugin-prometheus-sd>   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
netbox-plugin-prometheus-sd>   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
netbox-plugin-prometheus-sd>   File "/nix/store/p6kv6jhxzzh8j493r5n45aaz0g88r8r4-python3.12-netbox-plugin-prometheus-sd-0.8.0/lib/python3.12/site-packages/netbox_prometheus_sd/__init__.py", line 1, in <module>
netbox-plugin-prometheus-sd>     from extras.plugins import PluginConfig
netbox-plugin-prometheus-sd>   File "/nix/store/2907a2xzwa8y6hicmyyns91rbkm8v49g-netbox-3.7.4/opt/netbox/netbox/extras/plugins/__init__.py", line 1, in <module>
netbox-plugin-prometheus-sd>     from .navigation import *
netbox-plugin-prometheus-sd>   File "/nix/store/2907a2xzwa8y6hicmyyns91rbkm8v49g-netbox-3.7.4/opt/netbox/netbox/extras/plugins/navigation.py", line 3, in <module>
netbox-plugin-prometheus-sd>     from netbox.plugins.navigation import *
netbox-plugin-prometheus-sd>   File "/nix/store/2907a2xzwa8y6hicmyyns91rbkm8v49g-netbox-3.7.4/opt/netbox/netbox/netbox/plugins/__init__.py", line 4, in <module>
netbox-plugin-prometheus-sd>     from django.apps import AppConfig
netbox-plugin-prometheus-sd> ModuleNotFoundError: No module named 'django'

@minijackson
Copy link
Member

I think I know why the import check doesn't work for Python3.11, NetBox is packaged as an Python application, and not as a Python module, so when you put netbox in the function arguments, the package gets picked up from the toplevel, and not from python312Packages. So NetBox depends on django for Python3.11, which Python3.12 cannot import (because it only has /nix/store/...-django-4.2.11/lib/python3.11).

In practice, this shouldn't matter, since the NixOS module only picks the plugins from the correct package set, but it would be nice to not have broken packages. Is there a way to add Python modules for a specific Python version?

@minijackson
Copy link
Member

I found a solution for this issue, that I implemented in #311657. I added the netbox.pythonVersion passthru attribute, which we can use to enable or disable the imports check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants