Skip to content

Commit ccec351

Browse files
committed
Update phase 1
1 parent f5eddea commit ccec351

File tree

10 files changed

+93
-78
lines changed

10 files changed

+93
-78
lines changed

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.tox
22
.noseids
33
rdflib_sqlalchemy.egg-info
4-
.eggs/
5-
__pycache__/
4+
/build/
65
*.pyc
7-
build/
6+
/__pycache__/
7+
*.project
8+
*.pydevproject
9+
/.eggs/

.travis.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ env:
88
- DB=mysql
99
- DB=sqlite
1010
python:
11-
- "2.6"
12-
- "2.7"
13-
- "3.3"
14-
- "3.4"
11+
- 2.6
12+
- 2.7
13+
- 3.3
14+
- 3.4
15+
- 3.5
1516
install:
1617
- if [[ ${TRAVIS_PYTHON_VERSION%%.*} == '2' ]]; then pip install -r requirements-py2.txt --use-mirrors; fi
1718
- if [[ ${TRAVIS_PYTHON_VERSION%%.*} == '3' ]]; then pip install -r requirements-py3.txt --use-mirrors; fi
18-
- if [[ ${TRAVIS_PYTHON_VERSION} == 'pypy' ]]; then pip install --upgrade 'git+https://github.com/gjhiggins/isodate#egg=isodate'; fi
1919
- python setup.py install
2020
before_script:
21-
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS rdflibsqla_test;' -U postgres; fi"
22-
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database rdflibsqla_test;' -U postgres; fi"
23-
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS rdflibsqla_test'; fi"
21+
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS test;' -U postgres; psql -c 'create database test;' -U postgres; export DBURI='postgresql+psycopg2://postgres@localhost/test'; fi"
22+
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS test'; export DBURI='mysql+mysqldb://test@localhost/test?charset=utf8'; fi"
23+
- sh -c "if [ '$DB' = 'sqlite' ]; then export DBURI='sqlite:///%(here)s/test.sqlite'; fi"
2424
script:
2525
# Must cd somewhere else so python3 doesn't get confused and run
2626
# the python2 code from the current directory instead of the installed
2727
# 2to3 version.
28-
- if [[ ${TRAVIS_PYTHON_VERSION%%.*} == '2' ]]; then nosetests; fi
29-
- if [[ ${TRAVIS_PYTHON_VERSION%%.*} == '3' ]]; then nosetests --where=./build/src; fi
30-
28+
- if [[ ${TRAVIS_PYTHON_VERSION%%.*} == '2' ]]; then PYTHONWARNINGS=default nosetests --with-coverage --cover-tests --cover-package=rdflib_sqlalchemy ; fi
29+
- if [[ ${TRAVIS_PYTHON_VERSION%%.*} == '3' ]]; then PYTHONWARNINGS=default nosetests --with-coverage --cover-tests --cover-package=build/src/rdflib_sqlalchemy --where=./build/src; fi
30+

rdflib_sqlalchemy/termutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ def normalizeGraph(graph):
9090
(rdflib.term.URIRef(%(u)s'http://purl.org/net/bel-epa/gjh'), 'U')
9191
>>> g = ConjunctiveGraph(memstore, Namespace("http://rdflib.net/ns"))
9292
>>> normalizeGraph(g) #doctest: +ELLIPSIS
93-
(Namespace(%(u)s'http://rdflib.net/ns'), 'U')
93+
(rdflib.term.URIRef(%(u)s'http://rdflib.net/ns'), 'U')
9494
>>> g = QuotedGraph(memstore, Namespace("http://rdflib.net/ns"))
9595
>>> normalizeGraph(g)
96-
(Namespace(%(u)s'http://rdflib.net/ns'), 'F')
96+
(rdflib.term.URIRef(%(u)s'http://rdflib.net/ns'), 'F')
9797
9898
"""
9999
if isinstance(graph, QuotedGraph):

requirements-py2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
-e git+https://github.com/RDFLib/rdflib.git#egg=rdflib
1+
coverage
22
psycopg2
33
MySQL-python

requirements-py3.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-e git+https://github.com/RDFLib/rdflib.git#egg=rdflib
1+
coverage
22
psycopg2
3-
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.2.zip
3+
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
44
-e git+https://github.com/davispuh/MySQL-for-Python-3#egg=MySQL-python

setup.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#!/usr/bin/env python
2+
"""Setup."""
23
# -*- coding: utf-8 -*-
34
import sys
45
import re
56

67

78
def setup_python3():
8-
# Taken from "distribute" setup.py
9+
"""Taken from "distribute" setup.py."""
910
from distutils.filelist import FileList
10-
from distutils import dir_util, file_util, util, log
11+
from distutils import dir_util, file_util, util
1112
from os.path import join, exists
1213

1314
tmp_src = join("build", "src")
15+
# Not covered by "setup.py clean --all", so explicit deletion required.
1416
if exists(tmp_src):
1517
dir_util.remove_tree(tmp_src)
16-
log.set_verbosity(1)
18+
# log.set_verbosity(1)
1719
fl = FileList()
1820
for line in open("MANIFEST.in"):
1921
if not line.strip():
@@ -33,10 +35,33 @@ def setup_python3():
3335

3436
return tmp_src
3537

38+
kwargs = {}
39+
if sys.version_info[0] >= 3:
40+
from setuptools import setup
41+
# kwargs['use_2to3'] = True # is done in setup_python3 above already
42+
kwargs['install_requires'] = ["rdflib>=4.0", "SQLAlchemy"]
43+
kwargs['tests_require'] = ['coveralls']
44+
kwargs['requires'] = []
45+
kwargs['src_root'] = setup_python3()
46+
assert setup
47+
else:
48+
try:
49+
from setuptools import setup
50+
assert setup
51+
kwargs['test_suite'] = "nose.collector"
52+
kwargs['install_requires'] = ["rdflib>=4.0", "SQLAlchemy"]
53+
kwargs['tests_require'] = ['coveralls']
54+
55+
except ImportError:
56+
from distutils.core import setup
57+
3658

37-
# Find version. We have to do this because we can't import it in Python 3 until
38-
# its been automatically converted in the setup process.
3959
def find_version(filename):
60+
"""Find version.
61+
62+
We have to do this because we can't import it in Python 3 until
63+
its been automatically converted in the setup process.
64+
"""
4065
_version_re = re.compile(r'__version__ = "(.*)"')
4166
for line in open(filename):
4267
version_match = _version_re.match(line)
@@ -45,7 +70,7 @@ def find_version(filename):
4570

4671
__version__ = find_version('rdflib_sqlalchemy/__init__.py')
4772

48-
config = dict(
73+
setup(
4974
name='rdflib-sqlalchemy',
5075
version=__version__,
5176
description="rdflib extension adding SQLAlchemy as an AbstractSQLStore back-end store",
@@ -73,42 +98,21 @@ def find_version(filename):
7398
"Programming Language :: Python",
7499
"Programming Language :: Python :: 2",
75100
"Programming Language :: Python :: 3",
76-
"Programming Language :: Python :: 2.5",
77101
"Programming Language :: Python :: 2.6",
78102
"Programming Language :: Python :: 2.7",
79-
"Programming Language :: Python :: 3.2",
80103
"Programming Language :: Python :: 3.3",
104+
"Programming Language :: Python :: 3.4",
105+
"Programming Language :: Python :: 3.5",
81106
"License :: OSI Approved :: BSD License",
82107
"Topic :: Software Development :: Libraries :: Python Modules",
83108
"Operating System :: OS Independent",
84109
"Natural Language :: English",
85-
],
86-
test_suite="test",
110+
],
87111
entry_points={
88112
'rdf.plugins.store': [
89-
'SQLAlchemy = rdflib_sqlalchemy.SQLAlchemy:SQLAlchemy',
113+
# 'SQLAlchemy = rdflib_sqlalchemy.SQLAlchemy:SQLAlchemy',
90114
# 'SQLAlchemyBase = rdflib_sqlalchemy.SQLAlchemyBase:SQLAlchemy',
91115
],
92-
}
116+
},
117+
**kwargs
93118
)
94-
95-
install_requires = ["rdflib>=4.0",
96-
"SQLAlchemy"]
97-
98-
if sys.version_info[0] >= 3:
99-
from setuptools import setup
100-
assert setup
101-
config.update({'use_2to3': True})
102-
config.update({'src_root': setup_python3()})
103-
else:
104-
if sys.version_info[:2] < (2, 6):
105-
install_requires += ['pysqlite']
106-
try:
107-
from setuptools import setup
108-
assert setup
109-
config.update({'test_suite': "nose.collector"})
110-
except ImportError:
111-
from distutils.core import setup
112-
113-
config['install_requires'] = install_requires
114-
setup(**config)

test/test_sqlalchemy_mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Specific to Travis-ci continuous integration and testing ...
2828
sqlalchemy_url = Literal(os.environ.get(
2929
'DBURI',
30-
"mysql+%s://[email protected]:3306/rdflibsqla_test?charset=utf8" % dialect))
30+
"mysql+%s://[email protected]:3306/test?charset=utf8" % dialect))
3131
# Generally ...
3232
# sqlalchemy_url = Literal(
3333
# "mysql+mysqldb://user:password@hostname:port/database?charset=utf8")

test/test_sqlalchemy_postgresql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
sqlalchemy_url = os.environ.get(
1616
'DBURI',
17-
'postgresql+psycopg2://postgres@localhost/rdflibsqla_test')
17+
'postgresql+psycopg2://postgres@localhost/test')
1818

1919

2020
class SQLAPgSQLGraphTestCase(graph_case.GraphTestCase):

test/test_store_performance.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Store performance tests."""
12
import unittest
23
import gc
34
import os
@@ -7,34 +8,46 @@
78
from tempfile import mkdtemp
89
from rdflib import Graph
910
from rdflib import URIRef
11+
try:
12+
from urllib.request import pathname2url
13+
except:
14+
from urllib import pathname2url
15+
from nose import SkipTest
16+
17+
raise SkipTest("Store performance test suspended")
1018

1119

1220
def random_uri():
21+
"""Return random URI."""
1322
return URIRef("%s" % random())
1423

1524

1625
class StoreTestCase(unittest.TestCase):
1726
"""
18-
Test case for testing store performance... probably should be
19-
something other than a unit test... but for now we'll add it as a
20-
unit test.
27+
Test case for testing store performance.
28+
29+
Probably should be something other than a unit test
30+
but for now we'll add it as a unit test.
2131
"""
32+
2233
store = 'IOMemory'
2334
path = None
2435
storetest = True
2536
performancetest = True
2637

2738
def setUp(self):
39+
"""Setup."""
2840
self.gcold = gc.isenabled()
2941
gc.collect()
3042
gc.disable()
31-
3243
self.graph = Graph(store=self.store)
33-
self.tmppath = mkdtemp()
34-
self.graph.open(self.tmppath)
44+
if self.path is None:
45+
self.path = pathname2url(mkdtemp())
46+
self.graph.open(self.path)
3547
self.input = Graph()
3648

3749
def tearDown(self):
50+
"""Teardown."""
3851
self.graph.close()
3952
if self.gcold:
4053
gc.enable()
@@ -53,6 +66,7 @@ def tearDown(self):
5366
os.remove(self.path)
5467

5568
def testTime(self):
69+
"""Test timing."""
5670
# number = 1
5771
print('"%s": [' % self.store)
5872
for i in ['500triples', '1ktriples', '2ktriples',
@@ -80,9 +94,12 @@ def add_from_input():
8094

8195

8296
class SQLAlchemyStoreTestCase(StoreTestCase):
97+
"""SQLAlchemy Store."""
98+
8399
store = "SQLAlchemy"
84100

85101
def setUp(self):
102+
"""Setup."""
86103
self.store = "SQLAlchemy"
87104
self.path = "sqlite:///%(here)s/test/tmpdb.sqlite" % {
88105
"here": os.getcwd()}

tox.ini

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
11
[tox]
22
envlist =
3-
py26,py27,cover,py33,py34
3+
py26,py27,cover,py34,py35
44

55
[testenv]
6+
passenv = DB DBURI
67
commands =
78
{envpython} setup.py clean --all
89
{envpython} setup.py nosetests
910
deps =
1011
nose
11-
git+http://github.com/RDFLib/rdflib#egg=rdflib
12-
SQLAlchemy
1312
psycopg2
1413
MySQL-python
1514

16-
17-
[testenv:py33]
18-
basepython = python3.3
15+
[testenv:py34]
16+
basepython = python3.4
1917
commands =
2018
{envpython} setup.py clean --all
2119
{envpython} setup.py build
22-
nosetests --where=./build/src
20+
{envpython} setup.py nosetests --where=./build/src
2321
deps =
2422
nose
25-
git+http://github.com/RDFLib/rdflib#egg=rdflib
26-
SQLAlchemy
2723
psycopg2
28-
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.2.zip
24+
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
2925
git+https://github.com/PyMySQL/mysqlclient-python#egg=MySQLdb
3026

31-
[testenv:py34]
32-
basepython = python3.4
27+
[testenv:py35]
28+
basepython = python3.5
3329
commands =
3430
{envpython} setup.py clean --all
3531
{envpython} setup.py build
36-
nosetests --where=./build/src
32+
{envpython} setup.py nosetests --where=./build/src
3733
deps =
3834
nose
39-
git+http://github.com/RDFLib/rdflib#egg=rdflib
40-
SQLAlchemy
4135
psycopg2
42-
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.2.zip
36+
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
4337
git+https://github.com/PyMySQL/mysqlclient-python#egg=MySQLdb
4438

4539
[testenv:cover]
@@ -51,8 +45,6 @@ commands =
5145
deps =
5246
nose
5347
coverage
54-
git+http://github.com/RDFLib/rdflib#egg=rdflib
55-
SQLAlchemy
5648
psycopg2
5749
MySQL-python
5850

0 commit comments

Comments
 (0)