This guide expects you to have installed in your system the following tools:
- pip
- git
- virtualenv
- virtualenvwrapper
- npm > 3.0
- postgresql + devel headers
- libxml2 + devel headers
- libxslt + devel headers
- ImageMagick
- redis
- elasticsearch
$ sudo yum install python-pip python-virtualenv python-virtualenvwrapper \
npm postgresql postgresql-devel libxml2-devel ImageMagick redis git \
libxslt-devel
$ sudo npm -g install npmFor elasticsearch you can find the installation instructions on the elasticsearch install page, and, to run the development environment, you will need also add the following workarounds:
$ sudo usermod -a -G $USER elasticsearch
$ newgrp elasticsearch # or log out and in again
$ sudo ln -s /etc/elasticsearch /usr/share/elasticsearch/config.. TODO::
Add also Ubuntu and MacOS
Create a virtual environment and clone the INSPIRE source code using git:
$ mkvirtualenv inspirehep
$ workon inspirehep
(inspirehep)$ cdvirtualenv
(inspirehep)$ mkdir src
(inspirehep)$ git clone https://github.com/inspirehep/inspire-next.git src/inspirehepUse pip to install all requirements, it's recommended to upgrade pip and setuptools to latest too:
(inspirehep)$ pip install --upgrade pip setuptools
(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ pip install -r requirements.txt --pre --exists-action iAnd for development:
(inspirehep)$ pip install -e .[development]If you want to change the database url, or enable the debug mode for troubleshooting, you can do so in the inspirehep.cfg file under var/inspirehep-instance, you might need to create it:
(inspirehep)$ cdvirtualenv var/inspirehep-instance
(inspirehep)$ vim inspirehep.cfgThere you can change the value of any of the variables that are set under the file src/inspirehep/inspirehep/config.py, for example:
DEBUG = True
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://someuser:somepass@my.postgres.server:5432/inspirehep"Note
Make sure that the configuration keys you override here have the same exact name as the ones in the config.py file, as it will not complain if you put a key that did not exist.
We build assets using npm. Make sure you have installed it system wide.
(inspirehep)$ sudo npm update
(inspirehep)$ sudo npm install -g node-sass@3.8.0 clean-css requirejs uglify-jsNote
If you don't want to use sudo to install the npm packages globally, you can still setup a per-user npm modules installation that will allow you to install/remove modules as normal user. You can find more info in the npm docs here.
Then we build the INSPIRE assets:
(inspirehep)$ inspirehep npm
(inspirehep)$ cdvirtualenv var/inspirehep-instance/static
(inspirehep)$ npm install
(inspirehep)$ inspirehep collect -v
(inspirehep)$ inspirehep assets buildNote
Alternatively, run sh scripts/clean_assets to do the above in one command.
We will use postgreSQL as database. Make sure you have installed it system wide.
Then create the database and database tables if you haven't already done so:
(inspirehep)$ psql
# CREATE USER inspirehep WITH PASSWORD 'dbpass123';
# CREATE DATABASE inspirehep;
# GRANT ALL PRIVILEGES ON DATABASE inspirehep to inspirehep;
(inspirehep)$ inspirehep db init
(inspirehep)$ inspirehep db createYou must have rabbitmq installed and running (and reachable) somewhere. To run it locally on a CentOS:
$ sudo yum install rabbitmq-server
$ sudo service rabbitmq-server start
$ sudo systemctl enable rabbitmq-server.service # to start on system bootWe use honcho to manage our services and run the development server. See Procfile for details.
(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ honcho startAnd the site is now available on http://localhost:5000.
Note
Remember that you'll need to have the elasticsearch bin directory in your $PATH or prepend the binaries executed with the path to the elasticsearch bin directory in your system.
First of all, we will need to install the analysis-icu elasticsearch plugin.
(inspirehep)$ plugin install analysis-icuNow we are ready to create the indexes:
(inspirehep)$ inspirehep index initIf you are having troubles creating your indices, e.g. due to index name changes or existing legacy indices, try:
(inspirehep)$ inspirehep index destroy --force --yes-i-know
(inspirehep)$ inspirehep index initNow you can create a sample admin user, for that we will use the fixtures:
(inspirehep)$ inspirehep fixtures initNote
If you are not running in debug mode, remember to add the local=1 HTTP GET parameter to the login url so it will show you the login form, for example:
http://localhost:5000/login/?local=1
(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ inspirehep migrator populate -f inspirehep/demosite/data/demo-records.xml.gz --wait=trueNote
Alternatively, run sh scripts/recreate_records to drop db/index/records and re-create them in one command, it will also create the admin user.
Warning
Remember to keep honcho running in a separate window.
Now you can create regular users (optional) with the command:
(inspirehep)$ inspirehep users create your@email.com -aSame way as demo records:
(inspirehep)$ inspirehep migrator populate -f inspirehep/demosite/data/sample.xmlWhile running honcho you can access the records at
$ firefox http://localhost:5000/literature/1
$ curl -i -H "Accept: application/json" http://localhost:5000/api/records/1If you want to test the doJSON output for a specific rule, make sure it is added to doJSON entry points and then do the following (e.g. for the hep rule):
(inspirehep)$ dojson -l marcxml -i inspirehep/demosite/data/sample.xml do hep