From 3019b765469c4fb7ff15cc42bc6e870b933374d2 Mon Sep 17 00:00:00 2001
From: Justin Littman <justinlittman@gwu.edu>
Date: Tue, 1 Sep 2015 10:51:01 -0400
Subject: [PATCH] Added support for pypi.

---
 README.md                                 |  7 ++++++
 orcid2vivo.py                             | 18 ++++++++-------
 {app => orcid2vivo_app}/__init__.py       |  0
 {app => orcid2vivo_app}/affiliations.py   |  2 +-
 {app => orcid2vivo_app}/bio.py            |  0
 {app => orcid2vivo_app}/fundings.py       |  0
 {app => orcid2vivo_app}/utility.py        |  0
 {app => orcid2vivo_app}/vivo_namespace.py |  0
 {app => orcid2vivo_app}/vivo_uri.py       |  0
 {app => orcid2vivo_app}/works.py          |  0
 orcid2vivo_loader.py                      |  6 +++--
 orcid2vivo_service.py                     |  4 +++-
 setup.py                                  | 28 +++++++++++++++++++++++
 tests/app/test_affiliations.py            |  6 ++---
 tests/app/test_bio.py                     |  8 +++----
 tests/app/test_fundings.py                |  6 ++---
 tests/app/test_utility.py                 |  2 +-
 tests/app/test_vivo_uri.py                |  4 ++--
 tests/app/test_works.py                   |  6 ++---
 19 files changed, 69 insertions(+), 28 deletions(-)
 rename {app => orcid2vivo_app}/__init__.py (100%)
 rename {app => orcid2vivo_app}/affiliations.py (99%)
 rename {app => orcid2vivo_app}/bio.py (100%)
 rename {app => orcid2vivo_app}/fundings.py (100%)
 rename {app => orcid2vivo_app}/utility.py (100%)
 rename {app => orcid2vivo_app}/vivo_namespace.py (100%)
 rename {app => orcid2vivo_app}/vivo_uri.py (100%)
 rename {app => orcid2vivo_app}/works.py (100%)
 create mode 100644 setup.py

diff --git a/README.md b/README.md
index 3a60ca7..4db5e71 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,13 @@ Tool for retrieving data from the ORCID API and crosswalking to VIVO-ISF.
 
 Try it at  http://gw-orcid2vivo.wrlc.org/orcid2vivo
 
+##Installation
+With python/pip installed:
+
+```
+pip install orcid2vivo
+```
+
 ## Commandline
 * Supports outputting to:
     * screen / stdout
diff --git a/orcid2vivo.py b/orcid2vivo.py
index 5e0a6b5..0f44e2d 100644
--- a/orcid2vivo.py
+++ b/orcid2vivo.py
@@ -1,16 +1,18 @@
+#!/usr/bin/env python
+
 import requests
 import argparse
 import codecs
 from rdflib import Literal, Graph, URIRef
 from rdflib.namespace import Namespace
-from app.vivo_uri import HashIdentifierStrategy
-from app.vivo_namespace import VIVO, FOAF
-from app.affiliations import AffiliationsCrosswalk
-from app.bio import BioCrosswalk
-from app.fundings import FundingCrosswalk
-from app.works import WorksCrosswalk
-from app.utility import sparql_insert, clean_orcid
-import app.vivo_namespace as ns
+from orcid2vivo_app.vivo_uri import HashIdentifierStrategy
+from orcid2vivo_app.vivo_namespace import VIVO, FOAF
+from orcid2vivo_app.affiliations import AffiliationsCrosswalk
+from orcid2vivo_app.bio import BioCrosswalk
+from orcid2vivo_app.fundings import FundingCrosswalk
+from orcid2vivo_app.works import WorksCrosswalk
+from orcid2vivo_app.utility import sparql_insert, clean_orcid
+import orcid2vivo_app.vivo_namespace as ns
 
 
 class SimpleCreateEntitiesStrategy():
diff --git a/app/__init__.py b/orcid2vivo_app/__init__.py
similarity index 100%
rename from app/__init__.py
rename to orcid2vivo_app/__init__.py
diff --git a/app/affiliations.py b/orcid2vivo_app/affiliations.py
similarity index 99%
rename from app/affiliations.py
rename to orcid2vivo_app/affiliations.py
index 11335f8..1aa323a 100644
--- a/app/affiliations.py
+++ b/orcid2vivo_app/affiliations.py
@@ -3,7 +3,7 @@
 from vivo_namespace import FOAF
 from vivo_uri import to_hash_identifier
 from utility import add_date, add_date_interval
-import app.vivo_namespace as ns
+import orcid2vivo_app.vivo_namespace as ns
 
 
 class AffiliationsCrosswalk():
diff --git a/app/bio.py b/orcid2vivo_app/bio.py
similarity index 100%
rename from app/bio.py
rename to orcid2vivo_app/bio.py
diff --git a/app/fundings.py b/orcid2vivo_app/fundings.py
similarity index 100%
rename from app/fundings.py
rename to orcid2vivo_app/fundings.py
diff --git a/app/utility.py b/orcid2vivo_app/utility.py
similarity index 100%
rename from app/utility.py
rename to orcid2vivo_app/utility.py
diff --git a/app/vivo_namespace.py b/orcid2vivo_app/vivo_namespace.py
similarity index 100%
rename from app/vivo_namespace.py
rename to orcid2vivo_app/vivo_namespace.py
diff --git a/app/vivo_uri.py b/orcid2vivo_app/vivo_uri.py
similarity index 100%
rename from app/vivo_uri.py
rename to orcid2vivo_app/vivo_uri.py
diff --git a/app/works.py b/orcid2vivo_app/works.py
similarity index 100%
rename from app/works.py
rename to orcid2vivo_app/works.py
diff --git a/orcid2vivo_loader.py b/orcid2vivo_loader.py
index 9d1ca99..f3284ff 100644
--- a/orcid2vivo_loader.py
+++ b/orcid2vivo_loader.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
 import argparse
 import sqlite3
 import os
@@ -7,8 +9,8 @@
 from rdflib import Graph
 from rdflib.compare import graph_diff
 from orcid2vivo import default_execute
-from app.vivo_namespace import ns_manager
-from app.utility import sparql_insert, sparql_delete
+from orcid2vivo_app.vivo_namespace import ns_manager
+from orcid2vivo_app.utility import sparql_insert, sparql_delete
 
 log = logging.getLogger(__name__)
 
diff --git a/orcid2vivo_service.py b/orcid2vivo_service.py
index a260efc..42de177 100644
--- a/orcid2vivo_service.py
+++ b/orcid2vivo_service.py
@@ -1,9 +1,11 @@
+#!/usr/bin/env python
+
 from flask import Flask, render_template, request, session, Response, flash, Markup
 import argparse
 import json
 import urllib
 from orcid2vivo import default_execute
-import app.utility as utility
+import orcid2vivo_app.utility as utility
 
 app = Flask(__name__)
 def_format = None
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..67fc80d
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,28 @@
+from setuptools import setup
+
+setup(
+    name='orcid2vivo',
+    version='0.9.0',
+    url='https://github.com/gwu-libraries/orcid2vivo',
+    author='Justin Littman',
+    author_email='justinlittman@gmail.com',
+    py_modules=['orcid2vivo', 'orcid2vivo_loader', 'orcid2vivo_service'],
+    packages=['orcid2vivo_app', ],
+    scripts=['orcid2vivo.py', 'orcid2vivo_loader.py', 'orcid2vivo_service.py'],
+    description="For retrieving data from the ORCID API and crosswalking to VIVO-ISF.",
+    platforms=['POSIX'],
+    test_suite='tests',
+    install_requires=['rdflib>=4.2.0',
+                      'requests>=2.7.0',
+                      'bibtexparser>=0.6.1',
+                      'flask>=0.10.1'],
+    tests_require=['vcrpy>=1.7.0',
+                   'mock>=1.3.0'],
+    classifiers=[
+        'Intended Audience :: Developers',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Programming Language :: Python :: 2.7',
+        'Development Status :: 4 - Beta',
+        'Framework :: Flask',
+    ],
+)
diff --git a/tests/app/test_affiliations.py b/tests/app/test_affiliations.py
index 2309295..6fda7ce 100644
--- a/tests/app/test_affiliations.py
+++ b/tests/app/test_affiliations.py
@@ -1,9 +1,9 @@
 from unittest import TestCase
 import json
-from app.affiliations import AffiliationsCrosswalk
-import app.vivo_namespace as ns
+from orcid2vivo_app.affiliations import AffiliationsCrosswalk
+import orcid2vivo_app.vivo_namespace as ns
 from rdflib import Graph
-from app.vivo_uri import HashIdentifierStrategy
+from orcid2vivo_app.vivo_uri import HashIdentifierStrategy
 from orcid2vivo import SimpleCreateEntitiesStrategy
 
 
diff --git a/tests/app/test_bio.py b/tests/app/test_bio.py
index a0dec15..7647338 100644
--- a/tests/app/test_bio.py
+++ b/tests/app/test_bio.py
@@ -3,11 +3,11 @@
 
 from unittest import TestCase
 import json
-from app.bio import BioCrosswalk
-import app.vivo_namespace as ns
+from orcid2vivo_app.bio import BioCrosswalk
+import orcid2vivo_app.vivo_namespace as ns
 from rdflib import Literal, Graph, RDF, RDFS
-from app.vivo_namespace import D, VIVO, FOAF
-from app.vivo_uri import HashIdentifierStrategy
+from orcid2vivo_app.vivo_namespace import D, VIVO, FOAF
+from orcid2vivo_app.vivo_uri import HashIdentifierStrategy
 from orcid2vivo import SimpleCreateEntitiesStrategy
 
 
diff --git a/tests/app/test_fundings.py b/tests/app/test_fundings.py
index 1c4d603..71e6d5e 100644
--- a/tests/app/test_fundings.py
+++ b/tests/app/test_fundings.py
@@ -1,9 +1,9 @@
 from unittest import TestCase
 from tests import FIXTURE_PATH
-from app.fundings import FundingCrosswalk
+from orcid2vivo_app.fundings import FundingCrosswalk
 import orcid2vivo
-import app.vivo_namespace as ns
-from app.vivo_uri import HashIdentifierStrategy
+import orcid2vivo_app.vivo_namespace as ns
+from orcid2vivo_app.vivo_uri import HashIdentifierStrategy
 from orcid2vivo import SimpleCreateEntitiesStrategy
 
 from rdflib import Graph, RDFS
diff --git a/tests/app/test_utility.py b/tests/app/test_utility.py
index e690a26..a3df2da 100644
--- a/tests/app/test_utility.py
+++ b/tests/app/test_utility.py
@@ -1,5 +1,5 @@
 from unittest import TestCase
-from app.utility import clean_orcid
+from orcid2vivo_app.utility import clean_orcid
 
 
 class TestUtility(TestCase):
diff --git a/tests/app/test_vivo_uri.py b/tests/app/test_vivo_uri.py
index f0bdd5a..388a0d4 100644
--- a/tests/app/test_vivo_uri.py
+++ b/tests/app/test_vivo_uri.py
@@ -1,6 +1,6 @@
 from unittest import TestCase
-from app.vivo_uri import HashIdentifierStrategy
-from app.vivo_namespace import VIVO, OBO
+from orcid2vivo_app.vivo_uri import HashIdentifierStrategy
+from orcid2vivo_app.vivo_namespace import VIVO, OBO
 
 
 class TestHashIdentifierStrategy(TestCase):
diff --git a/tests/app/test_works.py b/tests/app/test_works.py
index f46917a..f599d52 100644
--- a/tests/app/test_works.py
+++ b/tests/app/test_works.py
@@ -3,10 +3,10 @@
 
 from unittest import TestCase
 import json
-from app.works import WorksCrosswalk 
-import app.vivo_namespace as ns
+from orcid2vivo_app.works import WorksCrosswalk
+import orcid2vivo_app.vivo_namespace as ns
 from rdflib import Graph, Literal, RDFS
-from app.vivo_uri import HashIdentifierStrategy
+from orcid2vivo_app.vivo_uri import HashIdentifierStrategy
 from orcid2vivo import SimpleCreateEntitiesStrategy
 
 #Saving this because will be monkey patching