Loading README.md +5 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,11 @@ Features: To create a new python project, run lein new python foo mkdir foo cd foo lein new python foo --to-dir . TODO make it work when outside the project root dir as well. Dependencies for the generated python project: Loading operational +85 −2 Original line number Diff line number Diff line * COMMENT -*- mode: org -*- #+Date: 2014-05-09 Time-stamp: <2014-05-09> Time-stamp: <2016-06-30> #+STARTUP: content * done :entry: * current :entry: ** ** 2016-06-30 make "lein new python bar" work, without --to-dir . ** 2016-06-30 update it for use with default debian config. (non-yy env) - update nginx config file - add support for systemd - create /data if it doesn't exist. auto use sudo to create the dir if it doesn't exist. make sure it works on fresh system. use a VM to test it. ** 2016-06-30 put venv in .venv dir. - DONE update Makefile - DONE update ./utils/bootstrap use a variable in template. no. move bootstrap inside Makefile. I will create it from scratch. Just use the old files. a recent copy of Makefile is at find /home/sylecn/python/ -name Makefile -mtime -7 find /home/sylecn/projects/ -name Makefile -mtime -30 /home/sylecn/projects/molecules/pbsa_jisuan/Makefile /home/sylecn/projects/qvm/Makefile /home/sylecn/projects/spider/src/python-prototyping/Makefile locater '\.venv$' DONE /home/sylecn/office/yxy/emeter-elavator-reports/.venv // also this. /home/sylecn/projects/webframework-simple-benchmark/.venv DONE /home/sylecn/python/questionsdb/.venv // also this. DONE /home/sylecn/websites/url-alias/.venv // this is the one I'm looking for. - bootstrap. can I use late binding variable to make bootstrap and bootstrap-dev work? Can I just set a variable and invoke make a 2nd time on a shared target that uses that variable? well, just define a function in Makefile, pass in parameters. - INFO function is a very confusing concept in Makefile. the call function https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_8.html#SEC81 This macro simply reverses its arguments: reverse = $(2) $(1) // and where is macro documented, it also looks like a function. Defining Canned Command Sequences https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_5.html#SEC55 - DONE can "python3 -m venv" replace virtualenv? no. it can only create venv for the python that is being run. just use the embedded virtualenv. - DONE use python3 in venv by default. - make old code work with python3. - add future imports from __future__ import (absolute_import, division, print_function, unicode_literals) - pylint fails. - DONE fallback to python2 if python3 is NA. - DONE upgrade virtualenv and pip. virtualenv 15.0.2, pip 8.1.2 included. https://pypi.python.org/pypi/virtualenv curl -O https://pypi.python.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz#md5=0ed59863994daf1292827ffdbba80a63 1.8M tar.gz file. old dir: 1.7M new dir: 2.1M removed some files, down to 1.9M. - test it now. v0.7.0 updated virtualenv, use Makefile do bootstrap, use python3 by default. - it requires me listing all template and plain files. this is bad. should just generate the file list on the fly. ** 2014-05-09 add sphinx support * later :entry: project.clj +1 −1 Original line number Diff line number Diff line (defproject python/lein-template "0.6.3" (defproject python/lein-template "0.7.0" :description "lein template for a python project" :repositories [["snapshots" {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots" Loading src/leiningen/new/python.clj +8 −8 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ "requirements-dev.txt" "setup.py" "README.rst" "utils/bootstrap" "utils/build-deb" "utils/install-git-hooks" "utils/trigger-jenkins-build" Loading @@ -54,19 +53,20 @@ "git-hooks/post-merge" "git-hooks/pre-commit" ".gitignore"] plain-files ["utils/pip-offline/argparse-1.2.1.tar.gz" "utils/pip-offline/wheel-0.15.0.tar.gz" "utils/virtualenv-1.9.1/virtualenv.py" "utils/virtualenv-1.9.1/virtualenv_support/distribute-0.6.34.tar.gz" "utils/virtualenv-1.9.1/virtualenv_support/__init__.py" "utils/virtualenv-1.9.1/virtualenv_support/pip-1.5.6.tar.gz" plain-files ["utils/choose_default_python.py" "utils/virtualenv-15.0.2/virtualenv.py" "utils/virtualenv-15.0.2/virtualenv_support/argparse-1.4.0-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/setuptools-21.2.1-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/wheel-0.29.0-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/__init__.py" ] empty-files ["{{name}}/__init__.py"] package-files ["logger.conf" "configlogger.py" "config.py"] post-run-commands ["chmod -R +x utils/ git-hooks/ deb-scripts/" "find utils/pip-offline/ -type f -exec chmod -x {} +"]] ]] (main/info "Generating new python project:" name) (apply ->files data (concat Loading src/leiningen/new/python/Makefile +40 −20 Original line number Diff line number Diff line PYTHON_MODULES = {{name}} PYTHONPATH = . PYTEST = env PYTHONPATH=$(PYTHONPATH) PYTEST=1 bin/py.test PYLINT = env PYTHONPATH=$(PYTHONPATH) bin/pylint --disable=I0011 --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" PEP8 = env PYTHONPATH=$(PYTHONPATH) bin/pep8 --repeat --ignore=E202,E501 PYTHON = env PYTHONPATH=$(PYTHONPATH) bin/python PYTHON_MODULES := {{name}} PYTHONPATH := . VENV := .venv PYTEST := env PYTHONPATH=$(PYTHONPATH) PYTEST=1 $(VENV)/bin/py.test PYLINT := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pylint --disable=I0011 --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" PEP8 := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pep8 --repeat --ignore=E202,E501 PYTHON := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/python PIP := $(VENV)/bin/pip default: pylint DEFAULT_PYTHON := $(shell ./utils/choose_default_python.py) VIRTUALENV := ./utils/virtualenv-15.0.2/virtualenv.py REQUIREMENTS := -r requirements.txt default: check-coding-style build: run: $(PYTHON) {{name}}/main.py uwsgi: bin/uwsgi --processes=2 --threads=4 --wsgi-file={{name}}/main.py --env=PYTHONPATH=. --http=localhost:8082 --disable-logging $(VENV)/bin/uwsgi --processes=2 --threads=4 --wsgi-file={{name}}/main.py --env=PYTHONPATH=. --http=localhost:8082 --disable-logging shell: $(PYTHON) -i bootstrap: @./utils/bootstrap bootstrap-dev: @./utils/bootstrap dev venv: test -d $(VENV) || $(DEFAULT_PYTHON) $(VIRTUALENV) -q $(VENV) requirements: @if [ -d wheelhouse ]; then \ $(PIP) install -q --no-index --find-links=wheelhouse $(REQUIREMENTS); \ else \ $(PIP) install -q --find-links=wheelhouse $(REQUIREMENTS); \ fi bootstrap: venv requirements bootstrap-dev: REQUIREMENTS += -r requirements-dev.txt bootstrap-dev: venv requirements install: bootstrap bin/python setup.py -q install $(PYTHON) setup.py -q install uninstall: bootstrap $(PIP) uninstall {{name}} # TODO not tested. deb: utils/build-deb wheel: bootstrap-dev @echo "building wheelhouse..." bin/pip install --use-wheel wheel bin/pip wheel -f http://apt.yygamedev.com/python/ -r requirements.txt $(PIP) install wheel $(PIP) wheel -f https://emacsos.com/python/packages/ $(REQUIREMENTS) check: test pylint: bootstrap-dev check-coding-style: bootstrap-dev $(PEP8) $(PYTHON_MODULES) $(PYLINT) -E $(PYTHON_MODULES) $(PYTHON) {{name}}/config.py pylint-full: pylint pylint-full: check-coding-style $(PYLINT) $(PYTHON_MODULES) test: pylint test: check-coding-style $(PYTEST) $(PYTHON_MODULES) clean: find . -name "__pycache__" -type d -exec rm -rf {} \; || true find . -name "*.pyc" -type f -exec rm -rf {} \; || true full-clean: rm -rf local/ lib/ bin/ include/ build/ dist/ wheelhouse/ {{name}}.egg-info/ distribute-*.tar.gz rm -rf $(VENV) build/ dist/ wheelhouse/ {{name}}.egg-info/ distribute-*.tar.gz find . -name "__pycache__" -type d -exec rm -rf {} \; || true find . -name "*.pyc" -type f -exec rm -rf {} \; || true TAGS: Loading @@ -51,4 +70,5 @@ install-git-hooks-force: ./utils/install-git-hooks -f loc: find . -regex '.*\.pyw?$$' -exec wc -l {} \+ | tail -n 1 .PHONY: default build bootstrap check pylint pylint-full test clean full-clean TAGS loc install uninstall all update wheel which cloc >/dev/null && cloc {{name}}/ .PHONY: default build run uwsgi shell venv bootstrap bootstrap-dev install uninstall deb wheel check check-coding-style pylint-full test clean full-clean TAGS update-git-hooks install-git-hooks install-git-hooks-force loc Loading
README.md +5 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,11 @@ Features: To create a new python project, run lein new python foo mkdir foo cd foo lein new python foo --to-dir . TODO make it work when outside the project root dir as well. Dependencies for the generated python project: Loading
operational +85 −2 Original line number Diff line number Diff line * COMMENT -*- mode: org -*- #+Date: 2014-05-09 Time-stamp: <2014-05-09> Time-stamp: <2016-06-30> #+STARTUP: content * done :entry: * current :entry: ** ** 2016-06-30 make "lein new python bar" work, without --to-dir . ** 2016-06-30 update it for use with default debian config. (non-yy env) - update nginx config file - add support for systemd - create /data if it doesn't exist. auto use sudo to create the dir if it doesn't exist. make sure it works on fresh system. use a VM to test it. ** 2016-06-30 put venv in .venv dir. - DONE update Makefile - DONE update ./utils/bootstrap use a variable in template. no. move bootstrap inside Makefile. I will create it from scratch. Just use the old files. a recent copy of Makefile is at find /home/sylecn/python/ -name Makefile -mtime -7 find /home/sylecn/projects/ -name Makefile -mtime -30 /home/sylecn/projects/molecules/pbsa_jisuan/Makefile /home/sylecn/projects/qvm/Makefile /home/sylecn/projects/spider/src/python-prototyping/Makefile locater '\.venv$' DONE /home/sylecn/office/yxy/emeter-elavator-reports/.venv // also this. /home/sylecn/projects/webframework-simple-benchmark/.venv DONE /home/sylecn/python/questionsdb/.venv // also this. DONE /home/sylecn/websites/url-alias/.venv // this is the one I'm looking for. - bootstrap. can I use late binding variable to make bootstrap and bootstrap-dev work? Can I just set a variable and invoke make a 2nd time on a shared target that uses that variable? well, just define a function in Makefile, pass in parameters. - INFO function is a very confusing concept in Makefile. the call function https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_8.html#SEC81 This macro simply reverses its arguments: reverse = $(2) $(1) // and where is macro documented, it also looks like a function. Defining Canned Command Sequences https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_5.html#SEC55 - DONE can "python3 -m venv" replace virtualenv? no. it can only create venv for the python that is being run. just use the embedded virtualenv. - DONE use python3 in venv by default. - make old code work with python3. - add future imports from __future__ import (absolute_import, division, print_function, unicode_literals) - pylint fails. - DONE fallback to python2 if python3 is NA. - DONE upgrade virtualenv and pip. virtualenv 15.0.2, pip 8.1.2 included. https://pypi.python.org/pypi/virtualenv curl -O https://pypi.python.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz#md5=0ed59863994daf1292827ffdbba80a63 1.8M tar.gz file. old dir: 1.7M new dir: 2.1M removed some files, down to 1.9M. - test it now. v0.7.0 updated virtualenv, use Makefile do bootstrap, use python3 by default. - it requires me listing all template and plain files. this is bad. should just generate the file list on the fly. ** 2014-05-09 add sphinx support * later :entry:
project.clj +1 −1 Original line number Diff line number Diff line (defproject python/lein-template "0.6.3" (defproject python/lein-template "0.7.0" :description "lein template for a python project" :repositories [["snapshots" {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots" Loading
src/leiningen/new/python.clj +8 −8 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ "requirements-dev.txt" "setup.py" "README.rst" "utils/bootstrap" "utils/build-deb" "utils/install-git-hooks" "utils/trigger-jenkins-build" Loading @@ -54,19 +53,20 @@ "git-hooks/post-merge" "git-hooks/pre-commit" ".gitignore"] plain-files ["utils/pip-offline/argparse-1.2.1.tar.gz" "utils/pip-offline/wheel-0.15.0.tar.gz" "utils/virtualenv-1.9.1/virtualenv.py" "utils/virtualenv-1.9.1/virtualenv_support/distribute-0.6.34.tar.gz" "utils/virtualenv-1.9.1/virtualenv_support/__init__.py" "utils/virtualenv-1.9.1/virtualenv_support/pip-1.5.6.tar.gz" plain-files ["utils/choose_default_python.py" "utils/virtualenv-15.0.2/virtualenv.py" "utils/virtualenv-15.0.2/virtualenv_support/argparse-1.4.0-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/setuptools-21.2.1-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/wheel-0.29.0-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl" "utils/virtualenv-15.0.2/virtualenv_support/__init__.py" ] empty-files ["{{name}}/__init__.py"] package-files ["logger.conf" "configlogger.py" "config.py"] post-run-commands ["chmod -R +x utils/ git-hooks/ deb-scripts/" "find utils/pip-offline/ -type f -exec chmod -x {} +"]] ]] (main/info "Generating new python project:" name) (apply ->files data (concat Loading
src/leiningen/new/python/Makefile +40 −20 Original line number Diff line number Diff line PYTHON_MODULES = {{name}} PYTHONPATH = . PYTEST = env PYTHONPATH=$(PYTHONPATH) PYTEST=1 bin/py.test PYLINT = env PYTHONPATH=$(PYTHONPATH) bin/pylint --disable=I0011 --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" PEP8 = env PYTHONPATH=$(PYTHONPATH) bin/pep8 --repeat --ignore=E202,E501 PYTHON = env PYTHONPATH=$(PYTHONPATH) bin/python PYTHON_MODULES := {{name}} PYTHONPATH := . VENV := .venv PYTEST := env PYTHONPATH=$(PYTHONPATH) PYTEST=1 $(VENV)/bin/py.test PYLINT := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pylint --disable=I0011 --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" PEP8 := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pep8 --repeat --ignore=E202,E501 PYTHON := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/python PIP := $(VENV)/bin/pip default: pylint DEFAULT_PYTHON := $(shell ./utils/choose_default_python.py) VIRTUALENV := ./utils/virtualenv-15.0.2/virtualenv.py REQUIREMENTS := -r requirements.txt default: check-coding-style build: run: $(PYTHON) {{name}}/main.py uwsgi: bin/uwsgi --processes=2 --threads=4 --wsgi-file={{name}}/main.py --env=PYTHONPATH=. --http=localhost:8082 --disable-logging $(VENV)/bin/uwsgi --processes=2 --threads=4 --wsgi-file={{name}}/main.py --env=PYTHONPATH=. --http=localhost:8082 --disable-logging shell: $(PYTHON) -i bootstrap: @./utils/bootstrap bootstrap-dev: @./utils/bootstrap dev venv: test -d $(VENV) || $(DEFAULT_PYTHON) $(VIRTUALENV) -q $(VENV) requirements: @if [ -d wheelhouse ]; then \ $(PIP) install -q --no-index --find-links=wheelhouse $(REQUIREMENTS); \ else \ $(PIP) install -q --find-links=wheelhouse $(REQUIREMENTS); \ fi bootstrap: venv requirements bootstrap-dev: REQUIREMENTS += -r requirements-dev.txt bootstrap-dev: venv requirements install: bootstrap bin/python setup.py -q install $(PYTHON) setup.py -q install uninstall: bootstrap $(PIP) uninstall {{name}} # TODO not tested. deb: utils/build-deb wheel: bootstrap-dev @echo "building wheelhouse..." bin/pip install --use-wheel wheel bin/pip wheel -f http://apt.yygamedev.com/python/ -r requirements.txt $(PIP) install wheel $(PIP) wheel -f https://emacsos.com/python/packages/ $(REQUIREMENTS) check: test pylint: bootstrap-dev check-coding-style: bootstrap-dev $(PEP8) $(PYTHON_MODULES) $(PYLINT) -E $(PYTHON_MODULES) $(PYTHON) {{name}}/config.py pylint-full: pylint pylint-full: check-coding-style $(PYLINT) $(PYTHON_MODULES) test: pylint test: check-coding-style $(PYTEST) $(PYTHON_MODULES) clean: find . -name "__pycache__" -type d -exec rm -rf {} \; || true find . -name "*.pyc" -type f -exec rm -rf {} \; || true full-clean: rm -rf local/ lib/ bin/ include/ build/ dist/ wheelhouse/ {{name}}.egg-info/ distribute-*.tar.gz rm -rf $(VENV) build/ dist/ wheelhouse/ {{name}}.egg-info/ distribute-*.tar.gz find . -name "__pycache__" -type d -exec rm -rf {} \; || true find . -name "*.pyc" -type f -exec rm -rf {} \; || true TAGS: Loading @@ -51,4 +70,5 @@ install-git-hooks-force: ./utils/install-git-hooks -f loc: find . -regex '.*\.pyw?$$' -exec wc -l {} \+ | tail -n 1 .PHONY: default build bootstrap check pylint pylint-full test clean full-clean TAGS loc install uninstall all update wheel which cloc >/dev/null && cloc {{name}}/ .PHONY: default build run uwsgi shell venv bootstrap bootstrap-dev install uninstall deb wheel check check-coding-style pylint-full test clean full-clean TAGS update-git-hooks install-git-hooks install-git-hooks-force loc