Skip to content

Commit 908a260

Browse files
committed
package the SQL files
1 parent 047d14e commit 908a260

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed
File renamed without changes.
File renamed without changes.

legi/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from collections import namedtuple
1111
from contextlib import contextmanager
1212
from itertools import chain, repeat
13+
import os.path
1314
import re
1415
from sqlite3 import Connection, IntegrityError, OperationalError, ProgrammingError, Row
1516
import traceback
@@ -21,6 +22,7 @@
2122

2223
IGNORE = object()
2324
NIL = object()
25+
ROOT = os.path.dirname(__file__) + '/'
2426

2527

2628
@contextmanager
@@ -84,7 +86,7 @@ def one(*args, **kw):
8486
try:
8587
db.run("SELECT 1 FROM db_meta LIMIT 1")
8688
except OperationalError:
87-
with open('sql/schema.sql', 'r') as f:
89+
with open(ROOT + 'sql/schema.sql', 'r') as f:
8890
db.executescript(f.read())
8991

9092
if update_schema:
@@ -146,7 +148,7 @@ def run_migrations(db):
146148
v = db.one("SELECT value FROM db_meta WHERE key = 'schema_version'") or 0
147149
if v == 0:
148150
db.insert('db_meta', dict(key='schema_version', value=v))
149-
migrations = open('sql/migrations.sql').read().split('\n\n-- migration #')
151+
migrations = open(ROOT + 'sql/migrations.sql').read().split('\n\n-- migration #')
150152
n = 0
151153
for m in migrations[1:]:
152154
n, sql = m.split('\n', 1)

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@
1919
long_description="See https://github.com/Legilibre/legi.py",
2020
install_requires=open(join(dirname(__file__), 'requirements.txt')).read(),
2121
keywords='legi law france',
22+
include_package_data=True,
23+
zip_safe=False,
2224
)

0 commit comments

Comments
 (0)