From d8e3d62f291e827b6042e710cec40b9f613283c5 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Sun, 8 Dec 2019 12:47:39 +0100 Subject: [PATCH] More cleanup and more helper --- MANIFEST.in | 1 - Makefile | 40 +++++++++++++++++++++------------------- dpaste/settings/base.py | 2 +- dpaste/views.py | 4 +--- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 03844d5..779381b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ include README.rst include LICENSE include CHANGELOG.rst include runtests.py -include tox.ini exclude dpaste/settings/local.py recursive-include dpaste/templates * recursive-include dpaste/static * diff --git a/Makefile b/Makefile index 95e986d..e94106e 100644 --- a/Makefile +++ b/Makefile @@ -10,23 +10,24 @@ define N # newline endef -# The Djangos ------------------------------------------------------------------ - -.PHONY: start -start: ## Start the webserver and migrate db if necessary - docker-compose run --rm app ./manage.py migrate - docker-compose up - .PHONY: test test: ## Run Django tests docker-compose run --rm app pytest dpaste/ .PHONY: code-cleanup code-cleanup: ## Black and isort the Python codebase + autoflake --remove-all-unused-imports --ignore-init-module-imports --remove-unused-variables \ + --exclude "**/migrations/*,dpaste/settings/local.py" -r dpaste isort -rc dpaste black --line-length=80 --exclude='/(migrations)/' dpaste -# The Frontendos (run inside of a docker container) ---------------------------- +.PHONY: docs +docs: ## Compile the documentation + docker-compose run --rm app sphinx-build docs docs/_build/html + +.PHONY: watch-docs +docs-watch: ## Compile the documentation and watch for changes + docker-compose run --rm app sphinx-autobuild docs docs/_build/html .PHONY: css css: ## Compile SCSS files @@ -34,22 +35,12 @@ css: ## Compile SCSS files .PHONY: css-watch css-watch: ## Compile JS files - npx sassz --watch client/scss/dpaste.scss:build/dpaste.css + npx sass --watch client/scss/dpaste.scss:build/dpaste.css .PHONY: js js: ## Compile JS files npx uglifyjs --compress="drop_console=true,ecma=6" --mangle="toplevel" --output=dpaste/static/dpaste.js client/js/dpaste.js -# Helper ----------------------------------------------------------------------- - -.PHONY: docs -docs: ## Compile the documentation - sphinx-build docs docs/_build/html - -.PHONY: watch-docs -docs-watch: ## Compile the documentation and watch for changes - sphinx-autobuild docs docs/_build/html - .PHONY: release-docker release-docker: set -ex @@ -57,6 +48,17 @@ release-docker: docker build --build-arg BUILD_EXTRAS=production -t barttc/dpaste:latest . @echo -e "\n\n💫 All fine. Now do: docker push barttc/dpaste:latest" +.PHONY: release-pypi +release-pypi: + set -ex + docker-compose run --rm app pytest dpaste/ + rm -rf ./node_modules + npm ci + make css + make js + python setup.py sdist && python setup.py bdist_wheel --universal + @echo -e "\n\n💫 All fine. Now do: twine upload dist/* --sign" + .PHONY: help help: @echo -e "Available make commands:" diff --git a/dpaste/settings/base.py b/dpaste/settings/base.py index f822a2a..7fd7881 100644 --- a/dpaste/settings/base.py +++ b/dpaste/settings/base.py @@ -101,7 +101,7 @@ DATABASES = { # If this project installation was built with production settings, # add that webserver right away. try: - import django_webserver + import django_webserver # noqa INSTALLED_APPS.append("django_webserver") sys.stdout.write( diff --git a/dpaste/views.py b/dpaste/views.py index 53098c7..c9af647 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -204,9 +204,7 @@ class SnippetRawView(SnippetDetailView): def render_to_response(self, context, **response_kwargs): if config.RAW_MODE_PLAIN_TEXT: return self.render_plain_text(config, **response_kwargs) - return super().render_to_response( - context, **response_kwargs - ) + return super().render_to_response(context, **response_kwargs) def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs)