diff --git a/bin/__init__.py b/bin/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/polyglotdb/__init__.py b/polyglotdb/__init__.py index 3d2d7a5a..2b6fea03 100755 --- a/polyglotdb/__init__.py +++ b/polyglotdb/__init__.py @@ -3,7 +3,17 @@ __ver_patch__ = 1 __version__ = f"{__ver_major__}.{__ver_minor__}.{__ver_patch__}" -__all__ = ['query', 'io', 'corpus', 'config', 'exceptions', 'CorpusContext', 'CorpusConfig'] +__all__ = ['query', 'io', 'corpus', 'config', 'exceptions', 'CorpusContext', 'CorpusConfig', 'pgdb'] + +# Inspired by: https://stackoverflow.com/a/43602645 +import sys +from importlib.util import spec_from_loader, module_from_spec +from importlib.machinery import SourceFileLoader + +spec = spec_from_loader("pgdb", SourceFileLoader("pgdb", "polyglotdb/command_line/pgdb")) +pgdb = module_from_spec(spec) +spec.loader.exec_module(pgdb) +sys.modules['pgdb'] = pgdb import polyglotdb.query.annotations as graph diff --git a/bin/pgdb b/polyglotdb/command_line/pgdb old mode 100644 new mode 100755 similarity index 99% rename from bin/pgdb rename to polyglotdb/command_line/pgdb index 0ff50ffe..cb8ff003 --- a/bin/pgdb +++ b/polyglotdb/command_line/pgdb @@ -242,7 +242,7 @@ def status(name): pass -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(help='Command to use') install_parser = subparsers.add_parser("install") @@ -311,3 +311,7 @@ if __name__ == '__main__': if CONFIG_CHANGED: save_config(CONFIG) + + +if __name__ == '__main__': + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9787c3bd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..a9787480 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,50 @@ +[metadata] +name = polyglotdb +description = '' +long_description = file: README.md +long_description_content_type = text/markdown +license = MIT +license_file = LICENSE +keywords='phonology corpus phonetics', +url='https://github.com/MontrealCorpusTools/PolyglotDB', +author='Montreal Corpus Tools', +author_email='michael.e.mcauliffe@gmail.com', +classifiers = + Development Status :: 3 - Alpha + Programming Language :: Python + Programming Language :: Python :: 3 + Intended Audience :: Science/Research + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Topic :: Scientific/Engineering + Topic :: Text Processing :: Linguistic +project_urls = + Documentation = 'http://polyglotdb.readthedocs.io/en/latest/' + Source = 'https://github.com/MontrealCorpusTools/PolyglotDB' + Tracker = 'https://github.com/MontrealCorpusTools/PolyglotDB/issues' + +[options] +packages = find: +zip_safe = True +include_package_data = True +install_requires = + neo4j-driver >=4.3 + praatio >=5.0 + textgrid + conch_sounds + librosa + influxdb + tqdm + requests +python_requires = >=3.6 + +[options.entry_points] +console_scripts = + pgdb = polyglotdb.command_line.pgdb:main + +[options.extras_require] +test = + pytest + +[options.package_data] +polyglotdb.command_line = pgdb diff --git a/setup.py b/setup.py index 7a7ba6e8..414b1edd 100755 --- a/setup.py +++ b/setup.py @@ -1,27 +1,9 @@ -import sys +#!/usr/bin/env python +import setuptools import os -from setuptools import setup -from setuptools.command.test import test as TestCommand import codecs -def readme(): - with open('README.md') as f: - return f.read() - - -class PyTest(TestCommand): - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = ['--strict', '--verbose', '--tb=long', 'tests', '-x'] - self.test_suite = True - - def run_tests(self): - if __name__ == '__main__': # Fix for multiprocessing infinite recursion on Windows - import pytest - errcode = pytest.main(self.test_args) - sys.exit(errcode) - def read(rel_path): here = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.join(here, rel_path), 'r') as fp: @@ -43,65 +25,6 @@ def get_version(rel_path): return "{}.{}.{}".format(major_version, minor_version, patch_version) -if __name__ == '__main__': - setup(name='polyglotdb', - version=get_version("polyglotdb/__init__.py"), - description='', - long_description=readme(), - long_description_content_type='text/markdown', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Topic :: Scientific/Engineering', - 'Topic :: Text Processing :: Linguistic', - ], - keywords='phonology corpus phonetics', - url='https://github.com/MontrealCorpusTools/PolyglotDB', - author='Montreal Corpus Tools', - author_email='michael.e.mcauliffe@gmail.com', - packages=['polyglotdb', - 'polyglotdb.acoustics', - 'polyglotdb.acoustics.formants', - 'polyglotdb.acoustics.pitch', - 'polyglotdb.acoustics.vot', - 'polyglotdb.client', - 'polyglotdb.corpus', - 'polyglotdb.databases', - 'polyglotdb.io', - 'polyglotdb.io.types', - 'polyglotdb.io.parsers', - 'polyglotdb.io.inspect', - 'polyglotdb.io.exporters', - 'polyglotdb.io.importer', - 'polyglotdb.io.enrichment', - 'polyglotdb.query', - 'polyglotdb.query.base', - 'polyglotdb.query.annotations', - 'polyglotdb.query.annotations.attributes', - 'polyglotdb.query.discourse', - 'polyglotdb.query.speaker', - 'polyglotdb.query.lexicon', - 'polyglotdb.query.metadata', - 'polyglotdb.syllabification'], - package_data={'polyglotdb.databases': ['*.conf'], - 'polyglotdb.acoustics.formants': ['*.praat']}, - install_requires=[ - 'neo4j-driver~=4.3', - 'praatio~=5.0', - 'textgrid', - 'conch_sounds', - 'librosa', - 'influxdb', - 'tqdm', - 'requests' - ], - scripts=['bin/pgdb'], - cmdclass={'test': PyTest}, - extras_require={ - 'testing': ['pytest'], - } - ) +if __name__ == "__main__": + setuptools.setup(version=get_version("polyglotdb/__init__.py")) +