Loading project.clj +1 −1 Original line number Diff line number Diff line (defproject python/lein-template "0.1.0" (defproject python/lein-template "0.2.0" :description "lein template for a python project" :url "http://emacsos.com/lein/python" :license {:name "Eclipse Public License" Loading src/leiningen/new/python.clj +22 −9 Original line number Diff line number Diff line Loading @@ -3,7 +3,9 @@ *dir*]] [clojure.java.io :as io] [clojure.java.shell :as shell] [leiningen.core.main :as main])) [leiningen.core.main :as main]) (:import (java.util Calendar) (java.text SimpleDateFormat))) (def render (renderer "python")) Loading @@ -19,22 +21,33 @@ "a standard python project with virtualenv, githooks, pep8, pylint etc" [name] (let [data {:name name :sanitized (name-to-path name)} :sanitized (name-to-path name) :date (let [cal (Calendar/getInstance)] (.format (new SimpleDateFormat "yyyy-MM-dd") (.getTime cal)))} plain-files ["Makefile" "requirements.txt" "setup.py" "README.rst" "utils/bootstrap" "utils/build-deb" "utils/install-git-hooks" "utils/trigger-jenkins-build" "deb-scripts/before-install.sh" "deb-scripts/after-install.sh" "deb-scripts/before-remove.sh" "git-hooks/post-commit" "git-hooks/post-merge" "git-hooks/pre-commit" ".gitignore"] post-run-commands [["chmod" "-R" "+x" "utils" "git-hooks/"]]] empty-files ["{{name}}/__init__.py"] post-run-commands [["chmod" "-R" "+x" "utils/" "git-hooks/" "deb-scripts/"]]] (main/info "Generating new python project:" name) (apply ->files data ["{{name}}/__init__.py" ""] (apply ->files data (map (fn [f] [f ""]) empty-files)) (apply ->files data ["{{name}}/logger.conf" (render "logger.conf" data)] (map (fn [f] [f (render f data)]) plain-files)) (shell/with-sh-dir *dir* (doseq [cmd post-run-commands] Loading src/leiningen/new/python/Makefile +8 −0 Original line number Diff line number Diff line Loading @@ -8,8 +8,14 @@ PYTHON = env PYTHONPATH=$(PYTHONPATH) bin/python default: pylint build: run: $(PYTHON) {{name}}/main.py bootstrap: @./utils/bootstrap install: bootstrap bin/python setup.py -q install deb: utils/build-deb check: test pylint: bootstrap $(PEP8) $(PYTHON_MODULES) Loading @@ -23,6 +29,8 @@ clean: find . -name "*.pyc" -type f -exec rm -rf {} \; full-clean: rm -rf local/ lib/ bin/ include/ build/ dist/ {{name}}.egg-info/ find . -name "__pycache__" -type d -exec rm -rf {} \; find . -name "*.pyc" -type f -exec rm -rf {} \; TAGS: etags -R --exclude=static $(PYTHON_MODULES) update-git-hooks: install-git-hooks-force Loading src/leiningen/new/python/README.rst 0 → 100644 +31 −0 Original line number Diff line number Diff line {{name}} ============================ TODO add brief intro Installation ------------ To install {{name}}, simply: .. code-block:: bash $ pip install {{name}} Quick Start ----------- TODO Documentation ------------- TODO ChangeLog --------- * v0.1.0 {{date}} - initial release src/leiningen/new/python/deb-scripts/after-install.sh 0 → 100644 +15 −0 Original line number Diff line number Diff line #!/bin/sh set -e PREFIX=${PREFIX:-/opt/{{name}}} LOGDIR=${LOGDIR:-/data2/log/{{name}}} RUN_AS_USER=root mkdir -p "$LOGDIR" if [ "$RUN_AS_USER" != root ]; then chown -R "$RUN_AS_USER":"$RUN_AS_USER" "$LOGDIR" fi make -C "$PREFIX" bootstrap install # start {{name}} || true Loading
project.clj +1 −1 Original line number Diff line number Diff line (defproject python/lein-template "0.1.0" (defproject python/lein-template "0.2.0" :description "lein template for a python project" :url "http://emacsos.com/lein/python" :license {:name "Eclipse Public License" Loading
src/leiningen/new/python.clj +22 −9 Original line number Diff line number Diff line Loading @@ -3,7 +3,9 @@ *dir*]] [clojure.java.io :as io] [clojure.java.shell :as shell] [leiningen.core.main :as main])) [leiningen.core.main :as main]) (:import (java.util Calendar) (java.text SimpleDateFormat))) (def render (renderer "python")) Loading @@ -19,22 +21,33 @@ "a standard python project with virtualenv, githooks, pep8, pylint etc" [name] (let [data {:name name :sanitized (name-to-path name)} :sanitized (name-to-path name) :date (let [cal (Calendar/getInstance)] (.format (new SimpleDateFormat "yyyy-MM-dd") (.getTime cal)))} plain-files ["Makefile" "requirements.txt" "setup.py" "README.rst" "utils/bootstrap" "utils/build-deb" "utils/install-git-hooks" "utils/trigger-jenkins-build" "deb-scripts/before-install.sh" "deb-scripts/after-install.sh" "deb-scripts/before-remove.sh" "git-hooks/post-commit" "git-hooks/post-merge" "git-hooks/pre-commit" ".gitignore"] post-run-commands [["chmod" "-R" "+x" "utils" "git-hooks/"]]] empty-files ["{{name}}/__init__.py"] post-run-commands [["chmod" "-R" "+x" "utils/" "git-hooks/" "deb-scripts/"]]] (main/info "Generating new python project:" name) (apply ->files data ["{{name}}/__init__.py" ""] (apply ->files data (map (fn [f] [f ""]) empty-files)) (apply ->files data ["{{name}}/logger.conf" (render "logger.conf" data)] (map (fn [f] [f (render f data)]) plain-files)) (shell/with-sh-dir *dir* (doseq [cmd post-run-commands] Loading
src/leiningen/new/python/Makefile +8 −0 Original line number Diff line number Diff line Loading @@ -8,8 +8,14 @@ PYTHON = env PYTHONPATH=$(PYTHONPATH) bin/python default: pylint build: run: $(PYTHON) {{name}}/main.py bootstrap: @./utils/bootstrap install: bootstrap bin/python setup.py -q install deb: utils/build-deb check: test pylint: bootstrap $(PEP8) $(PYTHON_MODULES) Loading @@ -23,6 +29,8 @@ clean: find . -name "*.pyc" -type f -exec rm -rf {} \; full-clean: rm -rf local/ lib/ bin/ include/ build/ dist/ {{name}}.egg-info/ find . -name "__pycache__" -type d -exec rm -rf {} \; find . -name "*.pyc" -type f -exec rm -rf {} \; TAGS: etags -R --exclude=static $(PYTHON_MODULES) update-git-hooks: install-git-hooks-force Loading
src/leiningen/new/python/README.rst 0 → 100644 +31 −0 Original line number Diff line number Diff line {{name}} ============================ TODO add brief intro Installation ------------ To install {{name}}, simply: .. code-block:: bash $ pip install {{name}} Quick Start ----------- TODO Documentation ------------- TODO ChangeLog --------- * v0.1.0 {{date}} - initial release
src/leiningen/new/python/deb-scripts/after-install.sh 0 → 100644 +15 −0 Original line number Diff line number Diff line #!/bin/sh set -e PREFIX=${PREFIX:-/opt/{{name}}} LOGDIR=${LOGDIR:-/data2/log/{{name}}} RUN_AS_USER=root mkdir -p "$LOGDIR" if [ "$RUN_AS_USER" != root ]; then chown -R "$RUN_AS_USER":"$RUN_AS_USER" "$LOGDIR" fi make -C "$PREFIX" bootstrap install # start {{name}} || true