Добавлено нахождение папки "egg-info" #1
Теперь пользователю не надо вводить название проекта для удаления папки "{название проекта}.egg-info", код находит эту папку сам
This commit is contained in:
+11
-4
@@ -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,7 +50,8 @@ 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__":
|
||||
|
||||
Reference in New Issue
Block a user