Move optional build dependencies to 'extras'

...and start skipping the relevant tests in 'nova.tests.unit.virt' if
these dependencies are not present. Thanks to hacking rules N311 and
N312, which prevent virt drivers using code from other virt drivers,
simply skipping the unit tests for a virt driver module is enough to
ensure we never load those modules.

This means users that want to use the powervm driver can install the
required dependencies using e.g. 'pip install .[powervm]', and packagers
can choose to skip packaging a dependency safe in the knowledge that the
relevant tests will be skipped.

Change-Id: I3787f9afd78cd0a7c7feb4dfe1bcb21437b5a128
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2021-12-22 16:25:19 +00:00
parent ff1dbb5eb4
commit 86d87be8db
7 changed files with 78 additions and 9 deletions

View File

@ -0,0 +1,20 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
try:
import os_win # noqa: F401
except ImportError:
raise unittest.SkipTest(
"The 'os-win' dependency is not installed."
)

View File

@ -11,13 +11,22 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import unittest
from oslo_utils.fixture import uuidsentinel
from nova.compute import power_state
from nova.compute import vm_states
from nova import objects
try:
import powervm # noqa: F401
except ImportError:
raise unittest.SkipTest(
"The 'pypowervm' dependency is not installed."
)
TEST_FLAVOR = objects.flavor.Flavor(
memory_mb=2048,

View File

@ -0,0 +1,20 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
try:
import oslo_vmware # noqa: F401
except ImportError:
raise unittest.SkipTest(
"The 'oslo.vmware' dependency is not installed."
)

View File

@ -0,0 +1,20 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
try:
import zvmconnector # noqa: F401
except ImportError:
raise unittest.SkipTest(
"The 'zVMCloudConnector' dependency is not installed."
)

View File

@ -8,8 +8,6 @@ lxml>=4.5.0 # BSD
Routes>=2.3.1 # MIT
cryptography>=2.7 # BSD/Apache-2.0
WebOb>=1.8.2 # MIT
# NOTE(mriedem): greenlet 0.4.14 does not work with older versions of gcc on
# ppc64le systems, see https://github.com/python-greenlet/greenlet/issues/136.
greenlet>=0.4.15 # MIT
PasteDeploy>=1.5.0 # MIT
Paste>=2.0.2 # MIT
@ -52,17 +50,14 @@ os-brick>=4.3.1 # Apache-2.0
os-resource-classes>=1.1.0 # Apache-2.0
os-traits>=2.5.0 # Apache-2.0
os-vif>=1.15.2 # Apache-2.0
os-win>=5.4.0 # Apache-2.0
castellan>=0.16.0 # Apache-2.0
microversion-parse>=0.2.1 # Apache-2.0
tooz>=1.58.0 # Apache-2.0
cursive>=0.2.1 # Apache-2.0
pypowervm>=1.1.15 # Apache-2.0
retrying>=1.3.3,!=1.3.0 # Apache-2.0
os-service-types>=1.7.0 # Apache-2.0
taskflow>=3.8.0 # Apache-2.0
python-dateutil>=2.7.0 # BSD
zVMCloudConnector>=1.3.0;sys_platform!='win32' # Apache 2.0 License
futurist>=1.8.0 # Apache-2.0
openstacksdk>=0.35.0 # Apache-2.0
dataclasses>=0.7;python_version=='3.6' # Apache 2.0 License

View File

@ -30,6 +30,14 @@ classifiers =
[extras]
osprofiler =
osprofiler>=1.4.0 # Apache-2.0
powervm =
pypowervm>=1.1.15 # Apache-2.0
zvm =
zVMCloudConnector>=1.3.0;sys_platform!='win32' # Apache 2.0 License
hyperv =
os-win>=5.4.0 # Apache-2.0
vmware =
oslo.vmware>=3.6.0 # Apache-2.0
[files]
data_files =

View File

@ -23,6 +23,3 @@ testtools>=2.5.0 # MIT
bandit>=1.1.0 # Apache-2.0
gabbi>=1.35.0 # Apache-2.0
wsgi-intercept>=1.7.0 # MIT License
# vmwareapi driver specific dependencies
oslo.vmware>=3.6.0 # Apache-2.0