Moved generation of pkg_info from setup.py to qmake/make - version.pri refactored suitably. Reimplemented sdist_clean as a new setuptools command
This commit is contained in:
parent
8f51e6f07a
commit
3b4b5a19b9
4
binding/binding.pro
Normal file
4
binding/binding.pro
Normal file
@ -0,0 +1,4 @@
|
||||
TEMPLATE = lib
|
||||
CONFIG += pkg_info
|
||||
|
||||
include(../version.pri)
|
@ -17,42 +17,43 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
from setuptools import setup
|
||||
from setuptools import Command, setup
|
||||
from setuptools.command.sdist import sdist as _sdist
|
||||
|
||||
def read(fname):
|
||||
return open(fname).read()
|
||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||
|
||||
def get_pkg_info():
|
||||
info = {}
|
||||
t = open('../server/version.cpp').read()
|
||||
info['version'] = re.search('version = "([^"]*)"', t).group(1)
|
||||
info['revision'] = re.search('revision = "([^"]*)"', t).group(1)
|
||||
return info
|
||||
|
||||
# ------- script starts from here ------- #
|
||||
|
||||
if len(sys.argv) >= 2 and sys.argv[1] == 'clean_sdist':
|
||||
shutil.rmtree('dist', ignore_errors = True)
|
||||
shutil.rmtree('ostinato.egg-info', ignore_errors = True)
|
||||
if os.path.exists('pkg_info.json'):
|
||||
os.remove('pkg_info.json')
|
||||
sys.exit(0)
|
||||
|
||||
if len(sys.argv) >= 2 and sys.argv[1] == 'sdist':
|
||||
def ensure_cwd():
|
||||
if os.path.split(os.getcwd())[1] != 'binding':
|
||||
print 'This script needs to be run from the binding directory'
|
||||
print 'ERROR: This script needs to be run from the binding directory'
|
||||
print 'Current Working Directory is %s' % os.getcwd()
|
||||
sys.exit(1)
|
||||
|
||||
pkg_info = get_pkg_info()
|
||||
with open('pkg_info.json', 'wt') as f:
|
||||
json.dump(pkg_info, f, indent=4)
|
||||
else:
|
||||
with open('pkg_info.json') as f:
|
||||
pkg_info = json.load(f)
|
||||
class sdist(_sdist):
|
||||
def run(self):
|
||||
ensure_cwd()
|
||||
_sdist.run(self)
|
||||
|
||||
class sdist_clean(Command):
|
||||
description = 'clean stuff generated by sdist'
|
||||
user_options = []
|
||||
def initialize_options(self):
|
||||
return
|
||||
|
||||
def finalize_options(self):
|
||||
return
|
||||
|
||||
def run(self):
|
||||
ensure_cwd()
|
||||
shutil.rmtree('dist', ignore_errors = True)
|
||||
shutil.rmtree('ostinato.egg-info', ignore_errors = True)
|
||||
|
||||
# ------- script starts from here ------- #
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), 'pkg_info.json')) as f:
|
||||
pkg_info = json.load(f)
|
||||
|
||||
setup(name = 'ostinato',
|
||||
version = pkg_info['version'],
|
||||
@ -72,6 +73,9 @@ setup(name = 'ostinato',
|
||||
'Intended Audience :: Telecommunications Industry',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||
'Topic :: Software Development :: Testing :: Traffic Generation',
|
||||
'Topic :: System :: Networking']
|
||||
'Topic :: System :: Networking'],
|
||||
cmdclass={
|
||||
'sdist': sdist,
|
||||
'sdist_clean': sdist_clean},
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += qt
|
||||
CONFIG += qt ver_info
|
||||
macx: TARGET = Ostinato
|
||||
win32:RC_FILE = ostinato.rc
|
||||
macx:ICON = icons/logo.icns
|
||||
|
4
ost.pro
4
ost.pro
@ -6,4 +6,6 @@ SUBDIRS = \
|
||||
common/ostproto.pro \
|
||||
common/ostprotogui.pro \
|
||||
server/drone.pro \
|
||||
client/ostinato.pro
|
||||
client/ostinato.pro \
|
||||
binding/binding.pro
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += qt
|
||||
CONFIG += qt ver_info
|
||||
QT += network script
|
||||
QT -= gui
|
||||
DEFINES += HAVE_REMOTE WPCAP
|
||||
|
51
version.pri
51
version.pri
@ -2,18 +2,41 @@ APP_VERSION = 0.5.1
|
||||
APP_REVISION = $(shell hg identify -i)
|
||||
#uncomment the below line in a source package and fill-in the correct revision
|
||||
#APP_REVISION = <rev-hash>@
|
||||
APP_VERSION_FILE = version.cpp
|
||||
revtarget.target = $$APP_VERSION_FILE
|
||||
win32:revtarget.commands = echo "const char *version = \"$$APP_VERSION\";" \
|
||||
"const char *revision = \"$$APP_REVISION\";" \
|
||||
> $$APP_VERSION_FILE
|
||||
unix:revtarget.commands = echo \
|
||||
"\"const char *version = \\\"$$APP_VERSION\\\";" \
|
||||
"const char *revision = \\\"$$APP_REVISION\\\";\"" \
|
||||
> $$APP_VERSION_FILE
|
||||
revtarget.depends = $$SOURCES $$HEADERS $$FORMS $$POST_TARGETDEPS
|
||||
|
||||
SOURCES += $$APP_VERSION_FILE
|
||||
QMAKE_EXTRA_TARGETS += revtarget
|
||||
POST_TARGETDEPS += $$APP_VERSION_FILE
|
||||
QMAKE_DISTCLEAN += $$APP_VERSION_FILE
|
||||
ver_info {
|
||||
APP_VERSION_FILE = version.cpp
|
||||
revtarget.target = $$APP_VERSION_FILE
|
||||
win32:revtarget.commands = echo "const char *version = \"$$APP_VERSION\";" \
|
||||
"const char *revision = \"$$APP_REVISION\";" \
|
||||
> $$APP_VERSION_FILE
|
||||
unix:revtarget.commands = echo \
|
||||
"\"const char *version = \\\"$$APP_VERSION\\\";" \
|
||||
"const char *revision = \\\"$$APP_REVISION\\\";\"" \
|
||||
> $$APP_VERSION_FILE
|
||||
revtarget.depends = $$SOURCES $$HEADERS $$FORMS $$POST_TARGETDEPS
|
||||
|
||||
SOURCES += $$APP_VERSION_FILE
|
||||
QMAKE_EXTRA_TARGETS += revtarget
|
||||
POST_TARGETDEPS += $$APP_VERSION_FILE
|
||||
QMAKE_DISTCLEAN += $$APP_VERSION_FILE
|
||||
}
|
||||
|
||||
pkg_info {
|
||||
PKG_INFO_FILE = pkg_info.json
|
||||
pkginfo.target = $$PKG_INFO_FILE
|
||||
pkginfo.CONFIG = recursive
|
||||
win32:pkginfo.commands = echo "{" \
|
||||
" \"version\": \"$$APP_VERSION\"," \
|
||||
" \"revision\": \"$$APP_REVISION\"" \
|
||||
"}" \
|
||||
> $$PKG_INFO_FILE
|
||||
unix:pkginfo.commands = echo "\"{" \
|
||||
" \\\"version\\\": \\\"$$APP_VERSION\\\"," \
|
||||
" \\\"revision\\\": \\\"$$APP_REVISION\\\"" \
|
||||
"}\"" \
|
||||
> $$PKG_INFO_FILE
|
||||
|
||||
QMAKE_EXTRA_TARGETS += pkginfo
|
||||
POST_TARGETDEPS += $$PKG_INFO_FILE
|
||||
QMAKE_DISTCLEAN += $$PKG_INFO_FILE
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user