From b458b1ceb141e53c151cba592b4449f6ef2d13d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 15 May 2023 17:02:11 +0200 Subject: [PATCH] build: chdir back to working directory after makemessages error (#77628) --- setup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c94dd69..3cca20e 100644 --- a/setup.py +++ b/setup.py @@ -58,18 +58,19 @@ class make_translations(Command): pass def run(self): + curdir = os.getcwd() try: from django.core.management import call_command for path, dirs, files in os.walk('publik_django_templatetags'): if 'locale' not in dirs: continue - curdir = os.getcwd() os.chdir(os.path.realpath(path)) call_command('makemessages', '-l', 'fr', '--add-location', 'file', '--no-obsolete') - os.chdir(curdir) except ImportError: sys.stderr.write('!!! Please install Django >= 2.2 to make translations\n') + finally: + os.chdir(curdir) class compile_translations(Command): @@ -83,18 +84,19 @@ class compile_translations(Command): pass def run(self): + curdir = os.getcwd() try: from django.core.management import call_command for path, dirs, files in os.walk('publik_django_templatetags'): if 'locale' not in dirs: continue - curdir = os.getcwd() os.chdir(os.path.realpath(path)) call_command('compilemessages') - os.chdir(curdir) except ImportError: sys.stderr.write('!!! Please install Django >= 2.2 to build translations\n') + finally: + os.chdir(curdir) class build(_build):