This guide expects you to have installed in your system the following tools:
- git
- virtualenv
- virtualenvwrapper
- npm > 3.0
- postgresql + devel headers
- libxml2 + devel headers
- libxslt + devel headers
- ImageMagick
- redis
- elasticsearch
$ sudo yum install python-virtualenv python-virtualenvwrapper \
npm postgresql postgresql-devel libxml2-devel ImageMagick redis git \
libxslt-devel
$ sudo npm -g install npm
For elasticsearch you can find the installation instructions on the `elasticsearch install page`_, and, to run the development environment, you will need also to 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
$ brew install libxml2
$ brew install libxslt
$ brew cask install caskroom/versions/java8
$ brew install imagemagick@6
$ brew install libmagic
$ brew install ghostscript
$ brew install poppler
You might also need to link imagemagick:
$ brew link --force imagemagick@6
Add to ~/.bash_profile:
# ElasticSearch.
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
Create a virtual environment and clone the INSPIRE source code using git:
$ mkvirtualenv --python=python2.7 inspirehep
$ workon inspirehep
(inspirehep)$ cdvirtualenv
(inspirehep)$ mkdir src
(inspirehep)$ git clone https://github.com/inspirehep/inspire-next.git src/inspirehep
Note
It is also possible (and more flexible) to do the above the other way around like this and clone the project into a folder of your choice:
$ git clone https://github.com/inspirehep/inspire-next.git inspirehep
$ cd inspirehep
$ mkvirtualenv --python=python2.7 inspirehep
$ workon inspirehep
This approach enables you to switch to a new virtual environment
without having to clone the project again. You simply specify on
which environment you want to workon
using its name.
Just be careful to replace all cdvirtualenv src/inspirehep
in the
following with a cd path_you_chose/inspirehep
.
Use 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 i
(inspirehep)$ pip install honcho
And 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.cfg
There 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:[email protected]: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 [email protected] clean-css@^3.4.24 requirejs uglify-js
Note
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`_.
In particular, if you want to install the npm
packages directly in your
virtualenv
, just add NPM_CONFIG_PREFIX=$VIRTUAL_ENV
in the
postactivate
file of your virtualenv
folder and you will be able to
run the above command from inside your virtual environment.
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 build
Note
Alternatively, run sh scripts/clean_assets to do the above in one command.
We will start, postgresql, elasticsearch, redis and rabbitmq.
Then create the database and database tables if you haven't already done so:
(inspirehep)$ docker compose up database indexer redis rabbitmq
We use `honcho`_ to manage our services and run the development server. See `Procfile`_ for details.
(inspirehep)$ cdvirtualenv src/inspirehep
(inspirehep)$ honcho start
And 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.
Now we are ready to create the indexes:
(inspirehep)$ inspirehep index init
If 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 init
Now you can create a sample admin user, for that we will use the fixtures:
(inspirehep)$ inspirehep fixtures init
Note
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 migrate file --force --wait inspirehep/demosite/data/demo-records.xml.gz
Note
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 [email protected] -a