Development Setup
Prerequisites
Before setting up the project locally, ensure you have the following installed:
- Python 3.7 or higher: The library uses modern Python features and type hinting.
- Git: For version control and cloning the repository.
- Google Custom Search API Key: Required to authenticate requests.
- Google Search Engine ID (CX): Required to identify the specific search engine instance.
Setting Up the Local Environment
Follow these steps to configure your local development environment:
1. Clone the Repository
Start by cloning the Eternity repository to your local machine:
git clone https://github.com/UditAkhourii/Eternity.git
cd Eternity
2. Create a Virtual Environment
It is recommended to use a virtual environment to manage dependencies and avoid conflicts with other Python projects.
# Create the environment
python -m venv venv
# Activate the environment (macOS/Linux)
source venv/bin/activate
# Activate the environment (Windows)
venv\Scripts\activate
3. Install in Editable Mode
To develop and test changes in real-time, install the package in "editable" mode. This allows you to import the library while the source code resides in your local folder.
pip install -e .
This command also installs the necessary dependencies, specifically the requests library.
Configuration
The Eternity class requires credentials from the Google Developers Console. To use the library during development, you will need to initialize the class with your specific keys:
from eternity.eternity import Eternity
# Initialize with your local credentials
api_key = "YOUR_GOOGLE_API_KEY"
engine_id = "YOUR_SEARCH_ENGINE_ID"
client = Eternity(api_key, engine_id)
Verifying the Setup
To verify that your development environment is configured correctly, create a small test script (e.g., test_dev.py) in the root directory:
from eternity.eternity import Eternity
def main():
# Initialize the client
client = Eternity(api_key="YOUR_KEY", engine_id="YOUR_ID")
# Test a simple search
query = "Open Source Development"
results = client.get_combined_text(query)
if results:
print("Setup successful! Data retrieved:")
print(results)
else:
print("Setup failed or no results returned.")
if __name__ == "__main__":
main()
Run the script to ensure the connection to the Google API is working through your local copy of the library:
python test_dev.py
Code Style and Standards
When contributing or modifying the code:
- Ensure all new features are implemented within the
Eternityclass ineternity/eternity.py. - Maintain the existing naming conventions for public methods like
search()andget_combined_text(). - Update
setup.pyif you introduce new external dependencies.