From a4116832e7a7819358e05eac3bb71d91fe77c6c9 Mon Sep 17 00:00:00 2001 From: Tiara Rodney Date: Fri, 8 Apr 2022 20:49:39 +0200 Subject: [PATCH 1/3] fix(build-toolchain): migrate versioning to setuptools_scm versioning of package now handled through setuptools_scm. Git tag therefore takes precedence and manually setting a version in setup.cfg is redundant. In addition, setuptools_scm handles proper inclusion of sdist non-python files and simplifies bdist packaging. --- .gitignore | 4 +++- MANIFEST.in | 2 -- pyproject.toml | 7 +++++-- setup.cfg | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 MANIFEST.in diff --git a/.gitignore b/.gitignore index 0ec6dc9..e2bd56f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ **/__pycache__/ .DS_Store .coverage -/*.md \ No newline at end of file +/*.md +/.eggs/ +/devel/ \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 75d6607..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include src/httpaste/schema *.json -recursive-incude src/httpaste/backend *.sql diff --git a/pyproject.toml b/pyproject.toml index 9111d02..cb91714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ [build-system] requires = [ "setuptools", - "wheel" + "wheel", + "setuptools-scm[toml]" ] build-backend = "setuptools.build_meta" @@ -9,4 +10,6 @@ build-backend = "setuptools.build_meta" max_line_length = 80 aggressive = 3 recursive = true -in-place = true \ No newline at end of file +in-place = true + +[tool.setuptools_scm] diff --git a/setup.cfg b/setup.cfg index 915d670..465a26b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = httpaste-victorykit -version = 1.0.9-alpha author = Tiara Rodney author_email = t.rodney@victoryk.it description = a versatile HTTP pastebin @@ -38,3 +37,7 @@ console_scripts = [options.packages.find] where = src +[options.package_data] +* = + *.json + *.sql \ No newline at end of file From c8dffbbdf893961a988421bd122089dcae0d1268 Mon Sep 17 00:00:00 2001 From: Tiara Rodney Date: Fri, 8 Apr 2022 21:01:33 +0200 Subject: [PATCH 2/3] refactor(__init__): reset context manager for flask app with proper bdist setup, it shouldn't be necessary to wrap path of importlib, since the context manager will handle egg extraction itself. Hopefully... --- src/httpaste/__init__.py | 3 ++- src/httpaste/helper/common.py | 26 -------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/httpaste/__init__.py b/src/httpaste/__init__.py index 999721b..92c55a5 100755 --- a/src/httpaste/__init__.py +++ b/src/httpaste/__init__.py @@ -144,6 +144,7 @@ from configparser import ConfigParser from ast import literal_eval from io import StringIO from os import environ +from importlib.resources import path as resource_path from connexion import FlaskApp from connexion.resolver import RestyResolver @@ -302,7 +303,7 @@ def get_flask_app( options = {"swagger_ui": server_config.swagger_ui} #context manager returns a pathlib.Path object - with tmp_pkg_resource_text_path('httpaste.schema', 'httpaste.openapi.json') as path: + with resource_path('httpaste.schema', 'httpaste.openapi.json') as path: application = FlaskApp(__name__, specification_dir=path.parent) diff --git a/src/httpaste/helper/common.py b/src/httpaste/helper/common.py index 8edacd1..2e6d1c7 100644 --- a/src/httpaste/helper/common.py +++ b/src/httpaste/helper/common.py @@ -1,7 +1,6 @@ from random import choice from base64 import b64decode from urllib.parse import urljoin -from importlib.resources import read_text from tempfile import mkdtemp from pathlib import Path from contextlib import contextmanager @@ -35,28 +34,3 @@ def decode(data: str, encoding: str) -> bytes: def join_url(base:str, url: str) -> str: return urljoin(base, url, True) - - -@contextmanager -def tmp_pkg_resource_text_path(package:str, resource:str) -> Path: - """context manager for accessing package resources from a real path - - this applies to the circumstance of the package living inside of an - egg and therefore is unable to provide real existing paths to any - module that may require it. - - :param package: dot seperated package name - :param resource: basename of resource inside package - - :returns: a Path-like object - """ - data = read_text(package, resource) - tmp_dirname = mkdtemp() - tmp_dirpath = Path(tmp_dirname) - tmp_file = tmp_dirpath.joinpath(resource) - tmp_file.write_text(data) - try: - yield tmp_file - finally: - tmp_file.unlink() - tmp_dirpath.rmdir() \ No newline at end of file From 2762d6d67ff8a5984178aafd332f0fb1b369815c Mon Sep 17 00:00:00 2001 From: Tiara Rodney Date: Fri, 8 Apr 2022 21:03:35 +0200 Subject: [PATCH 3/3] docs(guide/getting-started): init --- docs/guide/getting-started.rst | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 docs/guide/getting-started.rst diff --git a/docs/guide/getting-started.rst b/docs/guide/getting-started.rst new file mode 100644 index 0000000..431fa2b --- /dev/null +++ b/docs/guide/getting-started.rst @@ -0,0 +1,73 @@ +Getting Started +=============== + +Install +""""""" + +.. code-block:: shell + + $ python3 -m pip install httpaste-victorykit + $ httpaste --help + +.. note:: + httpaste is publicly available at `https://httpaste.it`_, and can be accessed + over the TOR network via `https://pastefao6mwyafs3cznoe2u2a6iizw5laulrznla3dytcnvaizte73yd.onion`_ aswell. Both are hosted on different servers of different service providers. + +Create Configuration +"""""""""""""""""""" + +.. code-block:: shell + + $ httpaste default-config --dump myconfig.ini + +.. note:: + The default configuration creates an in-memory SQLite backend, which is not + suitable for WWW deployments. Visit `backend`, for more + information on configuring the backend. + + +Run a Local Evaluation Server +""""""""""""""""""""""""""""" + +.. code-block:: shell + + $ httpaste standalone --config myconfig.ini --port 8080 + + +Publish a Private Paste +""""""""""""""""""""""" + +.. code-block:: shell + + $ echo 'My first private paste' | curl -F 'data=<-' -u myusername:mypassword http://localhost:8080/paste/private + http://localhost:8080/paste/private/UALUA9 + +.. note:: + If the user does not exist, they will be created upon authentication. + + +Retrieve a Private Paste +"""""""""""""""""""""""" + +.. code-block:: shell + + $ curl -u myusername:mypassword http://localhost:8080/paste/private/UALUA9 + My first private paste + + +Publish a Public Paste +"""""""""""""""""""""" + +.. code-block:: shell + + $ echo 'My first public paste' | curl -F 'data=<-' http://localhost:8080/paste/public + http://localhost:8080/paste/public/X4L39J + + +Retrieve a Public Paste +"""""""""""""""""""""""" + +.. code-block:: shell + + $ curl http://localhost:8080/paste/public/X4L39J + My first public paste \ No newline at end of file