mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-09 22:36:14 +01: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:
parent
2816f325ca
commit
7849e23eb5
33
setup.py
33
setup.py
@ -25,7 +25,7 @@ class build_osc(distutils.command.build.build, object):
|
||||
"""
|
||||
"""
|
||||
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)
|
||||
outfile = gzip.open(man_path, 'w')
|
||||
osccli = commandline.Osc(stdout=outfile)
|
||||
@ -47,10 +47,10 @@ class build_docs(distutils.command.build.Command):
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
self.built_docs = None
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
self.set_undefined_options('build', ('build_base', 'built_docs'))
|
||||
|
||||
def run(self):
|
||||
# metadata contains information supplied in setup()
|
||||
@ -61,7 +61,29 @@ class build_docs(distutils.command.build.Command):
|
||||
import sphinx
|
||||
sphinx.main(['runme',
|
||||
'-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 = {}
|
||||
@ -72,7 +94,7 @@ if HAVE_PY2EXE:
|
||||
|
||||
data_files = []
|
||||
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',
|
||||
version = osc.core.__version__,
|
||||
@ -93,6 +115,7 @@ setup(name='osc',
|
||||
cmdclass = {
|
||||
'build': build_osc,
|
||||
'build_docs' : build_docs,
|
||||
'install_data': install_data
|
||||
},
|
||||
**addparams
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user