Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __pycache__
*.swp
dist
*.egg-info
RELEASE-VERSION
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
language: python
python:
- 2.7

- 2.7
sudo: false

install:
- pip install PIL --allow-external PIL --allow-unverified PIL

- pip install PIL --allow-external PIL --allow-unverified PIL
script:
- ./tests/api_tests.py
- "./tests/api_tests.py"
deploy:
provider: pypi
user: Denis.Demidov
password:
secure: W13pXc2pp2A9gBUDz2QW/K3OfDT/cn/iapkW6NMdkwRQ+CL7MWXsY2qayfxs6QPfR5W7838pmMXogLOie70n8Hov5/XIrou+dEz/xh6If2VFG41KUz/tP9cy1yUhDYeADn5I+mr+8Yrh59OkHkaeZH1EFndbsxY4pyXV0DT+FNVg4eLc8sE5ZCfa/itVdsqp8M4xrMe8NO/ldnFEIHFymyEMTZHR5qoJD+Uk+AGMR4cSeSuOrZixnSLpQViZDFHpwej6F1LrreLltbT9ChjSEmdPAr1Jp1ReQfuD+vBzUMkhVfZyEo+fY1x8FZVPrTAEtbJGDhvTAsrV1KTgPqanMyyrCIG+OWfCSYYPyg7MYbAJVfB+P0BRp1cm2D5oFrpAZE129oVtATOykQarFzzRFhH4Tyc04WriyY/greEAe58MqYoJAZXUIe/JLf9+GLdjBKD07+q7QMZvyEEdsDCPYkqKQeuwrWZ/JlpWO5rmy12L23aYzvJqhcKo9LZQOY8LkmFmxuxt7k5eb/3iZ1trhj/lwoLLSu8l29B8cK3dax38URie0x9bMMhQRxaO59JQuhGuu0sNHiuFQHs6wLs/V8ff1IZIlRSlzztqIP3KW514TEdsFIuF0Gpn5wvagAXFbSnyxAUUTy81eQjY/ExTiUHKfU3zjluaAYGt9zjF0Bc=
on:
tags: true
repo: rhempel/ev3dev-lang-python
83 changes: 83 additions & 0 deletions git_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from subprocess import Popen, PIPE
import os, sys

pyver = sys.version_info

#----------------------------------------------------------------------------
# Get version string from git
#
# Author: Douglas Creager <dcreager@dcreager.net>
# http://dcreager.net/2010/02/10/setuptools-git-version-numbers/
#
# PEP 386 adaptation from
# https://gist.github.com/ilogue/2567778/f6661ea2c12c070851b2dfb4da8840a6641914bc
#----------------------------------------------------------------------------
def call_git_describe(abbrev=4):
try:
p = Popen(['git', 'describe', '--abbrev=%d' % abbrev],
stdout=PIPE, stderr=PIPE)
p.stderr.close()
line = p.stdout.readlines()[0]
return line.strip().decode('utf8')

except:
return None


def read_release_version():
try:
f = open("RELEASE-VERSION", "r")

try:
version = f.readlines()[0]
return version.strip()

finally:
f.close()

except:
return None


def write_release_version(version):
f = open("RELEASE-VERSION", "w")
f.write("%s\n" % version)
f.close()


def pep386adapt(version):
# adapt git-describe version to be in line with PEP 386
parts = version.split('-')
if len(parts) > 1:
parts[-2] = 'post'+parts[-2]
version = '.'.join(parts[:-1])
return version


def git_version(abbrev=4):
# Read in the version that's currently in RELEASE-VERSION.
release_version = read_release_version()

# Try to get the current version using "git describe".
version = call_git_describe(abbrev)

# If that doesn't work, fall back on the value that's in
# RELEASE-VERSION.
if version is None:
version = release_version
else:
#adapt to PEP 386 compatible versioning scheme
version = pep386adapt(version)

# If we still don't have anything, that's an error.
if version is None:
raise ValueError("Cannot find the version number!")

# If the current version is different from what's in the
# RELEASE-VERSION file, update the file to be current.
if version != release_version:
write_release_version(version)

# Finally, return the current version.
return version

4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from setuptools import setup
from git_version import git_version


setup(
name='python-ev3dev',
version='0.0.1',
version=git_version(),
description='Python language bindings for ev3dev',
author='Ralph Hempel/Denis Demidov/Anton Vanhoucke',
license='MIT',
Expand Down