1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2024-10-26 16:25:10 +03:00
Commit Graph

186 Commits

Author SHA1 Message Date
Michal Privoznik
a6b8929083 generator.py: Drop build/ prefix from #include
When -Ibuild flag is passed to compiler then build/ can be dropped
from includes. This is safe to do, because the prefix is only on
local includes (#include "") not system ones (#include <>).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2024-05-02 12:50:16 +00:00
Michal Privoznik
533399d186 setup.py: s/PY_VERSION/VERSION/
When generating spec file, @PY_VERSION@ is replaced with the
current version of libvirt-python. Well, it's not as obvious as
it could be: usually it's just @VERSION@. Worse, the PY_ prefix
may mislead readers into thinking it refers to python version.

Just drop the PY_ prefix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2024-05-02 12:50:16 +00:00
Daniel P. Berrangé
1d0166204c Request the Python stable API when building
We have Python 3.6 as a minimum version. If we set Py_LIMITED_API
to 0x03060000, we'll get the stable python API associated with
versions >= 3.6. This lets users compile once and have the libvirt
binary module be loadable by any Python version >= 3.6, as described
in:

  https://docs.python.org/3/c-api/stable.html

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-09-25 11:17:31 +00:00
Pino Toscano
c4ede87284 setup: simplify authors list generation
Use a set to collect the authors from the git output with no duplicates,
then sort the resulting set, and apply the wanted indentation.

This method is more Pythonic, using a set to avoid duplicates; applying
the indentation after the sorting makes the sorting slightly faster.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2023-09-25 10:42:29 +00:00
Pino Toscano
41363417b7 setup: switch away fron subprocess.Popen()
Adopt subprocess.check_output() as more modern and higher-level way to
invoke processes, checking that they succeed, and getting their output.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2023-09-25 10:42:29 +00:00
Pino Toscano
bf83c2b236 setup: remove unnecessary f-string
The whole content of this f-string is a variable, so use that variable
directly.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2023-09-25 10:42:29 +00:00
Pino Toscano
2c8339b44c setup: invoke git commands properly
Storing the git commands as single string, to split it by space later
on, works only in case there are no spaces in the arguments, which is
exactly what is in those commands.

Instead, specify them directly as lists, with the options & arguments
split in the right way. This fixes the generation of the AUTHORS and
ChangeLog files.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2023-09-25 10:42:29 +00:00
Erik Skultety
1baa0870ea setup: Drop the my_test command
Direct setup.py invocations are being discouraged in favour of
using Python's 'build' module. Therefore, we can't really make use of this command
anymore since only wheels and tarballs are built with the 'build' module
compared to the previous state of the art of dumping the freshly built
modules and libraries directly inside the build directory.

We'll have to encourage usage of tox which will install the package
inside a virtualenvironment for the tests. Future patch will update the
Makefile targets to make this easier for the end users.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-22 10:27:41 +02:00
Erik Skultety
aeb62b087b setup: Drop the clean command
Direct setup.py invocations are discouraged anyway, use git clean
or 'make clean' instead.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-22 10:27:41 +02:00
Erik Skultety
390cadccc0 setup: Query library version out of a file
This makes it possible to programatically query the version in any
stage of the build process, including Makefile etc.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-22 10:27:41 +02:00
Erik Skultety
8c3eb73631 Move declarative stuff out of setup.py to setup.cfg
So, why using setup.cfg if pyproject.toml is the new best thing
recommended everywhere? Well, quite a few of the fields we use with
setuptools are setuptools-specific and haven't been introduced as
keywords to pyproject.toml yet. There is a chance that these fields
could be added via a dedicated 'tool.setuptools' TOML section, but none
of it is officially documented and so it would be BETA at best anyway.
Let's not try our luck and use a declarative config file tailored
specifically to setuptools - setup.cfg. It's also unlikely we'd switch
from setuptools to something else in the near future given the nature
of building this project (i.e. building with C modules) and if so, it
would likely not be a PyPa recommended PEP-517 compliant build
system anyway, e.g. meson, so we're totally fine doing this.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-22 10:27:41 +02:00
Erik Skultety
3ffb60b7c8 setup: styling: Fix last occurrence of os.path in favour of pathlib
Commit e749b4cf forgot to update a couple more occurrences.

Fixes: e749b4cf11
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-09 11:12:34 +02:00
Erik Skultety
28d620c36c setup: Drop explicit creation of the build dir in sdist
No need to do that since we'll create it in the top-level code as a
first thing anyway.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-09 11:12:34 +02:00
Erik Skultety
8ba4e9d626 setup: Use a simple helper to generate dist files from .in templates
The code is almost identical in the impacted cases, so factor it out.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-09 11:12:25 +02:00
Erik Skultety
910079e4a7 setup: styling: Use context managers more
Some of the operations, namely file operations and spawning processes
can utilize the power of context managers. Use them more, use them
together.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-09 11:05:35 +02:00
Erik Skultety
d1cf506635 setup: Move over from os.popen to subprocess.Popen
subprocess is the high-level Pythonic interface providing more
flexibility over the low-level os.popen stuff. It is recommended to
always use subprocess over the direct 'os' interface.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-09 11:05:35 +02:00
Erik Skultety
583203c94c setup: styling: More f-string conversions
Fix a few more occurrences.

Fixes: 745e5a8ca4
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-09 11:05:35 +02:00
Erik Skultety
cd936c1f8a setup: Simplify get_pkgconfig_data
We don't need to do both None/non-None checks on the returned string.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-08 09:23:06 +02:00
Erik Skultety
e749b4cf11 setup: Move away from os.path to pathlib.Path
Drops usage of the glob module along the way as pathlib integrates glob
as well.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-08 09:23:06 +02:00
Erik Skultety
8c9bc5d2d0 setup: styling: Don't mix top-level code with function/class definition
It hinders readability so much when the top-level code that gets
executed right away when setup.py is loaded is mixed in between type
definitions.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
ad6a3343b7 setup: styling: Format multi-line arguments properly
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
745e5a8ca4 setup: styling: Adopt f-strings in favour of old-style string formatting
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
e418191c7b setup: styling: Drop unexpected spaces when providing kwargs arguments
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
df801cebd7 setup: styling: Replace apostrophes with quotes
Let's standardize on usage of one and be consistent with it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
35182909b8 setup: styling: Fix method/function/class spacing
2 newlines in between classes/functions, 1 newline in between methods.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
5a7ad288f8 setup: Re-order the imports
First go general, whole module imports, then specific symbol imports.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
fa96143b35 setup: Bump the minimum version of Python to 3.6
3.6 is already EOL, but many platforms still default to Python 3.6 when
it comes to the default platform Python package. Since we don't rely
on any 3.7+ features in the bindings at the moment, let's keep
everyone's life simpler and stay with 3.6 for now, we can bump it again
in the future.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:28:16 +02:00
Erik Skultety
90bf275b7d setup: Reduce the Python classifiers to "Python :: 3" only
We're not good at tracking all the released Python 3 versions (+ we
don't support Python 2 anymore).
Additionally, future patches will take care of reporting the minimum
required version of Python anyway through the 'python_requires' field
which shows up correctly in PyPI.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-06-07 17:27:34 +02:00
Jiri Denemark
5023662140 Post-release version bump to 9.5.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-06-01 11:50:43 +02:00
Jiri Denemark
d6d4929462 Post-release version bump to 9.4.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-05-02 14:19:04 +02:00
Jiri Denemark
3d89ddd1b7 Post-release version bump to 9.3.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-04-19 12:28:55 +00:00
Daniel P. Berrangé
65214dcd96 setup: limit pytest to 'tests' subdir
The libvirt git repo contains test data that represents the
layout of files in sysfs, which has two subdirs that mutually
reference each other with symlinks.

When pytest does test discovery it will traverse every
directory it finds underneath the libvirt-python checkout.

Since we checkout libvirt as a sub-dir, pytest traverses
everything in libvirt git and gets stuck in an infinite
loop following symlinks in the libvirt test data.

Telling pytest to only look at the 'tests' subdir avoids
this extra traversal.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-19 08:17:16 -04:00
Jiri Denemark
a0c7f86f06 Post-release version bump to 9.2.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-03-01 11:15:54 +01:00
Jiri Denemark
8ef7420806 Post-release version bump to 9.1.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-01-16 12:45:47 +01:00
Jiri Denemark
deabf3d88c Post-release version bump to 9.0.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-12-01 11:00:04 +01:00
Jiri Denemark
42305fb615 Post-release version bump to 8.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-11-01 12:37:38 +01:00
Jiri Denemark
bf95d64c72 Post-release version bump to 8.9.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-10-03 08:56:38 +00:00
Bastian Germann
c2374d3f4e Link libvirtmod_* modules also with libvirt
The -lvirt linker flag has to be added to the libvirtmod_qemu and
libvirtmod_lxc modules as well.

Signed-off-by: Bastian Germann <bage@linutronix.de>
2022-09-09 17:28:51 +02:00
Jiri Denemark
292da8384c Post-release version bump to 8.8.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-09-01 12:01:10 +02:00
Jiri Denemark
62681e1569 Post-release version bump to 8.7.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-08-01 09:40:54 +02:00
Jiri Denemark
2c8e159373 Post-release version bump to 8.6.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-07-01 11:27:50 +02:00
Pino Toscano
ba4db43f63 setup: make 'clean' command compatible again with distutils
After the switch of 'my_clean' to a simple Command, the 'clean' command
has no more bits for options, resulting in distutils (either external
or embedded in setuptools) complaining about it:

  distutils.errors.DistutilsClassError: command class <class '__main__.my_clean'> must provide 'user_options' attribute (a list of tuples)

To overcome that, provide all the standard bits from options, i.e. the
'user_options' list, and the 'initialize_options' & 'finalize_options'
methods. In addition, add a dummy 'all' option, as distutils wants it:

  error: error in [...]/.pydistutils.cfg: command 'my_clean' has no such option 'all'

Fixes commit a965c91c6f

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2022-06-25 06:38:30 +02:00
Daniel P. Berrangé
b34fbaf405 setup: advertize Python 3.9 and 3.10 support
Add classifiers that indicate we intend to support python versions
3.9 and 3.10.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Daniel P. Berrangé
e3fab09382 tests: use mocks to allow calling virEventRegisterImpl many times
We currently have to run each of the test_aio.py test cases in a
separate process, because libvirt.virEventRegisterImpl can only be
called once per process. This leads to quite unpleasant console
output when running tests.

By introducing a mock for libvirt.virEventRegisterImpl we can
regain the ability to run everything in a single process. The only
caveat is that it relies on tests to fully cleanup, but in practice
this is ok for our current tests.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Chris Gunn
b9f79758c9 tests: add libvirtaio test coverage
Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
2022-06-08 16:43:52 +01:00
Jiri Denemark
8a0e3f052b Post-release version bump to 8.5.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-06-01 09:31:33 +02:00
Jiri Denemark
f27567e993 Post-release version bump to 8.4.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-05-02 13:38:10 +02:00
Daniel P. Berrangé
60044515a2 setup: switch to running API coverage test using pytest
The API coverage test is no longer a special case.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
d4dfac2a43 sanitytest: stop passing python module path into sanity test
We want to move over to make sanitytest.py operate like a more normal
test script, which means making it self contained.

The setup.py already sets the PYTHONPATH thanks to changes introduced
in:

  commit eaded7bdad
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Tue Mar 18 11:11:48 2014 +0000

    Add support for running unit tests with nose

so passing the python module path into sanitytest.py is redundant.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
4e5d903fc3 sanitytest: stop passing API XML path into sanity test
We want to move over to make sanitytest.py operate like a more normal
test script, which means making it self contained.

The test already knows how to find the libvirt API XML path using
pkg-config and if an override location is required, this can be done
by pointing $PKG_CONFIG_PATH to a suitable place.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00