- generally saner/cleaner logger initialization In particular now it doesn't override logging level specified by the user code prior to instantiating the logger. Also remove the `LazyLogger` hack, doesn't seem like it's necessary when the above is implemented. - get rid of `logzero` which is archived and abandoned now, use `colorlog` for coloured logging formatter - allow configuring log level via shell via `LOGGING_LEVEL_module_name=<level>` E.g. `LOGGING_LEVEL_rescuexport_dal=WARNING LOGGING_LEVEL_my_rescuetime=debug ./script.py` - port `AddExceptionTraceback` from HPI/promnesia - port `CollapseLogsHandler` from HPI/promnesia Also allow configuring from the shell, e.g. `LOGGING_COLLAPSE=<level>` - add support for `enlighten` progress bar, so it can be shared between different projects See https://github.com/Rockhopper-Technologies/enlighten#readme This allows nice CLI progressbars, e.g. for parallel processing of different files from HPI: ghexport.dal[111] 29%|████████████████████████████████████████████████████████████████▏ | 29/100 [00:03<00:07, 10.03 files/s] rexport.dal[comments] 17%|████████████████████████████████████▋ | 115/682 [00:03<00:14, 39.15 files/s] my.instagram.android 0%|▎ | 3/2631 [00:02<34:50, 1.26 files/s] Currently off by default, and hidden behind an env variable (`ENLIGHTEN_ENABLE=true`)
88 lines
2.9 KiB
Python
88 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
# see https://github.com/karlicoss/pymplate for up-to-date reference
|
|
|
|
from setuptools import setup, find_namespace_packages # type: ignore
|
|
|
|
INSTALL_REQUIRES = [
|
|
'pytz', # even though it's not needed by the core, it's so common anyway...
|
|
'appdirs', # very common, and makes it portable
|
|
'more-itertools', # it's just too useful and very common anyway
|
|
'decorator' , # less pain in writing correct decorators. very mature and stable, so worth keeping in core
|
|
'click>=8.0' , # for the CLI, printing colors, decorator-based - may allow extensions to CLI
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
pkg = 'my'
|
|
subpackages = find_namespace_packages('.', include=('my.*',))
|
|
setup(
|
|
name='HPI', # NOTE: 'my' is taken for PyPi already, and makes discovering the project impossible. so we're using HPI
|
|
use_scm_version={
|
|
# todo eh? not sure if I should just rely on proper tag naming and use use_scm_version=True
|
|
# 'version_scheme': 'python-simplified-semver',
|
|
'local_scheme': 'dirty-tag',
|
|
},
|
|
setup_requires=['setuptools_scm'],
|
|
|
|
zip_safe=False,
|
|
|
|
# eh. find_packages doesn't find anything
|
|
# find_namespace_packages can't find single file packages (like my/common.py)
|
|
packages=[pkg, *subpackages],
|
|
package_data={
|
|
pkg: [
|
|
# for mypy
|
|
'py.typed',
|
|
],
|
|
},
|
|
|
|
|
|
url='https://github.com/karlicoss/HPI',
|
|
author='Dmitrii Gerasimov',
|
|
author_email='karlicoss@gmail.com',
|
|
description='A Python interface to my life',
|
|
|
|
python_requires='>=3.8',
|
|
install_requires=INSTALL_REQUIRES,
|
|
extras_require={
|
|
'testing': [
|
|
'pytest',
|
|
'mypy',
|
|
'lxml', # for mypy coverage
|
|
|
|
# used in some tests.. although shouldn't rely on it
|
|
'pandas',
|
|
],
|
|
'optional': [
|
|
# todo document these?
|
|
'orjson', # for my.core.serialize
|
|
'pyfzf_iter', # for my.core.denylist
|
|
'cachew>=0.8.0',
|
|
'mypy', # used for config checks
|
|
'colorlog', # for colored logs
|
|
'enlighten', # for CLI progress bars
|
|
],
|
|
},
|
|
entry_points={'console_scripts': ['hpi=my.core.__main__:main']},
|
|
)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import argparse
|
|
p = argparse.ArgumentParser()
|
|
p.add_argument('--dependencies-only', action='store_true')
|
|
args, _ = p.parse_known_args()
|
|
if args.dependencies_only:
|
|
cmd = ['pip3', 'install', '--user', *INSTALL_REQUIRES]
|
|
scmd = ' '.join(cmd)
|
|
import os
|
|
xx = input(f'Run {scmd} [y/n] ')
|
|
if xx.strip() == 'y':
|
|
os.execvp(
|
|
'pip3',
|
|
cmd
|
|
)
|
|
else:
|
|
main()
|
|
|
|
# TODO assert??? diff -bur my/ ~/.local/lib/python3.8/site-packages/my/
|