diff --git a/README.md b/README.md index 268179b..7e8e074 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,25 @@ # activitypub +This is a Python library to use with +[ActivityPub](https://en.wikipedia.org/wiki/ActivityPub). ActivityPub +is an API for an open, distributed, social network. + +## Install + +You can install the development version of activitypub with: + +``` +pip install git+git://github.com/dsblank/activitypub +``` + +or the last packaged version with: + +``` +pip install activitypub +``` + +## Abstractions + This module is designed to be a generally useful ActivityPub library in Python. It targets three different levels of use: * ActivityPub object API diff --git a/activitypub/database/mongodb.py b/activitypub/database/mongodb.py index d1780c5..2cc2221 100644 --- a/activitypub/database/mongodb.py +++ b/activitypub/database/mongodb.py @@ -1,4 +1,8 @@ -from pymongo import MongoClient +try: + from pymongo import MongoClient +except: + def MongoClient(*args, **kwargs): + raise Exception("You need to install pymongo") from .base import Database, Table diff --git a/activitypub/database/redisdb.py b/activitypub/database/redisdb.py index 109f16b..bfd0a1c 100644 --- a/activitypub/database/redisdb.py +++ b/activitypub/database/redisdb.py @@ -1,5 +1,11 @@ -from redis_collections import List -import redis +try: + import redis + from redis_collections import List + from_url = redis.StrictRedis.from_url +except: + def from_url(*args, **kwargs): + raise Exception("You need to install redis and redis_collections") + from .listdb import ListTable from .base import Database @@ -16,5 +22,5 @@ class RedisDatabase(Database): * "redis://localhost:6379" * "redis://localhost:6379/0" """ - self.redis = redis.StrictRedis.from_url(url, **kwargs) if url else None + self.redis = from_url(url, **kwargs) if url else None super().__init__() diff --git a/activitypub/database/sqldb.py b/activitypub/database/sqldb.py index 2bccfd5..2c9a52c 100644 --- a/activitypub/database/sqldb.py +++ b/activitypub/database/sqldb.py @@ -1,6 +1,12 @@ -from sqlalchemy import create_engine, inspect -from sqlalchemy.orm import scoped_session, sessionmaker -from sqlalchemy.pool import StaticPool + +try: + from sqlalchemy import create_engine, inspect + from sqlalchemy.orm import scoped_session, sessionmaker + from sqlalchemy.pool import StaticPool +except: + def create_engine(*args, **kwargs): + raise Exception("You need to install sqlalchemy") + import logging import json diff --git a/requirements.txt b/requirements.txt index de4887b..e69de29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +0,0 @@ -pymongo diff --git a/setup.py b/setup.py index a41316e..a487394 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ setup(name='activitypub', author='Douglas S. Blank', author_email='doug.blank@gmail.com', url='https://github.com/dsblank/activitypub', - install_requires=['pymongo'], + install_requires=[], packages=find_packages(include=['activitypub', 'activitypub.*']), include_data_files = True, test_suite = 'nose.collector',