diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..dedb795 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +recursive-include asl_rulebook2/webapp/config *.* +recursive-include asl_rulebook2/webapp/data *.* +recursive-include asl_rulebook2/webapp/static *.* +recursive-include asl_rulebook2/webapp/templates *.* +recursive-include asl_rulebook2/extract/data *.* + +recursive-include asl_rulebook2/webapp/tests/fixtures *.* + +recursive-include asl_rulebook2/bin *.* diff --git a/asl_rulebook2/extract/__init__.py b/asl_rulebook2/extract/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/asl_rulebook2/webapp/data/doc b/asl_rulebook2/webapp/data/doc new file mode 120000 index 0000000..b8f7789 --- /dev/null +++ b/asl_rulebook2/webapp/data/doc @@ -0,0 +1 @@ +../../../doc \ No newline at end of file diff --git a/asl_rulebook2/webapp/data/doc.txt b/asl_rulebook2/webapp/data/doc.txt new file mode 100644 index 0000000..a13376d --- /dev/null +++ b/asl_rulebook2/webapp/data/doc.txt @@ -0,0 +1,3 @@ +The doc/ symlink is to allow documents in the root doc/ directory to be served, even if this package has been installed in non-editable mode (i.e. into site-packages). + +See get_doc() for more details. diff --git a/asl_rulebook2/webapp/doc.py b/asl_rulebook2/webapp/doc.py index 6163fd5..73ac3ba 100644 --- a/asl_rulebook2/webapp/doc.py +++ b/asl_rulebook2/webapp/doc.py @@ -16,10 +16,19 @@ def get_doc( path ): """Return the specified documentation file.""" # locate the documentation file - doc_dir = os.path.join( os.path.dirname( __file__ ), "../../doc/" ) - fname = safe_join( doc_dir, path ) + dname = os.path.join( os.path.dirname( __file__ ), "../../doc/" ) + fname = safe_join( dname, path ) if not os.path.isfile( fname ): - abort( 404 ) + # FUDGE! If this package has been installed in non-editable mode (i.e. into site-packages, while it's possible + # to get the root doc/ directory included in the installation (by adding a __init__.py file :-/, then including + # it in MANIFEST.in), it ends up in asl-rulebook2's parent directory (i.e. the main site-packages directory), + # which is definitely not what we want. + # We work-around this my creating a symlink to the doc/ directory, which will get followed when the package + # is installed. This won't work on Windows, but we'll do the necessary penance, and just live with it... :-/ + dname = os.path.join( os.path.dirname( __file__ ), "data/doc/" ) + fname = safe_join( dname, path ) + if not os.path.isfile( fname ): + abort( 404 ) # check if the file is Markdown if os.path.splitext( path )[1] == ".md": diff --git a/asl_rulebook2/webapp/run_server.py b/asl_rulebook2/webapp/run_server.py index 03840d3..c9db334 100755 --- a/asl_rulebook2/webapp/run_server.py +++ b/asl_rulebook2/webapp/run_server.py @@ -20,7 +20,7 @@ from asl_rulebook2.webapp import app, globvars @click.option( "--force-init-delay", default=0, help="Force the webapp to initialize (#seconds delay)." ) @click.option( "--debug","flask_debug", is_flag=True, default=False, help="Run Flask in debug mode." ) def main( bind_addr, data_dir, force_init_delay, flask_debug ): - """Run the webapp server.""" + """Run the asl-rulebook2 webapp server.""" # initialize flask_port = None diff --git a/setup.py b/setup.py index 43fc850..de14c10 100644 --- a/setup.py +++ b/setup.py @@ -40,4 +40,7 @@ setup( data_files = [ ( "asl-rulebook2", ["LICENSE.txt"] ), ], + entry_points = { + "console_scripts": "asl-rulebook2 = asl_rulebook2.webapp.run_server:main", + } )