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()