From 286d1132eeb89e7e4760647ae2ef38a6fa84eb30 Mon Sep 17 00:00:00 2001 From: Ilia Miheev Date: Thu, 10 Jul 2025 13:08:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ LICENSE.txt | 21 +++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ setup.py | 18 ++++++++++++++++++ uploadi/__init__.py | 0 uploadi/uploadi.py | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 setup.py create mode 100644 uploadi/__init__.py create mode 100644 uploadi/uploadi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4d66bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv/ +test.* diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..79f75c3 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Ilia Miheev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +1. The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +2. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d860bf8 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Библиотека для загрузки проектов на PyPI и TestPyPI + +Библиотека способна быстро и просто выгрузить проекты. Проект доступен из командной строки. + +``` +uploadi [-h] [-t] [-p] name_project +``` + +1. **-h**: Выведет справочную информацию +2. **-t**: Проект будет выгружен на TestPyPI +3. **-p**: Проект будет выгружен на PyPI +4. **name_project**: название вашего проекта + +## Пример +Эта команда выгрузит проект ipars на TestPyPI +```bash +uploadi -t ipars +``` +Эта команда выгрузит проект uploadi на PyPI +```bash +uploadi -p uploadi +``` diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f999917 --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup, find_packages + +setup( + name='uploadi', + version='1.0.1', + description='Приложение для загрузки проектов python', + long_description=open('./README.md', encoding='utf8').read(), + long_description_content_type='text/markdown', + author='Ilia Miheev', + author_email='waggle-pout-sprawl@duck.com', + packages=find_packages(), + license='MIT', + entry_points={ + 'console_scripts': [ + 'uploadi=uploadi.uploadi:uploadi', + ], + }, +) diff --git a/uploadi/__init__.py b/uploadi/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/uploadi/uploadi.py b/uploadi/uploadi.py new file mode 100644 index 0000000..af00f77 --- /dev/null +++ b/uploadi/uploadi.py @@ -0,0 +1,39 @@ +from argparse import ArgumentParser +import sys +import os + +class CustomArgumentParser(ArgumentParser): + def error(self, message): + self.print_usage(sys.stderr) + print(f"Ошибка: {message}", file=sys.stderr) + sys.exit(1) + + +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() + + # Проверяем наличие одного из флагов + # Если указагы оба флага или ни один + if (args.t and args.p) or (not args.t and not args.p): + print('Надо выбрать один флаг. -t или -p') + return + + name_project = args.name_project + + + # Выполняем выгрузку + os.system('python setup.py sdist bdist_wheel') + if args.t: + os.system('twine upload --repository-url https://test.pypi.org/legacy/ dist/*') + else: + os.system('twine upload dist/*') + os.system(f'rmdir /s /q build dist {name_project}.egg-info') + + +if __name__ == "__main__": + uploadi() \ No newline at end of file