Commit f746a829 authored by Johan Bloemberg's avatar Johan Bloemberg

add version to python package

parent df1b1353
......@@ -22,3 +22,4 @@ code.json
codeclimate.json
static/
.direnv
version
# use full image for build (compile) dependencies
FROM python:3 as build
COPY requirements*.txt /
COPY . /source/
# install app and dependencies in a artifact-able directory
RUN pip install virtualenv
RUN virtualenv /pyenv
# install requirements seperately as they change less often then source, improved caching
COPY requirements*.txt /
RUN /pyenv/bin/pip install -r requirements.txt
RUN /pyenv/bin/pip install -r requirements.deploy.txt
# install the app
COPY . /source/
RUN /pyenv/bin/pip install /source/
# switch to lightweight base image for distribution
FROM python:3-slim
# install dependencies (remove cache to prevent inclusion in layer)
# install dependent libraries (remove cache to prevent inclusion in layer)
RUN apt-get update && \
apt-get install -yqq libxml2 libmysqlclient18 mysql-client postgresql postgresql-contrib mime-support && \
rm -rf /var/lib/apt/lists/*
......
import os
from subprocess import check_output
from setuptools import find_packages, setup
def get_git_version():
def get_version():
"""Determine current version number from nearest git tag."""
# prefer explicit version provided by (docker) build environment
try:
return open('version').read().strip()
except Exception:
pass
# fallback to git tag if building python package
try:
# get closest tag version
version = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode()
develop = bool(check_output(["git", "status", "--porcelain"]).strip())
# determine if there has been development beyond the tagged commit
dirty = bool(check_output(["git", "status", "--porcelain"]).strip())
unpushed = bool(check_output(["git", "rev-list", "origin/master.."]).strip())
develop = dirty or unpushed
if develop:
return version + '.dev'
else:
return version
except:
return '0.0.0'
except Exception:
pass
# fallback
return '0.0.0'
setup(
name='failmap-admin',
version=get_git_version(),
version=get_version(),
packages=find_packages(),
install_requires=open('requirements.txt').readlines(),
entry_points={
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment