Plugin development - virtualenvs #7473
Unanswered
cpmills1975
asked this question in
Q&A
Replies: 1 comment
-
If you want your plugin to be accessible within the netbox venv, you need to install it to that venv. I simply develop on my development machine in the venv, but I actually upload and install the plugin into my live environment using the netbox venv. The caveat of course is that the plugin will be lost with any upgrades and you will need to reinstall it. I believe you can specify the path in the local_requirements.txt and pip will install it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Would someone mind explaining the "Create a virtual environment" section from https://netbox.readthedocs.io/en/stable/plugins/development/?
I sort of understand the concept of virtual environments - they act as an isolated installation of Python that has the required libraries (Django, NetBox, etc) embedded in it and it acts entirely separately from any other python venv on the same system.
What confuses me is how one venv can see in to another - if I create a dedicated venv for my plugin, surely my plugin exists only within that venv? How can I then install that Django app in to the venv where NetBox lives? Does creating a netbox.pth file create some sort of link going the other way such that the NetBox venv can see the venv where my plugin lives?
Until now, I've been working with the netbox-docker image and since that doesn't (or didn't) use a venv (presumably because the separation is provided by Docker), I've been extending the container and installing my plugin directly in to the python environment within. I'm now working in a dev environment with venvs to try and speed up my development (building docker images every time I update my plugin code is a PITA!)
Beta Was this translation helpful? Give feedback.
All reactions