From 9003212ef354474287f0ccd62eb459481f88d641 Mon Sep 17 00:00:00 2001 From: Ilia Miheev Date: Mon, 6 Oct 2025 21:57:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BD=D0=B0=D1=85=D0=BE=D0=B6=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B8=20"egg-info"=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Теперь пользователю не надо вводить название проекта для удаления папки "{название проекта}.egg-info", код находит эту папку сам --- uploadi/uploadi.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/uploadi/uploadi.py b/uploadi/uploadi.py index 8ed1ca3..428c7e5 100644 --- a/uploadi/uploadi.py +++ b/uploadi/uploadi.py @@ -8,13 +8,20 @@ class CustomArgumentParser(ArgumentParser): print(f"Ошибка: {message}", file=sys.stderr) sys.exit(1) +def find_egg_info_folder(): + '''Находим папку с именем ".egg-info"''' + current_directory = os.getcwd() + for item in os.listdir(current_directory): + if os.path.isdir(item) and ".egg-info" in item: + return item + return None + def uploadi(): # Получаем аргументы из командной строки parser = CustomArgumentParser(description="Код для загрузки проектов python на PyPI или TestPyPI") parser.add_argument('-t', action='store_true', help='Загрузка будет происходить на TestPyPI') parser.add_argument('-p', action='store_true', help='Загрузка будет происходить на PyPI') - parser.add_argument('name_project', help='Название проекта') args = parser.parse_args() # Проверяем наличие одного из флагов @@ -29,8 +36,7 @@ def uploadi(): print('Отсутствует файл загрузки setup.py') return - # Определяем имя проекта и комманду выгрузки - name_project = args.name_project.replace('-', '_') + # Определяем комманду выгрузки command = '' if args.t: command = 'twine upload --repository-url https://test.pypi.org/legacy/ dist/*' @@ -44,8 +50,9 @@ def uploadi(): # Выполняем выгрузку os.system('python setup.py sdist bdist_wheel') os.system(command) - os.system(f'rmdir /s /q build dist {name_project}.egg-info') + eggInfo = find_egg_info_folder() + os.system(f'rmdir /s /q build dist {eggInfo}') if __name__ == "__main__": - uploadi() \ No newline at end of file + uploadi()