Extension Repository Connector - Pypi
Extension extending Extension Module with possibility to import extension from Pypi repositories. |
Type | JAR |
Category | repository |
Developed by | |
Active Installs | 6 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
XWiki has possibility to script on its pages in Python. Under the hood it's using the Java Scripting API and Jython that takes care of running this script and returning result to page. Jython has implementation only for standard libraries. That's why this extension was created: to be able to import to XWiki other (non-standard) python packages that are hosted on pypi.
Limitations
Unfortunately there's huge amount of python packages that cannot be installed in XWiki. There are 2 groups of such packages:
- Platform dependent - packages depending on libraries written in C and compiled per given platform, e.g. NumPy or SciPy. Jython has limited compatibility with such packages. The future development of extension may take into consideration JyNI (Jython Native Interface) that is a project with aim to enable Jython to use native CPython extensions.
- Packages only for python 3 - that are packages that does not have built version for python 2. Jython version used by XWiki is currently 2.7.1. That means it's compatible with python packages in version 2.7. (Built package means platform independent Wheel package). To release package on pypi the minimum requirement is to upload sources in 'sdist' package and unfortunately there are quite some packages (but fortunately mainly those less common) that have only 'sdist' (zip) distribution.
Configuration
No configuration needed. The extension after installment connects automatically to the main pypi repository (and practically the only commonly used one).
Example
Import of requests package
After installing this extension, go to the "Extensions" page of the Administration. Then search for requests by choosing "All Extensions" from the drop down list filter. The result should be more less the following:
Then choose from the requests package from the result list and proceed to install it as you'd do for any XWiki extension:
Script on page
Create a wiki page with the following script:
import requests
r = requests.get('http://www.mocky.io/v2/59736a8810000022034418c8')
print "Status code is: "
print r.status_code
{{/python}}
The result should be:
200
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Release Notes
v1.1.4
v1.1.3
v1.1.2
Cleanup.
v1.1.1
v1.1
Various bugfixes.
v1.0
First version.
Dependencies
Dependencies for this extension (org.xwiki.contrib:repository-pypi 1.1.4):
- org.xwiki.commons:xwiki-commons-component-api 8.4
- org.xwiki.commons:xwiki-commons-extension-api 8.4
- org.xwiki.commons:xwiki-commons-extension-repository-http 8.4
- com.fasterxml.jackson.core:jackson-databind 2.8.4
- org.apache.lucene:lucene-core 6.2.1
- org.apache.lucene:lucene-queryparser 6.2.1
- net.lingala.zip4j:zip4j 1.3.2
- commons-io:commons-io 2.5