diff --git a/protcur/MANIFEST.in b/protcur/MANIFEST.in index e18108c..55e12dd 100644 --- a/protcur/MANIFEST.in +++ b/protcur/MANIFEST.in @@ -1,5 +1,8 @@ recursive-include test * +recursive-include units *.rkt +include README.org exclude MANIFEST.in +exclude units/parsing.rkt recursive-exclude *.egg-info * recursive-exclude * *.pyc recursive-exclude * *.swp diff --git a/protcur/protcur/analysis.py b/protcur/protcur/analysis.py index 524fa7b..302f6d9 100755 --- a/protcur/protcur/analysis.py +++ b/protcur/protcur/analysis.py @@ -25,13 +25,12 @@ #from pysercomb import parsing_parsec from hyputils.hypothesis import HypothesisAnnotation, HypothesisHelper, idFromShareLink from protcur.core import linewrap, color_pda, log, logd -from protcur.config import __script_folder__ +from protcur.config import __units_folder__ as units_folder from IPython import embed sgv = Vocabulary(cache=True) RFU = 'protc:references-for-use' -parameter_expression, *_ = units.make_unit_parser(Path(__script_folder__, - '../../protc-lib/protc/units')) +parameter_expression, *_ = units.make_unit_parser(units_folder) error_output = [] # utility diff --git a/protcur/protcur/config.py b/protcur/protcur/config.py index 0cde0fb..a1fb7e2 100644 --- a/protcur/protcur/config.py +++ b/protcur/protcur/config.py @@ -1,5 +1,9 @@ from pathlib import Path __script_folder__ = Path(__file__).resolve().parent __units_folder__ = Path(__script_folder__, '../../protc-lib/protc/units') -__units_test_folder__ = Path(__script_folder__, '../../protc-lib/protc/units/test') -__units_test_params__ = Path(__script_folder__, '../../protc-lib/protc/units/test/params.rkt') + +if not __units_folder__.exists(): + __units_folder__ = Path('/usr/share') + +__units_test_folder__ = __units_folder__ / 'test' +__units_test_params__ = __units_test_folder__ / 'params.rkt' diff --git a/protcur/setup.py b/protcur/setup.py index e33e88f..808f833 100644 --- a/protcur/setup.py +++ b/protcur/setup.py @@ -1,4 +1,7 @@ import re +import sys +import shutil +from pathlib import Path from setuptools import setup @@ -16,36 +19,58 @@ def find_version(filename): # TODO pandoc conversion long_description = f.read() + +RELEASE = '--release' in sys.argv +if RELEASE: + sys.argv.remove('--release') + from protcur.config import __units_folder__, __units_test_folder__ + units = [p.name for p in __units_folder__.iterdir() + if p.is_file() and p.name != 'parsing.rkt' and p.suffix == '.rkt'] + units_test = [p.parent.name + '/' + p.name + for p in __units_test_folder__.iterdir() + if p.is_file() and p.suffix == '.rkt'] + shutil.copytree(__units_folder__, 'units') + data_files=[('protcur/units', units), + ('protcur/units/test', units_test)] +else: + data_files = [] + tests_require = ['pytest', 'pytest-runner'] -setup(name='protcur', - version=__version__, - description='A dashboard for web annotation workflows for protocol curation.', - long_description=long_description, - long_description_content_type='text/plain', - url='https://github.com/tgbugs/protc/tree/master/protcur', - author='Tom Gillespie', - author_email='tgbugs@gmail.com', - license='MIT', - classifiers=[], - keywords=('protc protocols dashboard curation ' - 'hypothesis hypothes.is web annotation'), - packages=['protcur'], - python_requires='>=3.6', - install_requires=[ - 'flask', - 'htmlfn', - 'hyputils>=0.0.4', - 'Markdown', - 'pyontutils>=0.1.3', - 'pysercomb', - ], - extras_require={'dev':[], - 'test': tests_require, - }, - entry_points={ - 'console_scripts': [ - 'protcur-server=protcur.server:main', - 'protcur-analysis=protcur.analysis:main', + +try: + setup(name='protcur', + version=__version__, + description='A dashboard for web annotation workflows for protocol curation.', + long_description=long_description, + long_description_content_type='text/plain', + url='https://github.com/tgbugs/protc/tree/master/protcur', + author='Tom Gillespie', + author_email='tgbugs@gmail.com', + license='MIT', + classifiers=[], + keywords=('protc protocols dashboard curation ' + 'hypothesis hypothes.is web annotation'), + packages=['protcur'], + python_requires='>=3.6', + install_requires=[ + 'flask', + 'htmlfn', + 'hyputils>=0.0.4', + 'Markdown', + 'pyontutils>=0.1.3', + 'pysercomb', ], - }, - ) + extras_require={'dev':[], + 'test': tests_require, + }, + entry_points={ + 'console_scripts': [ + 'protcur-server=protcur.server:main', + 'protcur-analysis=protcur.analysis:main', + ], + }, + data_files=data_files, + ) +finally: + if RELEASE: + shutil.rmtree('units')