From 29f5fa9e0ffdc57550492f3feed7364c660cd0c4 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 22 Apr 2018 17:22:12 -0700 Subject: [PATCH] unfuck the requirements & dockerfile --- examples/docker/Dockerfile | 35 +++++++-------- bin/pyircbot => pyircbot/cli.py | 6 ++- bin/pubsubbot => pyircbot/clipub.py | 5 ++- requirements-test.txt | 66 ++++++++++++----------------- requirements.txt | 36 ++++++---------- setup.py | 7 ++- 6 files changed, 69 insertions(+), 86 deletions(-) rename bin/pyircbot => pyircbot/cli.py (98%) mode change 100755 => 100644 rename bin/pubsubbot => pyircbot/clipub.py (99%) mode change 100755 => 100644 diff --git a/examples/docker/Dockerfile b/examples/docker/Dockerfile index a4584a3..b3add31 100644 --- a/examples/docker/Dockerfile +++ b/examples/docker/Dockerfile @@ -1,26 +1,21 @@ FROM ubuntu:bionic +RUN apt-get update && \ + apt-get install -y python3-pip git && \ + useradd --home-dir /srv/bot bot && \ + mkdir -p /srv/bot && \ + chown bot /srv/bot + +COPY ./requirements.txt /requirements.txt + +RUN pip3 install -r /requirements.txt + + +COPY ./ /tmp/pyircbot +RUN cd /tmp/pyircbot && \ + python3 setup.py install + ENTRYPOINT ["/usr/local/bin/pyircbot"] WORKDIR /srv/bot/ CMD ["-c", "config.json"] -ADD requirements.txt /tmp/requirements.txt - -RUN apt-get update && \ - apt-get install -y python3 python3-setuptools python3-pip sqlite3 git && \ - pip3 install -r /tmp/requirements.txt && \ - useradd --home-dir /srv/bot bot && \ - chown bot /srv/bot && \ - apt-get remove -y python3-pip perl && \ - apt-get autoremove -y && \ - apt-get clean -y && \ - rm -rf /var/lib/apt/lists/* - -COPY . /tmp/pyircbot/ - -RUN cd /tmp/pyircbot/ && \ - python3 setup.py install && \ - su -c "cp -r /tmp/pyircbot/examples/config.json /tmp/pyircbot/examples/data/ /srv/bot/" bot && \ - cd / && \ - rm -rf /tmp/pyircbot - USER bot diff --git a/bin/pyircbot b/pyircbot/cli.py old mode 100755 new mode 100644 similarity index 98% rename from bin/pyircbot rename to pyircbot/cli.py index e789881..05be2e8 --- a/bin/pyircbot +++ b/pyircbot/cli.py @@ -8,7 +8,7 @@ from pyircbot import PyIRCBot from json import loads -if __name__ == "__main__": +def main(): " logging level and facility " logging.basicConfig(level=logging.INFO, format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s") @@ -45,3 +45,7 @@ if __name__ == "__main__": signal.signal(signal.SIGTERM, signal_handler) bot.run() + + +if __name__ == "__main__": + main() diff --git a/bin/pubsubbot b/pyircbot/clipub.py old mode 100755 new mode 100644 similarity index 99% rename from bin/pubsubbot rename to pyircbot/clipub.py index 1af9815..6b634dc --- a/bin/pubsubbot +++ b/pyircbot/clipub.py @@ -112,7 +112,7 @@ class PyIRCBotSub(PrimitiveBot): return self.meta.get("nick", None) -if __name__ == "__main__": +def main(): logging.basicConfig(level=logging.WARNING, format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s") log = logging.getLogger('main') @@ -160,3 +160,6 @@ if __name__ == "__main__": bot.run() + +if __name__ == "__main__": + main() diff --git a/requirements-test.txt b/requirements-test.txt index fc1fad4..376488f 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,47 +1,35 @@ apipkg==1.4 -appdirs==1.4.3 -certifi==2017.4.17 +attrs==17.4.0 +backports.functools-lru-cache==1.5 +certifi==2018.4.16 chardet==3.0.4 -cheroot==5.9.1 -CherryPy==12.0.1 -coverage==4.4.2 -decorator==4.0.11 +cheroot==6.2.4 +CherryPy==14.2.0 +coverage==4.5.1 execnet==1.5.0 -idna==2.5 -ipdb==0.10.3 -ipython==6.0.0 -ipython-genutils==0.2.0 -jaraco.classes==1.4.3 -jedi==0.10.2 -lxml==4.1.1 -mock==2.0.0 --e git+http://gitlab.davepedu.com/dave/pymsgbus.git#egg=msgbus -packaging==16.8 -pbr==3.1.1 -pexpect==4.2.1 -pickleshare==0.7.4 +idna==2.6 +more-itertools==4.1.0 +-e git+http://git.davepedu.com/dave/pymsgbus.git@373a9c5f153078fce57bde43f493785859f51de4#egg=msgbus +pluggy==0.6.0 portend==2.2 -praw==5.0.1 -prawcore==0.11.0 -prompt-toolkit==1.0.14 -ptyprocess==0.5.1 -py==1.5.2 -Pygments==2.2.0 -PyJWT==1.5.3 -pyparsing==2.2.0 -PySocks==1.6.7 -pytest==3.2.5 +praw==5.4.0 +prawcore==0.14.0 +py==1.5.3 +PyJWT==1.6.1 +PyMySQL==0.8.0 +PySocks==1.6.8 +pytest==3.5.0 pytest-cov==2.5.1 +pytest-cover==3.0.0 +pytest-coverage==0.0 pytest-forked==0.2 -pytest-xdist==1.20.1 -pytz==2017.3 -pyzmq==16.0.2 -requests==2.18.1 -simplegeneric==0.8.1 +pytest-xdist==1.22.2 +-e git+https://github.com/jgarzik/python-bitcoinrpc.git@76ced424dc16f997365265487487056e653238c6#egg=python_bitcoinrpc +pytz==2018.4 +pyzmq==17.0.0 +requests==2.18.4 six==1.11.0 -tempora==1.9 -traitlets==4.3.2 -twilio==6.9.0 +tempora==1.11 +twilio==6.12.1 update-checker==0.16 -urllib3==1.21.1 -wcwidth==0.1.7 +urllib3==1.22 diff --git a/requirements.txt b/requirements.txt index 7f1c5eb..25abe4b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,35 +1,23 @@ -alabaster==0.7.10 -Babel==2.5.3 -certifi==2017.11.5 +backports.functools-lru-cache==1.5 +certifi==2018.4.16 chardet==3.0.4 -cheroot==6.0.0 -CherryPy==13.1.0 -docutils==0.14 +cheroot==6.2.4 +CherryPy==14.2.0 idna==2.6 -imagesize==0.7.1 -Jinja2==2.10 -lxml==4.1.1 -MarkupSafe==1.0 -more-itertools==4.0.1 -pyzmq==16.0.3 +more-itertools==4.1.0 -e git+http://git.davepedu.com/dave/pymsgbus.git@373a9c5f153078fce57bde43f493785859f51de4#egg=msgbus portend==2.2 -praw==5.3.0 -prawcore==0.13.0 -Pygments==2.2.0 -PyJWT==1.5.3 +praw==5.4.0 +prawcore==0.14.0 +PyJWT==1.6.1 PyMySQL==0.8.0 PySocks==1.6.8 -e git+https://github.com/jgarzik/python-bitcoinrpc.git@76ced424dc16f997365265487487056e653238c6#egg=python_bitcoinrpc -pytz==2017.3 -releases==1.4.0 +pytz==2018.4 +pyzmq==17.0.0 requests==2.18.4 -semantic-version==2.6.0 six==1.11.0 -snowballstemmer==1.2.1 -Sphinx==1.6.6 -sphinxcontrib-websupport==1.0.1 -tempora==1.10 -twilio==6.9.0 +tempora==1.11 +twilio==6.12.1 update-checker==0.16 urllib3==1.22 diff --git a/setup.py b/setup.py index 8ff4c7d..5b54bb3 100755 --- a/setup.py +++ b/setup.py @@ -10,5 +10,10 @@ setup(name='pyircbot', author='dpedu', author_email='dave@davepedu.com', packages=['pyircbot', 'pyircbot.modules'], - scripts=['bin/pyircbot'], + entry_points={ + "console_scripts": [ + "pyircbot = pyircbot.cli:main", + "pubsubbot = pyircbot.clipub:main" + ] + }, zip_safe=False)