-
Notifications
You must be signed in to change notification settings - Fork 85
Developer setup for working on Open library client
Bharat edited this page Jun 29, 2021
·
1 revision
- Python 3.7 + (can be verified by
python--version
) - If you want to parse MARC, follow these steps as well
- Clone the repository and
cd
into the cloned folder
git clone [email protected]:internetarchive/openlibrary-client.git
cd openlibrary-client
- Create a virtual environment to avoid polluting the global python install. There are many ways to create a virtual environment using python (virtual env, poetry and pipenv are the popular options). We will be using virtual env since its usually installed by default.
python -m venv openlibrary-client-venv
this will create a folder called openlibrary-client-venv
. This folder includes a fully independent python environment (including the python binary which would be at openlibrary-client-venv/bin/python
)
- Now we need to activate this virtual environment. Run this command from the root of the cloned project
source ./openlibrary-client-venv/bin/activate # on linux/mac OS
if on windows, run
openlibrary-client-venv\bin\Activate.ps1
- Verify the virtual environment is active by checking the output of
which python
. It should point toopenlibrary-client-venv
- Now that the virtual environment is activated, install the package requirements
pip install -r requirements.txt
pip install -r requirements-dev.txt
- Install the open library client in the virtual environment
python setup.py install
this will install the open library client to openlibrary-client-venv/bin/ol
.
- The cli is installed, configure credentials by following steps from here
- To check the python package, start a python interpreter and import the package and start testing
>>> from olclient.openlibrary import OpenLibrary # This imports the package from the virtual environment
>>> ol = OpenLibrary()
>>> work = ol.Work.get(u'OL82586W')
>>> work.title
'Harry Potter and the Deathly Hallows'
- On code change, run
python setup.py install
to reinstall the package and test.
- tests can be run using
pytest
(pytest is installed during the installation ofrequirements-dev.txt
)