If you are interested in secondary development of Gerapy or contributing to Gerapy, this document details the environment configuration and development process for Gerapy developers.
Development Gerapy requires a Python3 environment and a Node.js environment. The recommended versions are Python 3.6 + and Node.js 10.x +. Please install and make sure to use the python3, pip3, node, npm commands.
First clone Gerapy locally:
git clone https://github.com/Gerapy/Gerapy.git
Once the clone is complete, a Gerapy folder is generated locally.
Go to the Gerapy folder and install the dependencies you need for development:
pip3 install -r requirements.txt
Then install Gerapy locally:
python3 setup.py install
This installs the development version of Gerapy, and if Gerapy was previously installed, this installation will replace the previous version.
The gerapy command can be used after the installation is complete.
Then install the front-end dependencies, the front-end code is in the gerapy/client folder, based on Vue.js development.
Go into the directory and install dependencies.
cd gerapy/client npm install
This will generate a node_modules folder under gerapy/client.
Here are divided into frontend and backend respectively introduced, the two parts need to start at the same time to work properly.
For the backend, the gerapy command requires the Gerapy installation package to be available. However, it is tedious to manually install each time after the change during development.
It is recommended to set the parameter configuration in PyCharm IDE, and it is also convenient for debugging.
- Script path:
gerapy/gerapy/cmd/__init__.py, which is the entry file for the command.
- Running parameters:
runserver 0.0.0.0:5000. Note that it needs to run on port 5000, and the frontend will forward the request to port 5000.
- Environment variables:
PYTHONUNBUFFERED=1;APP_DEBUG=true, where APP_DEBUG is to set the debug mode, and more debug logs will be printed.
- Working path: The working path generated by the gerapy init command.
as the picture shows:
After starting in this way, Gerapy Server will run on port 5000, and the console will print out debugging information.
For the frontend, in the gerapy/client folder, execute:
npm run serve
It can run on port 8080, and its backend API will be forwarded to port 5000, which is the Gerapy Server just started.
Open http://localhost:8080 to enter Gerapy's frontend page.
The backend is based on Django development, and the database used is SQLite, whose main logic is in the gerapy/server folder.
The front end is based on Vue.js development and its main logic is in the gerapy/client folder.
After the frontend modification is completed, if you want to officially release it, you can directly execute it:
npm run build
The result of the build will go to the backend's gerapy/server/core/templates folder.
The release of the backend code can be executed directly:
python3 setup.py upload
It will be automatically uploaded to PyPi and tagged on GitHub, but you must have PyPi and GitHub permissions.