From a81d99251080d753c315295c6d18afc471150c3c Mon Sep 17 00:00:00 2001 From: michaelhaaf Date: Mon, 14 Mar 2022 17:11:05 -0400 Subject: [PATCH 1/3] migrate from scripts= to entry_point= in setup.py for noarch support --- bin/__init__.py | 0 bin/pgdb | 0 setup.py | 7 +++++-- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 bin/__init__.py mode change 100644 => 100755 bin/pgdb diff --git a/bin/__init__.py b/bin/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/bin/pgdb b/bin/pgdb old mode 100644 new mode 100755 diff --git a/setup.py b/setup.py index 7a7ba6e8..2a32a9f2 100755 --- a/setup.py +++ b/setup.py @@ -63,7 +63,8 @@ def get_version(rel_path): url='https://github.com/MontrealCorpusTools/PolyglotDB', author='Montreal Corpus Tools', author_email='michael.e.mcauliffe@gmail.com', - packages=['polyglotdb', + packages=['bin', + 'polyglotdb', 'polyglotdb.acoustics', 'polyglotdb.acoustics.formants', 'polyglotdb.acoustics.pitch', @@ -99,7 +100,9 @@ def get_version(rel_path): 'tqdm', 'requests' ], - scripts=['bin/pgdb'], + entry_point={ + 'console_scripts': ['pgdb = bin.pgdb:main'] + }, cmdclass={'test': PyTest}, extras_require={ 'testing': ['pytest'], From ece969a66febcfb7ed8b711da216be583383527d Mon Sep 17 00:00:00 2001 From: michaelhaaf Date: Wed, 23 Mar 2022 17:07:29 -0400 Subject: [PATCH 2/3] [in progress] migrate to modern python building protocol --- pyproject.toml | 3 ++ setup.cfg | 46 ++++++++++++++++++++++++ setup.py | 98 +++----------------------------------------------- 3 files changed, 54 insertions(+), 93 deletions(-) create mode 100644 pyproject.toml create mode 100644 setup.cfg 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..5859df93 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[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: +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 = bin.pgdb:main + +[options.extras_require] +test = + pytest diff --git a/setup.py b/setup.py index 2a32a9f2..5aced21c 100755 --- a/setup.py +++ b/setup.py @@ -1,31 +1,5 @@ -import sys -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: - return fp.read() +#!/usr/bin/env python +import setuptools def get_version(rel_path): @@ -43,68 +17,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=['bin', - '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' - ], - entry_point={ - 'console_scripts': ['pgdb = bin.pgdb:main'] - }, - cmdclass={'test': PyTest}, - extras_require={ - 'testing': ['pytest'], - } - ) +if __name__ == "__main__": + setuptools.setup(version=get_version("polyglotdb/__init__.py")) + From 26e3e264b581279aa5b3180b8a177f3aa6002b76 Mon Sep 17 00:00:00 2001 From: michaelhaaf Date: Wed, 18 May 2022 14:16:12 -0400 Subject: [PATCH 3/3] (in progress) moving to modern python setup.py --- polyglotdb/__init__.py | 12 +++++++++++- {bin => polyglotdb/command_line}/pgdb | 6 +++++- setup.cfg | 8 ++++++-- setup.py | 8 ++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) rename {bin => polyglotdb/command_line}/pgdb (99%) 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 similarity index 99% rename from bin/pgdb rename to polyglotdb/command_line/pgdb index 0ff50ffe..cb8ff003 100755 --- 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/setup.cfg b/setup.cfg index 5859df93..a9787480 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,6 +25,7 @@ project_urls = [options] packages = find: +zip_safe = True include_package_data = True install_requires = neo4j-driver >=4.3 @@ -38,9 +39,12 @@ install_requires = python_requires = >=3.6 [options.entry_points] -console_scripts = - pgdb = bin.pgdb:main +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 5aced21c..414b1edd 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,13 @@ #!/usr/bin/env python import setuptools +import os +import codecs + + +def read(rel_path): + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, rel_path), 'r') as fp: + return fp.read() def get_version(rel_path):