Commit 97d3160b authored by Yuanle Song's avatar Yuanle Song
Browse files

v1.0.0 added <pkg>.__version__ in __init__.py

let Makefile, setup.py, fabfile use version from that file.
parent 16cb5c0f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
(defproject python/lein-template "0.20.5"
(defproject python/lein-template "1.0.0"
  :description "lein template for a python project"
  :repositories [["snapshots"
                  {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots"
+6 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
                        "requirements-dev.txt"
                        "setup.py"
                        "README.rst"
                        "utils/versionutils.py"
                        "utils/build-deb"
                        "utils/install-git-hooks"
                        "utils/trigger-jenkins-build"
@@ -62,7 +63,8 @@
                        "git-hooks/post-merge"
                        "git-hooks/pre-commit"
                        ".gitignore"]
        plain-files ["utils/choose_default_python.py"
        plain-files ["utils/__init__.py"
                     "utils/choose_default_python.py"
                     "utils/virtualenv-15.1.0/virtualenv.py"
                     "utils/virtualenv-15.1.0/virtualenv_support/argparse-1.4.0-py2.py3-none-any.whl"
                     "utils/virtualenv-15.1.0/virtualenv_support/setuptools-28.8.0-py2.py3-none-any.whl"
@@ -70,8 +72,9 @@
                     "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 ["{{python-pkg-name}}/__init__.py"]
        package-files ["logger.conf"
        empty-files []
        package-files ["__init__.py"
                       "logger.conf"
                       "configlogger.py"
                       "config.py"
                       "sanity_check.py"
+4 −0
Original line number Diff line number Diff line
@@ -13,9 +13,13 @@ VIRTUALENV := ./utils/virtualenv-15.1.0/virtualenv.py
REQUIREMENTS := -r requirements.txt
DEV_REQUIREMENTS := -r requirements-dev.txt

VERSION := $(shell grep '__version__' {{python-pkg-name}}/__init__.py |cut -d'"' -f 2)

default: check-coding-style
build:

version:
	@echo $(VERSION)
debug:
	env DEBUG=1 $(PYTHON) {{python-pkg-name}}/main.py
run:
+1 −0
Original line number Diff line number Diff line
__version__ = "0.1.0"
+3 −14
Original line number Diff line number Diff line
@@ -9,26 +9,15 @@ fabric file for server automation.
import os.path
from fabric.api import env, sudo, run, local, hosts, put, cd

from utils.versionutils import get_version_from_init_file

env.use_ssh_config = True
PROD_HOST = 'de01'


def get_version_from_setup_file():
    """parse version info from setup.py file.

    Return the version string.

    """
    with open("setup.py", "r") as f:
        for line in f:
            if "version=" in line:
                return line.split("=")[1][1:-3]
    raise Exception("version not found in setup.py")


@hosts(PROD_HOST)
def deploy():
    version = get_version_from_setup_file()
    version = get_version_from_init_file()
    deb_file = "{{name}}_%s_amd64.deb" % (version,)
    if not os.path.exists(deb_file):
        local("make deb")
Loading