aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsetup.py15
-rw-r--r--src/pydrilla/pydrilla.py7
-rw-r--r--src/test/development_config.json (renamed from src/pydrilla/development_config.json)1
-rw-r--r--src/test/example_content/hello/bye.js (renamed from example_content/hello/bye.js)0
-rw-r--r--src/test/example_content/hello/cc0.txt (renamed from example_content/hello/cc0.txt)0
-rw-r--r--src/test/example_content/hello/hello.js (renamed from example_content/hello/hello.js)0
-rw-r--r--src/test/example_content/hello/index.json (renamed from example_content/hello/index.json)0
-rw-r--r--src/test/example_content/hello/message.js (renamed from example_content/hello/message.js)0
-rw-r--r--src/test/test_pydrilla.py6
9 files changed, 21 insertions, 8 deletions
diff --git a/setup.py b/setup.py
index 4f87ecc..28d9ca5 100755
--- a/setup.py
+++ b/setup.py
@@ -21,14 +21,21 @@ from setuptools import setup, find_packages
import sys
import pathlib
+def files_find(package_path, subpath, rglob):
+ package_path = pathlib.Path(package_path)
+ for path in (package_path / subpath).rglob(rglob):
+ if not path.is_dir():
+ yield str(path.relative_to(package_path))
+
settings = {}
settings['version'] = '0.2'
settings['app_package_name'] = 'pydrilla'
settings['project_root'] = pathlib.Path(__file__).resolve().parent
packages_root = settings['project_root'] / 'src'
main_package_dir = packages_root / settings['app_package_name']
+test_dir = packages_root / 'test'
settings['locales_dir'] = main_package_dir / 'locales'
-settings['config_path'] = main_package_dir / 'development_config.json'
+settings['config_path'] = test_dir / 'development_config.json'
sys.path.insert(0, str(packages_root))
import test
@@ -63,8 +70,10 @@ setup(
'test': ['pytest'],
},
package_data={
- 'pydrilla': ['config.json', *helper.locale_files_relative()],
- 'test': []
+ 'pydrilla': ['config.json', *helper.locale_files_relative(),
+ *files_find(main_package_dir, 'templates', '*.html')],
+ 'test': [*files_find(packages_root / 'test', 'example_content', '*'),
+ 'development_config.json']
},
cmdclass=helper.commands()
# project_urls={
diff --git a/src/pydrilla/pydrilla.py b/src/pydrilla/pydrilla.py
index 239267e..2c4ad0d 100644
--- a/src/pydrilla/pydrilla.py
+++ b/src/pydrilla/pydrilla.py
@@ -541,7 +541,6 @@ def load_content_from_subdir(subdir_path, source_name, content):
content.process_index(index, source_name)
def load_content(path):
- path = pathlib.Path(path)
if not path.is_dir():
raise ValueError(_('content_dir_path_not_dir'))
@@ -586,8 +585,12 @@ def create_app(config_path=(here / 'config.json'), flask_config={}):
app._pydrilla_werror = config.get('werror', False)
if 'hydrilla_parent' in config:
raise MyNotImplError('hydrilla_parent', config_path.name)
+
+ content_dir = pathlib.Path(config['content_dir'])
+ if not content_dir.is_absolute():
+ content_dir = config_path.parent / content_dir
with app.app_context():
- app._pydrilla_content = load_content(config['content_dir'])
+ app._pydrilla_content = load_content(content_dir.resolve())
app.register_blueprint(bp)
diff --git a/src/pydrilla/development_config.json b/src/test/development_config.json
index 1660edb..5998918 100644
--- a/src/pydrilla/development_config.json
+++ b/src/test/development_config.json
@@ -9,6 +9,7 @@
// this config is meant to be used in development environment;
// unlike config.json, it shall not be included in distribution
{
+ // Relative paths now get resolved from config's containing direcotry.
"content_dir": "./example_content",
// Except files from content_dir to be served there (used to redirect
diff --git a/example_content/hello/bye.js b/src/test/example_content/hello/bye.js
index e6fd70c..e6fd70c 100644
--- a/example_content/hello/bye.js
+++ b/src/test/example_content/hello/bye.js
diff --git a/example_content/hello/cc0.txt b/src/test/example_content/hello/cc0.txt
index 0e259d4..0e259d4 100644
--- a/example_content/hello/cc0.txt
+++ b/src/test/example_content/hello/cc0.txt
diff --git a/example_content/hello/hello.js b/src/test/example_content/hello/hello.js
index d87ea7f..d87ea7f 100644
--- a/example_content/hello/hello.js
+++ b/src/test/example_content/hello/hello.js
diff --git a/example_content/hello/index.json b/src/test/example_content/hello/index.json
index 34f5eba..34f5eba 100644
--- a/example_content/hello/index.json
+++ b/src/test/example_content/hello/index.json
diff --git a/example_content/hello/message.js b/src/test/example_content/hello/message.js
index da5966d..da5966d 100644
--- a/example_content/hello/message.js
+++ b/src/test/example_content/hello/message.js
diff --git a/src/test/test_pydrilla.py b/src/test/test_pydrilla.py
index 07c580a..ed98f13 100644
--- a/src/test/test_pydrilla.py
+++ b/src/test/test_pydrilla.py
@@ -33,9 +33,9 @@ import json
from pydrilla import pydrilla, create_app
-test_dir = Path(__file__).resolve().parent
-pydrilla_dir = Path(pydrilla.__file__).resolve().parent
-test_config_path = pydrilla_dir / 'development_config.json'
+test_dir = Path(__file__).resolve().parent
+packages_dir = test_dir.parent
+test_config_path = test_dir / 'development_config.json'
@pytest.fixture
def client():