mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-25 07:38:54 +02:00
setup.py: take potential "--build-base=<dir>" option into account
For instance, if osc is build and installed like this: python setup.py build --build-base=<dir> ... install ... The patch is based on Roman Neuhauser's (neuhauser@sigpipe.cz) PR (see https://github.com/openSUSE/osc/pull/229).
This commit is contained in:
33
setup.py
33
setup.py
@@ -25,7 +25,7 @@ class build_osc(distutils.command.build.build, object):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
import gzip
|
import gzip
|
||||||
man_path = os.path.join('build', 'osc.1.gz')
|
man_path = os.path.join(self.build_base, 'osc.1.gz')
|
||||||
distutils.log.info('generating %s' % man_path)
|
distutils.log.info('generating %s' % man_path)
|
||||||
outfile = gzip.open(man_path, 'w')
|
outfile = gzip.open(man_path, 'w')
|
||||||
osccli = commandline.Osc(stdout=outfile)
|
osccli = commandline.Osc(stdout=outfile)
|
||||||
@@ -47,10 +47,10 @@ class build_docs(distutils.command.build.Command):
|
|||||||
user_options = []
|
user_options = []
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
pass
|
self.built_docs = None
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
pass
|
self.set_undefined_options('build', ('build_base', 'built_docs'))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# metadata contains information supplied in setup()
|
# metadata contains information supplied in setup()
|
||||||
@@ -61,7 +61,29 @@ class build_docs(distutils.command.build.Command):
|
|||||||
import sphinx
|
import sphinx
|
||||||
sphinx.main(['runme',
|
sphinx.main(['runme',
|
||||||
'-D', 'version=%s' % metadata.get_version(),
|
'-D', 'version=%s' % metadata.get_version(),
|
||||||
os.path.join('docs',), os.path.join('build', 'docs')])
|
os.path.join('docs',), os.path.join(self.built_docs, 'docs')])
|
||||||
|
|
||||||
|
|
||||||
|
# take a potential build-base option into account (for instance, if osc is
|
||||||
|
# build and installed like this:
|
||||||
|
# python setup.py build --build-base=<dir> ... install ...)
|
||||||
|
class install_data(distutils.command.install_data.install_data, object):
|
||||||
|
def initialize_options(self):
|
||||||
|
super(install_data, self).initialize_options()
|
||||||
|
self.built_data = None
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super(install_data, self).finalize_options()
|
||||||
|
self.set_undefined_options('build', ('build_base', 'built_data'))
|
||||||
|
data_files = []
|
||||||
|
for f in self.data_files:
|
||||||
|
# f is either a str or a (dir, files) pair
|
||||||
|
# (see distutils.command.install_data.install_data.run)
|
||||||
|
if isinstance(f, str):
|
||||||
|
data_files.append(os.path.join(self.built_data, f))
|
||||||
|
else:
|
||||||
|
data_files.append((f[0], [os.path.join(self.built_data, i) for i in f[1]]))
|
||||||
|
self.data_files = data_files
|
||||||
|
|
||||||
|
|
||||||
addparams = {}
|
addparams = {}
|
||||||
@@ -72,7 +94,7 @@ if HAVE_PY2EXE:
|
|||||||
|
|
||||||
data_files = []
|
data_files = []
|
||||||
if sys.platform[:3] != 'win':
|
if sys.platform[:3] != 'win':
|
||||||
data_files.append((os.path.join('share', 'man', 'man1'), [os.path.join('build', 'osc.1.gz')]))
|
data_files.append((os.path.join('share', 'man', 'man1'), ['osc.1.gz']))
|
||||||
|
|
||||||
setup(name='osc',
|
setup(name='osc',
|
||||||
version = osc.core.__version__,
|
version = osc.core.__version__,
|
||||||
@@ -93,6 +115,7 @@ setup(name='osc',
|
|||||||
cmdclass = {
|
cmdclass = {
|
||||||
'build': build_osc,
|
'build': build_osc,
|
||||||
'build_docs' : build_docs,
|
'build_docs' : build_docs,
|
||||||
|
'install_data': install_data
|
||||||
},
|
},
|
||||||
**addparams
|
**addparams
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user