2020-09-19 23:28:30 +02:00
|
|
|
#!/usr/bin/env python3
|
2006-05-10 16:21:51 +02:00
|
|
|
|
|
|
|
from distutils.core import setup
|
2016-09-16 16:09:59 +02:00
|
|
|
import distutils.core
|
2018-12-13 13:15:31 +01:00
|
|
|
from distutils.command import build, install_data
|
2020-02-13 14:41:15 +01:00
|
|
|
import gzip
|
2009-05-06 13:47:53 +02:00
|
|
|
import os.path
|
2018-12-13 13:15:31 +01:00
|
|
|
|
|
|
|
import setuptools
|
|
|
|
|
2020-02-13 14:41:15 +01:00
|
|
|
import osc.core
|
2009-05-06 13:47:53 +02:00
|
|
|
from osc import commandline
|
2020-02-13 14:41:15 +01:00
|
|
|
|
2011-07-08 16:09:44 +02:00
|
|
|
|
2018-12-13 13:15:31 +01:00
|
|
|
class build_osc(build.build, object):
|
2009-05-06 13:47:53 +02:00
|
|
|
"""
|
|
|
|
Custom build command which generates man page.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def build_man_page(self):
|
|
|
|
"""
|
|
|
|
"""
|
2016-09-16 16:04:25 +02:00
|
|
|
man_path = os.path.join(self.build_base, 'osc.1.gz')
|
2009-05-06 13:47:53 +02:00
|
|
|
distutils.log.info('generating %s' % man_path)
|
2018-12-13 13:15:31 +01:00
|
|
|
outfile = gzip.open(man_path, 'wt')
|
2011-07-08 16:09:44 +02:00
|
|
|
osccli = commandline.Osc(stdout=outfile)
|
|
|
|
# FIXME: we cannot call the main method because osc expects an ~/.oscrc
|
|
|
|
# file (this would break builds in environments like the obs)
|
2020-02-13 14:41:15 +01:00
|
|
|
# osccli.main(argv = ['osc','man'])
|
2009-05-10 12:42:36 +02:00
|
|
|
osccli.optparser = osccli.get_optparser()
|
2010-12-22 13:29:52 +01:00
|
|
|
osccli.do_man(None)
|
2009-05-09 16:16:18 +02:00
|
|
|
outfile.close()
|
2009-05-06 13:47:53 +02:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
super(build_osc, self).run()
|
2009-05-10 12:42:36 +02:00
|
|
|
self.build_man_page()
|
2006-05-10 16:21:51 +02:00
|
|
|
|
2016-02-15 23:31:02 +01:00
|
|
|
|
|
|
|
# Support for documentation (sphinx)
|
2016-09-16 16:09:59 +02:00
|
|
|
class build_docs(distutils.core.Command):
|
2016-02-15 23:31:02 +01:00
|
|
|
description = 'builds documentation using sphinx'
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
2016-09-16 16:04:25 +02:00
|
|
|
self.built_docs = None
|
2016-02-15 23:31:02 +01:00
|
|
|
|
|
|
|
def finalize_options(self):
|
2016-09-16 16:04:25 +02:00
|
|
|
self.set_undefined_options('build', ('build_base', 'built_docs'))
|
2016-02-15 23:31:02 +01:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
# metadata contains information supplied in setup()
|
|
|
|
metadata = self.distribution.metadata
|
|
|
|
# package_dir may be None, in that case use the current directory.
|
|
|
|
src_dir = (self.distribution.package_dir or {'': ''})['']
|
2020-02-13 14:41:15 +01:00
|
|
|
src_dir = os.path.join(os.getcwd(), src_dir)
|
2016-02-15 23:31:02 +01:00
|
|
|
import sphinx
|
2018-12-13 13:15:31 +01:00
|
|
|
sphinx.main(['runme',
|
2020-02-13 14:41:15 +01:00
|
|
|
'-D', 'version=%s' % metadata.get_version(),
|
|
|
|
os.path.join('docs', ), os.path.join(self.built_docs, 'docs')])
|
2016-09-16 16:04:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
# 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 ...)
|
2018-12-13 13:15:31 +01:00
|
|
|
class install_data(install_data.install_data, object):
|
2016-09-16 16:04:25 +02:00
|
|
|
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
|
2016-02-15 23:31:02 +01:00
|
|
|
|
|
|
|
|
2009-05-14 17:49:54 +02:00
|
|
|
data_files = []
|
2022-01-26 15:06:24 +01:00
|
|
|
data_files.append((os.path.join('share', 'man', 'man1'), ['osc.1.gz']))
|
2009-05-14 17:49:54 +02:00
|
|
|
|
2020-02-13 14:41:15 +01:00
|
|
|
with open("README") as fh:
|
|
|
|
long_description = fh.read()
|
|
|
|
|
|
|
|
setuptools.setup(
|
|
|
|
name='osc',
|
|
|
|
version=osc.core.__version__,
|
|
|
|
description='openSUSE commander',
|
|
|
|
long_description=long_description,
|
|
|
|
long_description_content_type="text/plain",
|
|
|
|
author='openSUSE project',
|
|
|
|
author_email='opensuse-buildservice@opensuse.org',
|
2022-01-26 15:03:23 +01:00
|
|
|
license='GPLv2+',
|
2022-01-26 15:06:24 +01:00
|
|
|
platforms=['Linux', 'MacOS X', 'FreeBSD'],
|
2020-02-13 14:41:15 +01:00
|
|
|
keywords=['openSUSE', 'SUSE', 'RPM', 'build', 'buildservice'],
|
|
|
|
url='http://en.opensuse.org/openSUSE:OSC',
|
|
|
|
download_url='https://github.com/openSUSE/osc',
|
|
|
|
packages=['osc', 'osc.util'],
|
|
|
|
scripts=['osc-wrapper.py'],
|
|
|
|
data_files=data_files,
|
|
|
|
install_requires=['M2Crypto', 'chardet'],
|
|
|
|
classifiers=[
|
|
|
|
"Development Status :: 5 - Production/Stable",
|
|
|
|
"Environment :: Console",
|
|
|
|
"Intended Audience :: Developers",
|
|
|
|
"Intended Audience :: Information Technology",
|
|
|
|
"Intended Audience :: System Administrators",
|
|
|
|
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
|
2022-01-26 15:06:24 +01:00
|
|
|
"Operating System :: MacOS :: MacOS X",
|
|
|
|
"Operating System :: POSIX :: BSD :: FreeBSD",
|
|
|
|
"Operating System :: POSIX :: Linux",
|
2020-02-13 14:41:15 +01:00
|
|
|
"Programming Language :: Python",
|
|
|
|
"Programming Language :: Python :: 2.7",
|
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
"Programming Language :: Python :: 3.5",
|
|
|
|
"Programming Language :: Python :: 3.6",
|
|
|
|
"Programming Language :: Python :: 3.7",
|
|
|
|
"Programming Language :: Python :: 3.8",
|
|
|
|
"Programming Language :: Python :: 3.9",
|
2022-01-26 15:04:24 +01:00
|
|
|
"Programming Language :: Python :: 3.10",
|
|
|
|
"Programming Language :: Python :: 3.11",
|
2020-02-13 14:41:15 +01:00
|
|
|
"Topic :: Software Development :: Build Tools",
|
|
|
|
"Topic :: System :: Archiving :: Packaging",
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
# Override certain command classes with our own ones
|
|
|
|
cmdclass={
|
2009-05-06 13:47:53 +02:00
|
|
|
'build': build_osc,
|
2020-02-13 14:41:15 +01:00
|
|
|
'build_docs': build_docs,
|
2016-09-16 16:04:25 +02:00
|
|
|
'install_data': install_data
|
2020-02-13 14:41:15 +01:00
|
|
|
},
|
|
|
|
)
|