Recipe for rapid deployment and testing of new code

The question is what steps are needed to deploy and test new code for a plugin that is being developed on a production instance host (not a development instance one).

I already got the first step is to build the wheel on any development host, with command

$ python ./bin/maintenance/build-wheel.py plugin ../indico-plugins/<my_plugin> --add-version-suffix

And then scp the generated wheel file to the destination server, and pip install it.
Quick question: does the wheel file need to be copied to any particular directory? Or that does not matter? I guess it does not, but just in case.
Second question is: the pip install command is ran as root, or indico user?

After that, is there any extra step needed? For a development host, I know you have to manually add the new plugin to indico.conf file. Is that still needed? Similar question with adding the plugin to the internal DB with command

indico db --all-plugins upgrade

Is that also needed?

Thanks a lot.
Jose

Doesn’t matter where. /tmp/ is a good choice since you don’t need it anymore after installing it.

Indico user, while the virtualenv is active (source ~/.venv/bin/activate)

Yes, that’s always needed to load a plugin.

That’s only needed if you have plugins that have alembic revisions to create database tables. Your plugin doesn’t. so no need to run it.

Thanks for the prompt response.
I guess I only have one follow up question, since we are talking about testing during development. I imagine there is no problem if the same plugin is re-installed many times, right? There is no need to perform any cleanup step before each reinstallation, correct?

By using --add-version-suffix each time you build the plugin it has a higher version number (since the build time is included in it), so you can just install the next wheel and pip will automatically uninstall the older one first.

excellent !! Thanks a lot !!

OK. I am trying to run the build-wheel command. I am having a few small issues, so I just need confirmation.

  1. do I need to create manually a directory dist/?

     $ python ./bin/maintenance/build-wheel.py plugin ../indico-plugins/livesync_invenio/ --add-version-suffix
     Usage: build-wheel.py [OPTIONS] COMMAND [ARGS]...
    
     Error: Invalid value for "--target-dir" / "-d": Directory "dist/" does not exist.
    
  2. Is it needed to run the command from indico/ directory?

     $ python indico/bin/maintenance/build-wheel.py plugin ./indico-plugins/livesync_invenio --add-version-suffix
     Usage: build-wheel.py plugin [OPTIONS] PLUGIN_DIR
     
     Error: Invalid value for "plugin_dir": Directory "./indico-plugins/livesync_invenio" does not exist.
    
     
     $ cd indico
     indico $ python ./bin/maintenance/build-wheel.py plugin ../indico-plugins/livesync_invenio --add-version-suffix
     Usage: build-wheel.py [OPTIONS] COMMAND [ARGS]...
     
     Error: Invalid value for "--target-dir" / "-d": Directory "dist/" does not exist.
    
  3. any particular version of python and/or setuptools is needed?

     indico $ mkdir dist
    
     indico $ python --version
     Python 2.7.5
    
     indico $ ./bin/maintenance/build-wheel.py plugin ../indico-plugins/livesync_invenio --add-version-suffix
     Traceback (most recent call last):
       File "./bin/maintenance/build-wheel.py", line 334, in <module>
         cli(obj={})
       File "/usr/lib/python2.7/site-packages/click/core.py", line 721, in __call__
         return self.main(*args, **kwargs)
       File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
         rv = self.invoke(ctx)
       File "/usr/lib/python2.7/site-packages/click/core.py", line 1065, in invoke
         return _process_result(sub_ctx.command.invoke(sub_ctx))
       File "/usr/lib/python2.7/site-packages/click/core.py", line 894, in invoke
         return ctx.invoke(self.callback, **ctx.params)
       File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
         return callback(*args, **kwargs)
       File "/usr/lib/python2.7/site-packages/click/decorators.py", line 27, in new_func
         return f(get_current_context().obj, *args, **kwargs)
       File "./bin/maintenance/build-wheel.py", line 296, in build_plugin
         clean, output = git_is_clean_plugin()
       File "./bin/maintenance/build-wheel.py", line 168, in git_is_clean_plugin
         toplevel = list({x.split('.')[0] for x in find_packages(include=('indico', 'indico.*)})
     TypeError: find_packages() got an unexpected keyword argument 'include'
     ')

yes

yes as well

you should always have the latest versions of pip, setuptools and wheel installed in your virtualenv → pip install -U pip setuptools wheel