install python package with setuptools

This commit is contained in:
Wojtek Porczyk 2015-09-28 17:44:59 +02:00
parent ce60915fb0
commit 6f4951d08a
7 changed files with 94 additions and 159 deletions

View File

@ -44,7 +44,7 @@ clean:
make -C qmemman clean
all:
make all -C qubes
python setup.py build
# make all -C tests
# Currently supported only on xen
ifeq ($(BACKEND_VMM),xen)
@ -58,8 +58,7 @@ ifeq ($(OS),Linux)
$(MAKE) install -C linux/aux-tools
$(MAKE) install -C linux/system-config
endif
$(MAKE) install -C qvm-tools
$(MAKE) install -C qubes
python setup.py install -O1 --skip-build --root $(DESTDIR)
# $(MAKE) install -C tests
$(MAKE) install -C relaxng
ifeq ($(BACKEND_VMM),xen)

View File

@ -1,83 +0,0 @@
OS ?= Linux
PYTHON_QUBESPATH = $(PYTHON_SITEPATH)/qubes
SETTINGS_SUFFIX = $(BACKEND_VMM)-$(OS)
all:
python -m compileall .
python -O -m compileall .
install:
ifndef PYTHON_SITEPATH
$(error PYTHON_SITEPATH not defined)
endif
mkdir -p $(DESTDIR)$(PYTHON_QUBESPATH)
mkdir \
$(DESTDIR)$(PYTHON_QUBESPATH)/vm \
$(DESTDIR)$(PYTHON_QUBESPATH)/storage \
$(DESTDIR)$(PYTHON_QUBESPATH)/tools \
$(DESTDIR)$(PYTHON_QUBESPATH)/ext \
$(DESTDIR)$(PYTHON_QUBESPATH)/tests \
$(DESTDIR)$(PYTHON_QUBESPATH)/tests/vm \
$(DESTDIR)$(PYTHON_QUBESPATH)/tests/tools
cp \
__init__.py* \
_pluginloader.py* \
config.py* \
dochelpers.py* \
events.py* \
log.py* \
plugins.py* \
rngdoc.py* \
utils.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)
cp \
vm/__init__.py* \
vm/adminvm.py* \
vm/appvm.py* \
vm/dispvm.py* \
vm/hvm.py* \
vm/netvm.py* \
vm/proxyvm.py* \
vm/qubesvm.py* \
vm/templatehvm.py* \
vm/templatevm.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)/vm
cp \
storage/__init__.py* \
storage/xen.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)/storage
cp \
tools/__init__.py* \
tools/qubes_create.py* \
tools/qvm_create.py* \
tools/qvm_ls.py* \
tools/qvm_prefs.py* \
tools/qvm_start.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)/tools
cp ext/__init__.py* $(DESTDIR)$(PYTHON_QUBESPATH)/ext
cp \
tests/__init__.py* \
tests/events.py* \
tests/init.py* \
tests/run.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)/tests
cp \
tests/vm/__init__.py* \
tests/vm/init.py* \
tests/vm/adminvm.py* \
tests/vm/qubesvm.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)/tests/vm
cp \
tests/tools/__init__.py* \
tests/tools/init.py* \
tests/tools/qvm_ls.py* \
$(DESTDIR)$(PYTHON_QUBESPATH)/tests/tools

View File

@ -1,5 +0,0 @@
# This is mock file, not installed. It is needed. because pylint needs to
# import all the modules, and qubes.qbd is one of them.
def QubesDB(dummy):
return None

View File

@ -42,7 +42,6 @@ import libvirt
import qubes
import qubes.config
import qubes.qdb
#import qubes.qmemman
#import qubes.qmemman_algo
import qubes.storage
@ -339,6 +338,7 @@ class QubesVM(qubes.vm.BaseVM):
'''QubesDB handle for this domain.'''
if self._qdb_connection is None:
if self.is_running():
import qubes.qdb
self._qdb_connection = qubes.qdb.QubesDB(self.name)
return self._qdb_connection

View File

@ -1,14 +0,0 @@
BINDIR ?= /usr/bin
ifeq ($(OS),Windows_NT)
PYTHONEXEEXT = .py
endif
all:
true
install:
mkdir -p $(DESTDIR)$(BINDIR)
for f in qvm-* qubes-*; do \
cp $$f $(DESTDIR)$(BINDIR)/$$f$(PYTHONEXEEXT); \
done

View File

@ -23,7 +23,7 @@
#
#
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
#%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(False)")}
%{!?version: %define version %(cat version)}
@ -53,6 +53,7 @@ Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires: python, pciutils, python-inotify, python-daemon
Requires: python-setuptools
Requires: qubes-core-dom0-linux >= 2.0.24
Requires: qubes-db-dom0
Requires: python-lxml
@ -75,6 +76,7 @@ Requires: PyQt4
# for property's docstrings
Requires: python-docutils
# Prevent preupgrade from installation (it pretend to provide distribution upgrade)
Obsoletes: preupgrade < 2.0
Provides: preupgrade = 2.0
@ -99,7 +101,7 @@ make all
make install \
DESTDIR=$RPM_BUILD_ROOT \
UNITDIR=%{_unitdir} \
PYTHON_SITEPATH=%{python_sitearch} \
PYTHON_SITEPATH=%{python_sitelib} \
SYSCONFDIR=%{_sysconfdir}
%post
@ -187,67 +189,70 @@ fi
/usr/bin/qvm-*
/usr/bin/qubes-*
%dir %{python_sitearch}/qubes
%{python_sitearch}/qubes/__init__.py*
%{python_sitearch}/qubes/_pluginloader.py*
%{python_sitearch}/qubes/config.py*
%{python_sitearch}/qubes/dochelpers.py*
%{python_sitearch}/qubes/events.py*
%{python_sitearch}/qubes/log.py*
%{python_sitearch}/qubes/plugins.py*
%{python_sitearch}/qubes/rngdoc.py*
%{python_sitearch}/qubes/utils.py*
%dir %{python_sitelib}/qubes-*.egg-info
%{python_sitelib}/qubes-*.egg-info/*
%dir %{python_sitearch}/qubes/vm
%{python_sitearch}/qubes/vm/__init__.py*
%{python_sitearch}/qubes/vm/adminvm.py*
%{python_sitearch}/qubes/vm/appvm.py*
%{python_sitearch}/qubes/vm/dispvm.py*
%{python_sitearch}/qubes/vm/hvm.py*
%{python_sitearch}/qubes/vm/netvm.py*
%{python_sitearch}/qubes/vm/proxyvm.py*
%{python_sitearch}/qubes/vm/qubesvm.py*
%{python_sitearch}/qubes/vm/templatehvm.py*
%{python_sitearch}/qubes/vm/templatevm.py*
%dir %{python_sitelib}/qubes
%{python_sitelib}/qubes/__init__.py*
%{python_sitelib}/qubes/_pluginloader.py*
%{python_sitelib}/qubes/config.py*
%{python_sitelib}/qubes/dochelpers.py*
%{python_sitelib}/qubes/events.py*
%{python_sitelib}/qubes/log.py*
%{python_sitelib}/qubes/plugins.py*
%{python_sitelib}/qubes/rngdoc.py*
%{python_sitelib}/qubes/utils.py*
%dir %{python_sitearch}/qubes/storage
%{python_sitearch}/qubes/storage/__init__.py*
%{python_sitearch}/qubes/storage/xen.py*
%dir %{python_sitelib}/qubes/vm
%{python_sitelib}/qubes/vm/__init__.py*
%{python_sitelib}/qubes/vm/adminvm.py*
%{python_sitelib}/qubes/vm/appvm.py*
%{python_sitelib}/qubes/vm/dispvm.py*
%{python_sitelib}/qubes/vm/hvm.py*
%{python_sitelib}/qubes/vm/netvm.py*
%{python_sitelib}/qubes/vm/proxyvm.py*
%{python_sitelib}/qubes/vm/qubesvm.py*
%{python_sitelib}/qubes/vm/templatehvm.py*
%{python_sitelib}/qubes/vm/templatevm.py*
%dir %{python_sitearch}/qubes/tools
%{python_sitearch}/qubes/tools/__init__.py*
%{python_sitearch}/qubes/tools/qubes_create.py*
%{python_sitearch}/qubes/tools/qvm_create.py*
%{python_sitearch}/qubes/tools/qvm_ls.py*
%{python_sitearch}/qubes/tools/qvm_prefs.py*
%{python_sitearch}/qubes/tools/qvm_start.py*
%dir %{python_sitelib}/qubes/storage
%{python_sitelib}/qubes/storage/__init__.py*
%{python_sitelib}/qubes/storage/xen.py*
%dir %{python_sitearch}/qubes/ext
%{python_sitearch}/qubes/ext/__init__.py*
%dir %{python_sitelib}/qubes/tools
%{python_sitelib}/qubes/tools/__init__.py*
%{python_sitelib}/qubes/tools/qubes_create.py*
%{python_sitelib}/qubes/tools/qvm_create.py*
%{python_sitelib}/qubes/tools/qvm_ls.py*
%{python_sitelib}/qubes/tools/qvm_prefs.py*
%{python_sitelib}/qubes/tools/qvm_start.py*
%dir %{python_sitearch}/qubes/tests
%{python_sitearch}/qubes/tests/__init__.py*
%{python_sitearch}/qubes/tests/run.py*
%dir %{python_sitelib}/qubes/ext
%{python_sitelib}/qubes/ext/__init__.py*
%{python_sitearch}/qubes/tests/events.py*
%{python_sitearch}/qubes/tests/init.py*
%dir %{python_sitelib}/qubes/tests
%{python_sitelib}/qubes/tests/__init__.py*
%{python_sitelib}/qubes/tests/run.py*
%dir %{python_sitearch}/qubes/tests/vm
%{python_sitearch}/qubes/tests/vm/__init__.py*
%{python_sitearch}/qubes/tests/vm/init.py*
%{python_sitearch}/qubes/tests/vm/adminvm.py*
%{python_sitearch}/qubes/tests/vm/qubesvm.py*
%{python_sitelib}/qubes/tests/events.py*
%{python_sitelib}/qubes/tests/init.py*
%dir %{python_sitearch}/qubes/tests/tools
%{python_sitearch}/qubes/tests/tools/__init__.py*
%{python_sitearch}/qubes/tests/tools/init.py*
%{python_sitearch}/qubes/tests/tools/qvm_ls.py*
%dir %{python_sitelib}/qubes/tests/vm
%{python_sitelib}/qubes/tests/vm/__init__.py*
%{python_sitelib}/qubes/tests/vm/init.py*
%{python_sitelib}/qubes/tests/vm/adminvm.py*
%{python_sitelib}/qubes/tests/vm/qubesvm.py*
%dir %{python_sitelib}/qubes/tests/tools
%{python_sitelib}/qubes/tests/tools/__init__.py*
%{python_sitelib}/qubes/tests/tools/init.py*
%{python_sitelib}/qubes/tests/tools/qvm_ls.py*
# qmemman
%{python_sitearch}/qubes/qmemman.py*
%{python_sitearch}/qubes/qmemman_algo.py*
%{python_sitearch}/qubes/qmemman_client.py*
%{python_sitearch}/qubes/qmemman_server.py*
%{python_sitelib}/qubes/qmemman.py*
%{python_sitelib}/qubes/qmemman_algo.py*
%{python_sitelib}/qubes/qmemman_client.py*
%{python_sitelib}/qubes/qmemman_server.py*
/usr/lib/qubes/unbind-pci-device.sh
/usr/lib/qubes/cleanup-dispvms

33
setup.py Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/python2 -O
# vim: fileencoding=utf-8
import glob
import os
import setuptools
# don't import: import * is unreliable and there is no need, since this is
# compile time and we have source files
def get_console_scripts():
for filename in os.listdir('./qubes/tools'):
basename, ext = os.path.splitext(os.path.basename(filename))
if basename == '__init__' or ext != '.py':
continue
yield '{} = qubes.tools.{}:main'.format(
basename.replace('_', '-'), basename)
if __name__ == '__main__':
setuptools.setup(
name='qubes',
version=open('version').read().strip(),
author='Invisible Things Lab',
author_email='woju@invisiblethingslab.com',
description='Qubes core package',
license='GPL2+',
url='https://www.qubes-os.org/',
packages=setuptools.find_packages(exclude=('core*', 'tests')),
entry_points={
'console_scripts': list(get_console_scripts()),
}
)