495 |
"""Return the name of the postgis_sql file |
"""Return the name of the postgis_sql file |
496 |
|
|
497 |
A postgis installation usually has the postgis_sql file in |
A postgis installation usually has the postgis_sql file in |
498 |
PostgreSQL's datadir (i.e. the directory where PostgreSQL keeps |
PostgreSQL's $datadir (i.e. the directory where PostgreSQL keeps |
499 |
static files, not the directory containing the databases). |
static files, not the directory containing the databases). |
500 |
Unfortunately there's no way to determine the name of this directory |
Unfortunately there's no way to determine the name of this directory |
501 |
with pg_config so we assume here that it's |
with pg_config so we assume here that it's |
502 |
$bindir/../share/postgresql/. |
$bindir/../share/postgresql/. |
503 |
|
|
504 |
|
Furthermore, different versions of postgis place the file in |
505 |
|
slightly different locations. For instance: |
506 |
|
|
507 |
|
postgis 0.7.5 $datadir/contrib/postgis.sql |
508 |
|
postgis 0.8.1 $datadir/postgis.sql |
509 |
|
|
510 |
|
To support both versions, we look in both places and return the |
511 |
|
first one found (looking under contrib first). If the file is not |
512 |
|
found the return value is None. |
513 |
""" |
""" |
514 |
bindir = run_config_script("pg_config --bindir").strip() |
bindir = run_config_script("pg_config --bindir").strip() |
515 |
return os.path.join(bindir, "..", "share", "postgresql", |
datadir = os.path.join(bindir, "..", "share", "postgresql") |
516 |
"contrib", "postgis.sql") |
for filename in [os.path.join(datadir, "contrib", "postgis.sql"), |
517 |
|
os.path.join(datadir, "postgis.sql")]: |
518 |
|
if os.path.exists(filename): |
519 |
|
return filename |
520 |
|
|
521 |
|
|
522 |
_postgres_server = None |
_postgres_server = None |
523 |
def get_test_server(): |
def get_test_server(): |