import os
import sys
import setuptools
from setuptools import setup
from wheel.bdist_wheel import bdist_wheel
from datetime import datetime
from subprocess import Popen, PIPE
from distutils.util import get_platform
from distutils.core import Extension, Distribution
pyversion = float(sys.version_info[0]) + float(sys.version_info[1]) / 10.0
if pyversion < 3:
str_encode = str
str_decode = str
def pipe_decode(output):
return output
else:
def str_encode(s):
return bytes(s,sys.getdefaultencoding())
def str_decode(bs):
return bs.decode(sys.getdefaultencoding(),"strict")
def pipe_decode(output):
if isinstance(output,bytes) or isinstance(output,bytearray):
return str_decode(output)
elif isinstance(output,tuple):
return (str_decode(output[0]),str_decode(output[1]))
else:
return ("","")
def compute_version( ):
print(os.getcwd())
proc = Popen( [ "../../scripts/version" ], stdout=PIPE, stderr=PIPE )
out,err = pipe_decode(proc.communicate( ))
print(out)
devbranchtag = out.split(" ")[0].strip()
print(devbranchtag)
releasetag = out.split(" ")[1].strip()
dirty=""
if (len(out.split(" ")) == 3):
print("Latest commit doesn't have a tag. Adding -dirty flag to version string.")
dirty="+" + out.split(" ")[2].strip()
print(releasetag)
devbranchversion = ""
devbranchrevision = ""
if (devbranchtag != releasetag):
devbranchrevision = devbranchtag.split("-")[-1]
if (devbranchtag.startswith("CAS-")):
devbranchversion=devbranchtag.split("-")[1]
else:
devbranchversion=100
devbranchrevision = devbranchtag.split("-")[-1]
else:
isDevBranch = False
(major, minor, patch) = releasetag.split(".")
return(int(major), int(minor), int(patch), devbranchversion, devbranchrevision, dirty)
(major, minor, patch, devbranchversion, devbranchrevision, dirty) = compute_version( )
print(major, minor, patch, devbranchversion, devbranchrevision, dirty)
casaviewer_version = '%d.%d.%d%s' % (major,minor,patch,dirty)
if devbranchversion !="":
casaviewer_version = '%d.%d.%da%s.dev%s%s' % (major,minor,patch,devbranchversion,devbranchrevision,dirty)
print(casaviewer_version)
def all_files( dir ):
acc = [ ]
for root, directories, filenames in os.walk(dir):
r = os.path.join(*root.split(os.sep)[1:])
for filename in filenames:
acc.append(os.path.join(r,filename))
return acc
class BinaryDistribution(Distribution):
user_options = bdist_wheel.user_options + [
('build=', None, 'specify build number') ]
def initialize_options(self):
Distribution.initialize_options(self)
self.build=casaviewer_version
"""Distribution which always forces a binary package with platform name"""
def has_ext_modules(foo):
return True
class BdistWheel(bdist_wheel):
user_options = bdist_wheel.user_options + [
('build=', None, 'specify build number') ]