Commit b96885aa authored by Yuanle Song's avatar Yuanle Song
Browse files

v0.20.3 allow using dash in project name

parent b046dce7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
(defproject python/lein-template "0.20.2"
(defproject python/lein-template "0.20.3"
  :description "lein template for a python project"
  :repositories [["snapshots"
                  {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots"
+8 −2
Original line number Diff line number Diff line
@@ -25,11 +25,17 @@
    (if (not (empty? output))
      (main/info output))))

(defn name-to-python-pkg-name
  "convert project name to python pkg name"
  [name]
  (string/replace name "-" "_"))

(defn python
  "a standard python project with virtualenv, githooks, pep8, pylint etc"
  [name]
  (let [data {:name name
              :sanitized (name-to-path name)
              :python-pkg-name (name-to-python-pkg-name name)
              :date (let [cal (Calendar/getInstance)]
                      (.format (new SimpleDateFormat "yyyy-MM-dd")
                               (.getTime cal)))}
@@ -64,7 +70,7 @@
                     "utils/virtualenv-15.1.0/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl"
                     "utils/virtualenv-15.1.0/virtualenv_support/__init__.py"
                     ]
        empty-files ["{{name}}/__init__.py"]
        empty-files ["{{python-pkg-name}}/__init__.py"]
        package-files ["logger.conf"
                       "configlogger.py"
                       "config.py"
@@ -77,7 +83,7 @@
           (concat
            (map (fn [f] [f ""]) empty-files)
            (map (fn [f] [f (render f data)]) template-files)
            (map (fn [f] [(str "{{name}}/" f) (render f data)]) package-files)
            (map (fn [f] [(str "{{python-pkg-name}}/" f) (render f data)]) package-files)
            (map (fn [f] [f (io/input-stream (get-template-file f))])
                 ;; using input-stream here because the result of rendering
                 ;; binary file is undefined even when data is empty hashmap.
+9 −9
Original line number Diff line number Diff line
PYTHON_MODULES := {{name}}
PYTHON_MODULES := {{python-pkg-name}}
PYTHONPATH := .
VENV := .venv
PYTEST := env PYTHONPATH=$(PYTHONPATH) PYTEST=1 $(VENV)/bin/py.test
@@ -17,11 +17,11 @@ default: check-coding-style
build:

debug:
	env DEBUG=1 $(PYTHON) {{name}}/main.py
	env DEBUG=1 $(PYTHON) {{python-pkg-name}}/main.py
run:
	$(PYTHON) {{name}}/main.py
	$(PYTHON) {{python-pkg-name}}/main.py
uwsgi:
	$(VENV)/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={{python-pkg-name}}/main.py --env=PYTHONPATH=. --http=localhost:8082 --disable-logging
shell:
	$(PYTHON) -i

@@ -44,7 +44,7 @@ bootstrap-dev: venv requirements
install: bootstrap
	$(PYTHON) setup.py -q install
uninstall: bootstrap
	$(PIP) uninstall {{name}}    # TODO not tested.
	$(PIP) uninstall {{python-pkg-name}}    # TODO not tested.
deb:
	utils/build-deb
pipfreeze:
@@ -56,11 +56,11 @@ wheel: bootstrap-dev

check: just-test
sanity-check: bootstrap
	$(PYTHON) {{name}}/sanity_check.py
	$(PYTHON) {{python-pkg-name}}/sanity_check.py
check-coding-style: bootstrap-dev
	$(PEP8) $(PYTHON_MODULES)
	$(PYLINT) -E $(PYTHON_MODULES)
	$(PYTHON) {{name}}/config.py
	$(PYTHON) {{python-pkg-name}}/config.py
pylint-full: check-coding-style
	$(PYLINT) $(PYTHON_MODULES)
test: check-coding-style
@@ -76,7 +76,7 @@ clean:
	find . -name "__pycache__" -type d -exec rm -rf {} \; || true
	find . -name "*.pyc" -type f -exec rm -rf {} \; || true
full-clean:
	rm -rf $(VENV) build/ dist/ wheelhouse/ {{name}}.egg-info/ distribute-*.tar.gz
	rm -rf $(VENV) build/ dist/ wheelhouse/ {{python-pkg-name}}.egg-info/ distribute-*.tar.gz
	find . -name "__pycache__" -type d -exec rm -rf {} \; || true
	find . -name "*.pyc" -type f -exec rm -rf {} \; || true
todo:
@@ -90,5 +90,5 @@ install-git-hooks-force:
	./utils/install-git-hooks -f
loc:
	find . -regex '.*\.pyw?$$' -exec wc -l {} \+ | tail -n 1
	which cloc >/dev/null && cloc {{name}}/
	which cloc >/dev/null && cloc {{python-pkg-name}}/
.PHONY: default build debug run uwsgi shell venv bootstrap bootstrap-dev install uninstall deb pipfreeze wheel check check-coding-style pylint-full test just-test test-prod clean full-clean todo TAGS update-git-hooks install-git-hooks install-git-hooks-force loc
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
socket=127.0.0.1:8082

chdir=/opt/{{name}}
wsgi-file={{name}}/main.py
wsgi-file={{python-pkg-name}}/main.py
env=PYTHONPATH=.

processes=4
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ config variables
from __future__ import (absolute_import, division, print_function,
                        unicode_literals, with_statement)

import {{name}}.configlogger
import {{python-pkg-name}}.configlogger
import logging
import os

Loading