diff --git a/.createrepo_c.metadata b/.createrepo_c.metadata
index 736e1d7..eac90b8 100644
--- a/.createrepo_c.metadata
+++ b/.createrepo_c.metadata
@@ -1 +1 @@
-39e70f306cff3675e581b204a2754212280342e1 SOURCES/createrepo_c-0.16.2.tar.gz
+9feb9bf8e6a9812a08ef8156c3ccc1c4dac90b7a SOURCES/createrepo_c-0.17.2.tar.gz
diff --git a/.gitignore b/.gitignore
index 87831e1..fe40994 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/createrepo_c-0.16.2.tar.gz
+SOURCES/createrepo_c-0.17.2.tar.gz
diff --git a/SOURCES/0001-Fix-cr_compress_file_with_stat-Memory-leak.patch b/SOURCES/0001-Fix-cr_compress_file_with_stat-Memory-leak.patch
new file mode 100644
index 0000000..126a489
--- /dev/null
+++ b/SOURCES/0001-Fix-cr_compress_file_with_stat-Memory-leak.patch
@@ -0,0 +1,25 @@
+From 1ec1e767e4a48bc2c1d09b52da9e749352f8d925 Mon Sep 17 00:00:00 2001
+From: Jaroslav Rohel <jrohel@redhat.com>
+Date: Thu, 6 May 2021 19:09:19 +0200
+Subject: [PATCH] Fix: cr_compress_file_with_stat: Memory leak
+
+---
+ src/misc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/misc.c b/src/misc.c
+index e5350ac..59c04e6 100644
+--- a/src/misc.c
++++ b/src/misc.c
+@@ -503,6 +503,8 @@ cr_compress_file_with_stat(const char *src,
+     if (!orig) {
+         ret = tmp_err->code;
+         g_propagate_prefixed_error(err, tmp_err, "Cannot open %s: ", src);
++        if (dst != in_dst)
++            g_free(dst);
+         return ret;
+     }
+ 
+--
+libgit2 1.0.1
+
diff --git a/SOURCES/0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch b/SOURCES/0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch
deleted file mode 100644
index f078b74..0000000
--- a/SOURCES/0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From e21b038a231e2743e30915af9575b8c43e9fda1f Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
-Date: Tue, 15 Dec 2020 14:15:39 +0100
-Subject: [PATCH] Never leave behind .repodata lock on exit (RhBug:1906831
-
-createrepo_c was removing `.repodata` if `exit_val` was se to failure.
-Problem is `exit_val` is set only on a couple of places so most of the
-failures (no matter how rare) leave `.repodata` behind.
-
-However because on a successful run `.repodata` is renamed to normal
-output `repodata` we know that if `.repodata` are present there was an
-error and we can delete them.
----
- src/createrepo_c.c      |  5 +----
- src/createrepo_shared.c | 29 +++++++++--------------------
- 2 files changed, 10 insertions(+), 24 deletions(-)
-
-diff --git a/src/createrepo_c.c b/src/createrepo_c.c
-index 8c90ebd..eeb871c 100644
---- a/src/createrepo_c.c
-+++ b/src/createrepo_c.c
-@@ -665,9 +665,6 @@ main(int argc, char **argv)
-         exit(EXIT_FAILURE);
-     }
- 
--    // Set exit_value pointer used in cleanup handlers
--    cr_set_global_exit_value(&exit_val);
--
-     // Setup cleanup handlers
-     if (!cr_set_cleanup_handler(lock_dir, tmp_out_repo, &tmp_err)) {
-         g_printerr("%s\n", tmp_err->message);
-@@ -885,7 +882,7 @@ main(int argc, char **argv)
-         char *moduleindex_str = modulemd_module_index_dump_to_string (moduleindex, &tmp_err);
-         g_clear_pointer(&moduleindex, g_object_unref);
-         if (tmp_err) {
--            g_critical("%s: Cannot cannot dump module index: %s", __func__, tmp_err->message);
-+            g_critical("%s: Cannot dump module index: %s", __func__, tmp_err->message);
-             free(moduleindex_str);
-             g_clear_error(&tmp_err);
-             exit(EXIT_FAILURE);
-diff --git a/src/createrepo_shared.c b/src/createrepo_shared.c
-index f8ef998..d1a37bd 100644
---- a/src/createrepo_shared.c
-+++ b/src/createrepo_shared.c
-@@ -28,8 +28,6 @@
- #include "misc.h"
- #include "cleanup.h"
- 
--int *global_exit_status = NULL;  // pointer to exit_value used in failure_exit_cleanup
--
- char *global_lock_dir     = NULL;  // Path to .repodata/ dir that is used as a lock
- char *global_tmp_out_repo = NULL;  // Path to temporary repodata directory,
-                                    // if NULL that it's same as
-@@ -43,18 +41,16 @@ char *global_tmp_out_repo = NULL;  // Path to temporary repodata directory,
-  *
-  */
- static void
--failure_exit_cleanup()
-+exit_cleanup()
- {
--    if (global_exit_status && *global_exit_status != EXIT_SUCCESS) {
--        if (global_lock_dir) {
--            g_debug("Removing %s", global_lock_dir);
--            cr_remove_dir(global_lock_dir, NULL);
--        }
-+    if (global_lock_dir) {
-+        g_debug("Removing %s", global_lock_dir);
-+        cr_remove_dir(global_lock_dir, NULL);
-+    }
- 
--        if (global_tmp_out_repo) {
--            g_debug("Removing %s", global_tmp_out_repo);
--            cr_remove_dir(global_tmp_out_repo, NULL);
--        }
-+    if (global_tmp_out_repo) {
-+        g_debug("Removing %s", global_tmp_out_repo);
-+        cr_remove_dir(global_tmp_out_repo, NULL);
-     }
- }
- 
-@@ -65,16 +61,9 @@ static void
- sigint_catcher(int sig)
- {
-     g_message("%s caught: Terminating...", strsignal(sig));
--    *global_exit_status = 1;
-     exit(1);
- }
- 
--void
--cr_set_global_exit_value(int *exit_val)
--{
--    global_exit_status = exit_val;
--}
--
- gboolean
- cr_set_cleanup_handler(const char *lock_dir,
-                        const char *tmp_out_repo,
-@@ -90,7 +79,7 @@ cr_set_cleanup_handler(const char *lock_dir,
-         global_tmp_out_repo = NULL;
- 
-     // Register on exit cleanup function
--    if (atexit(failure_exit_cleanup))
-+    if (atexit(exit_cleanup))
-         g_warning("Cannot set exit cleanup function by atexit()");
- 
-     // Prepare signal handler configuration
diff --git a/SPECS/createrepo_c.spec b/SPECS/createrepo_c.spec
index 4819f89..32f4add 100644
--- a/SPECS/createrepo_c.spec
+++ b/SPECS/createrepo_c.spec
@@ -1,34 +1,22 @@
 %global libmodulemd_version 2.3.0
 %{!?_licensedir:%global license %%doc}
+%define __cmake_in_source_build 1
 
-# Bash completion (we need different approach for RHEL-6)
-%if 0%{?rhel} == 6
-%global bash_completion %config%{_sysconfdir}/bash_completion.d/createrepo_c.bash
-%else
 %global bash_completion %{_datadir}/bash-completion/completions/*
-%endif
 
-%if 0%{?rhel} && 0%{?rhel} <= 7
-%bcond_with python3
+%if 0%{?rhel} && ( 0%{?rhel} <= 7 || 0%{?rhel} >= 9 )
 %bcond_with drpm
 %else
-%bcond_without python3
 %bcond_without drpm
 %endif
 
-%if 0%{?fedora} > 29 || 0%{?rhel} > 7
-%bcond_with python2
-%else
-%bcond_without python2
-%endif
-
 %if 0%{?rhel} || (0%{?fedora} && 0%{?fedora} < 29)
 %bcond_with zchunk
 %else
 %bcond_without zchunk
 %endif
 
-%if 0%{?rhel} < 8 || (0%{?fedora} && 0%{?fedora} < 29)
+%if (0%{?rhel} && 0%{?rhel} < 8) || (0%{?fedora} && 0%{?fedora} < 29)
 %bcond_with libmodulemd
 %else
 %bcond_without libmodulemd
@@ -36,12 +24,12 @@
 
 Summary:        Creates a common metadata repository
 Name:           createrepo_c
-Version:        0.16.2
+Version:        0.17.2
 Release:        2%{?dist}
 License:        GPLv2+
 URL:            https://github.com/rpm-software-management/createrepo_c
 Source0:        %{url}/archive/%{version}/%{name}-%{version}.tar.gz
-Patch0:         0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch
+Patch1:         0001-Fix-cr_compress_file_with_stat-Memory-leak.patch
 
 BuildRequires:  cmake
 BuildRequires:  gcc
@@ -54,6 +42,7 @@ BuildRequires:  libxml2-devel
 BuildRequires:  openssl-devel
 BuildRequires:  rpm-devel >= 4.8.0-28
 BuildRequires:  sqlite-devel
+BuildRequires:  xz
 BuildRequires:  xz-devel
 BuildRequires:  zlib-devel
 %if %{with zchunk}
@@ -66,12 +55,8 @@ BuildRequires:  libmodulemd
 Requires:       libmodulemd%{?_isa} >= %{libmodulemd_version}
 %endif
 Requires:       %{name}-libs =  %{version}-%{release}
-%if 0%{?rhel} == 6
-Requires: rpm >= 4.8.0-28
-%else
 BuildRequires:  bash-completion
 Requires: rpm >= 4.9.0
-%endif
 %if %{with drpm}
 BuildRequires:  drpm-devel >= 0.4.0
 %endif
@@ -102,84 +87,35 @@ Requires:   %{name}-libs%{?_isa} = %{version}-%{release}
 This package contains the createrepo_c C library and header files.
 These development files are for easy manipulation with a repodata.
 
-%if %{with python2}
-%package -n python2-%{name}
-Summary:        Python bindings for the createrepo_c library
-%{?python_provide:%python_provide python2-%{name}}
-BuildRequires:  python2-devel
-BuildRequires:  python2-nose
-%if 0%{?rhel} && 0%{?rhel} <= 7
-BuildRequires:  python-sphinx
-%else
-BuildRequires:  python2-sphinx
-%endif
-Requires:       %{name}-libs = %{version}-%{release}
-
-%description -n python2-%{name}
-Python bindings for the createrepo_c library.
-%endif
-
-%if %{with python3}
 %package -n python3-%{name}
 Summary:        Python 3 bindings for the createrepo_c library
 %{?python_provide:%python_provide python3-%{name}}
 BuildRequires:  python3-devel
-BuildRequires:  python3-nose
 BuildRequires:  python3-sphinx
 Requires:       %{name}-libs = %{version}-%{release}
 
 %description -n python3-%{name}
 Python 3 bindings for the createrepo_c library.
-%endif
 
 %prep
 %autosetup -p1
-%if %{with python2}
-mkdir build-py2
-%endif
 
-%if %{with python3}
 mkdir build-py3
-%endif
 
 %build
-# Build createrepo_c with Python 2
-%if %{with python2}
-pushd build-py2
-  %cmake .. -DPYTHON_DESIRED:FILEPATH=%{__python2} %{!?with_zchunk:-DWITH_ZCHUNK=OFF} %{!?with_libmodulemd:-DWITH_LIBMODULEMD=OFF}
-  make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}"
-  %if %{without python3}
-  # Build C documentation
-  make doc-c
-  %endif
-popd
-%endif
-
 # Build createrepo_c with Pyhon 3
-%if %{with python3}
 pushd build-py3
-  %cmake .. -DPYTHON_DESIRED:FILEPATH=%{__python3} %{!?with_zchunk:-DWITH_ZCHUNK=OFF} %{!?with_libmodulemd:-DWITH_LIBMODULEMD=OFF}
+  %cmake .. \
+      -DWITH_ZCHUNK=%{?with_zchunk:ON}%{!?with_zchunk:OFF} \
+      -DWITH_LIBMODULEMD=%{?with_libmodulemd:ON}%{!?with_libmodulemd:OFF} \
+      -DENABLE_DRPM=%{?with_drpm:ON}%{!?with_drpm:OFF}
   make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}"
   # Build C documentation
   make doc-c
 popd
-%endif
 
 %check
-%if %{with python2}
-pushd build-py2
-  %if %{without python3}
-  # Compile C tests
-  make tests
-  %endif
-
-  # Run Python 2 tests
-  make ARGS="-V" test
-popd
-%endif
-
 # Run Python 3 tests
-%if %{with python3}
 pushd build-py3
   # Compile C tests
   make tests
@@ -187,22 +123,12 @@ pushd build-py3
   # Run Python 3 tests
   make ARGS="-V" test
 popd
-%endif
 
 %install
-%if %{with python2}
-pushd build-py2
-  # Install createrepo_c with Python 2
-  make install DESTDIR=%{buildroot}
-popd
-%endif
-
-%if %{with python3}
 pushd build-py3
   # Install createrepo_c with Python 3
   make install DESTDIR=%{buildroot}
 popd
-%endif
 
 %if 0%{?fedora} || 0%{?rhel} > 7
 ln -sr %{buildroot}%{_bindir}/createrepo_c %{buildroot}%{_bindir}/createrepo
@@ -240,28 +166,27 @@ ln -sr %{buildroot}%{_bindir}/modifyrepo_c %{buildroot}%{_bindir}/modifyrepo
 %{_libdir}/lib%{name}.so.*
 
 %files devel
-%if %{with python3}
 %doc build-py3/doc/html
-%else
-%doc build-py2/doc/html
-%endif
 %{_libdir}/lib%{name}.so
 %{_libdir}/pkgconfig/%{name}.pc
 %{_includedir}/%{name}/
 
-%if %{with python2}
-%files -n python2-%{name}
-%{python2_sitearch}/%{name}/
-%{python2_sitearch}/%{name}-%{version}-py%{python2_version}.egg-info
-%endif
-
-%if %{with python3}
 %files -n python3-%{name}
 %{python3_sitearch}/%{name}/
 %{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info
-%endif
 
 %changelog
+* Tue Jul 27 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 0.17.2-2
+- Fix: cr_compress_file_with_stat: Memory leak
+
+* Wed Apr 28 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 0.17.2-1
+- Update to 0.17.2
+- Fix Python deprecation (PY_SSIZE_T_CLEAN) (RhBug:1891785)
+- Revert back to old c API for destination file of cr_compress_file_with_stat and cr_compress_file to prevent a memory leak
+- Disable drpm for RHEL >= 9 (RhBug:1914828)
+- Setting updated/issued_date to None doesn't produce garbage values (RhBug:1921715)
+- Allow taking __repr__ (__str__) of closed xmlfile and sqlite (RhBug:1913465)
+
 * Fri Jan 29 2021 Nicola Sella <nsella@redhat.com> - 0.16.2-2
 - Never leave behind .repodata lock on exit (RhBug:1906831)