Installing a plugin from a private PyPI repository
I am trying to integrate a pybuilder plugin that is deployed in a private PyPI repository, but it seems that the link to the repository is being ignored by the plugin downloader. It appears that the plugin is loaded right when the use_plugin() statement is encountered, but the project properties are not set at that point, leading to those 3 parameters being None
@init
def initialize(project):
# ....
project.set_property('install_dependencies_extra_index_url', 'url goes here')
After some digging it seems that things are done a bit out of order - first the project module is loaded, which implies loading all plugins and the initializers are executed much later.
As a workaround one can access the project object from the Reactor instance and set the properties required for loading the plugin there:
from pybuilder.core import init, use_plugin
from pybuilder.reactor import Reactor
# loading other plugins...
# required to access a private PyPI repository
project = Reactor.current_instance().project
project.set_property('install_dependencies_extra_index_url', 'pypi url')
project.set_property('install_dependencies_trusted_host', 'hostname')
use_plugin('pypi:pybuilder_private_pypi_plugin')
@init
def initialize(project):
# the usual stuff
Hi, @kvalev Great workaround.
Unfortunately, workaround doesn't work for me - I need to pass install_dependencies_extra_index_url from command line. But PyBuilder applies properties from command line later.
Created #515 which provides global properties from command line to properties immediately.
Did corresponding changes into pypi_server plugin
Now it sets properties on use_plugin step. So usage is:
use_plugin('...')
use_plugin('...')
....
use_plugin('pypi:pybuilder_pypi_server')
use_plugin('pypi:pybuilder_private_pypi_plugin')
And call with -P pypi_server=... like
pyb clean install_dependencies analyze publish --debug --environment=dev -P pypi_server=my-pypi-dev
@arcivanov we are planning to use pybuilder and build many custom plugins, is this issue regarding using a private repository handled and is a there a recommended way to do it ?
@pavan-kumar222 What kind of authentication are you looking for in the private repository?
You can see here the way private repository authentication can be configured outside of PyB: https://pip.pypa.io/en/stable/topics/authentication/
@arcivanov I will use either username/pwd based authentication or a user token. We will try to use Nexus to host Pypi type private repo.
However my question was in similar lines as the first comment in this issue, Should I use the workaround mentioned here to load the plugin from my private repo or is there a better way, where a plugin is first searched in public pypi and also private repo automatically.
I'll need to create/find a test harness that allows PIP503-compliant repository to test your use case. A lot of things changed since 2017, including internal pip logic.
I've done some debugging, and while the workaround above does works for me - the url for my private PIP repo does indeed get added when PIP is being executed - I'm getting an SSL error, because my repo is using a SSL certificate not trusted by default by PIP. The workaround would work for my, if the --cert option for PIP was exposed I guess.