From 1d7188d02f03c9d80dfa122de6f1e7cf3cff71e7 Mon Sep 17 00:00:00 2001 From: Yuki Igarashi Date: Thu, 2 Jan 2020 23:28:42 +0900 Subject: [PATCH] Add PyPI package (#4) * Update README, setup.py * Set long_description_content_type * Update version * Update README * Add badges --- .gitignore | 2 ++ MANIFEST.in | 4 ++++ README.md | 34 ++++++++++++++++++---------------- setup.py | 37 +++++++++++++++++++++---------------- shamiko/__init__.py | 4 ++++ 5 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 MANIFEST.in diff --git a/.gitignore b/.gitignore index b663459..635f409 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ __pycache__ *.pyc .mypy_cache *.egg-info +build/ +dist/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..cb395e6 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README.md +include LICENSE + +recursive-include shamiko *.py py.typed *.template diff --git a/README.md b/README.md index ff62c9c..ce8fe74 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # shamiko +[![PyPI](https://img.shields.io/pypi/v/shamiko.svg)](https://pypi.org/project/shamiko/) +[![PyPI Supported Python Versions](https://img.shields.io/pypi/pyversions/shamiko.svg)](https://pypi.org/project/shamiko/) [![GitHub license](https://img.shields.io/github/license/bonprosoft/shamiko.svg)](https://github.com/bonprosoft/shamiko) shamiko is a library for inspecting running Python processes. @@ -6,8 +8,8 @@ shamiko is a library for inspecting running Python processes. It can - inspect Python processes - obtain information about current frames and threads of the running process -- inject arbitrary code into specified frame and thread -- attach pdb +- inject arbitrary code into specified frame and thread of the process +- attach the running process with pdb ## Install @@ -17,7 +19,7 @@ pip install shamiko ## CLI -shamiko provides the command line interface. +shamiko provides the command-line interface. ```sh shamiko --help @@ -50,7 +52,7 @@ inspect the running process Usage: shamiko PID inspect ``` -![](./imgs/inspect.gif) +![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/inspect.gif) ### attach @@ -60,12 +62,12 @@ attach a debugger to the running process Usage: shamiko PID attach [OPTIONS] Options: - --thread (int): thread id where you can obtain by inspect command - --frame (int): frame id where you can obtain by inspect command + --thread (int): thread id where you can obtain by `inspect` command + --frame (int): frame id where you can obtain by `inspect` command --debugger (str): debugger type. available debuggers: [pdb] ``` -![](./imgs/attach.gif) +![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/attach.gif) ### run-file @@ -75,14 +77,14 @@ inject a python script file into the running process Usage: shamiko PID run-file [OPTIONS] FILE_PATH Arguments: - FILE_PATH (str): a path of python script that you want to inject into given PID + FILE_PATH (str): a path of the python script that you want to inject into given PID Options: - --thread (int): thread id where you can obtain by inspect command - --frame (int): frame id where you can obtain by inspect command + --thread (int): thread id where you can obtain by `inspect` command + --frame (int): frame id where you can obtain by `inspect` command ``` -![](./imgs/runfile.gif) +![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/runfile.gif) ### run-script @@ -95,11 +97,11 @@ Arguments: SCRIPT (str): a python code that you want to inject into given PID Options: - --thread (int): thread id where you can obtain by inspect command - --frame (int): frame id where you can obtain by inspect command + --thread (int): thread id where you can obtain by `inspect` command + --frame (int): frame id where you can obtain by `inspect` command ``` -![](./imgs/runscript.gif) +![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/runscript.gif) ### shell @@ -109,7 +111,7 @@ launch an interactive shell Usage: shamiko PID shell ``` -![](./imgs/shell.gif) +![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/shell.gif) ## FAQ @@ -122,7 +124,7 @@ again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf ptrace: Operation not permitted. ``` -In most distributions, executing ptrace of non-child process by non-super user is disallowed. +In most distributions, executing ptrace of non-child processes by a non-super user is disallowed. You can disable this temporarily by ```sh echo 0 > /proc/sys/kernel/yama/ptrace_scope diff --git a/setup.py b/setup.py index d87f3b5..e7460e9 100644 --- a/setup.py +++ b/setup.py @@ -1,26 +1,31 @@ -from setuptools import setup +from setuptools import find_packages, setup + +__version__ = "0.1.0" setup( name="shamiko", - version="0.0.1", + version=__version__, description="Shamiko ga waruindayo", - long_description="", + long_description=open("README.md").read(), + long_description_content_type="text/markdown", author="Yuki Igarashi", author_email="me@bonprosoft.com", url="https://github.com/bonprosoft/shamiko", license="MIT License", - packages=["shamiko", "shamiko.gdb", "shamiko.simple_rpc"], - package_data={ - "shamiko": [ - "templates/*.template", - ], - }, - install_requires=[ - "psutil>=5.6.7,<6", + packages=find_packages(), + classifiers=[ + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python", + "License :: OSI Approved :: MIT License", ], - entry_points={ - "console_scripts": [ - "shamiko = shamiko.cli:cli", - ], - }, + package_data={"shamiko": ["py.typed", "templates/*.template"]}, + install_requires=["psutil>=5.6.7,<6", "Jinja2>=2.10.3,<3"], + entry_points={"console_scripts": ["shamiko = shamiko.cli:cli"]}, + zip_safe=False, ) diff --git a/shamiko/__init__.py b/shamiko/__init__.py index 504a662..0384b3d 100644 --- a/shamiko/__init__.py +++ b/shamiko/__init__.py @@ -5,6 +5,10 @@ try: import gdb # NOQA except ImportError: + import shutil + if shutil.which("gdb") is None: + raise RuntimeError("gdb command is required") from None + from shamiko.app import Shamiko # NOQA from shamiko.session import Session # NOQA