From 95a80636c82d1ff4305533228f95c8fef4499ccd Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Wed, 31 Jan 2024 19:15:49 +0300 Subject: [PATCH] Initial commit --- .gitignore | 5 +++ LICENSE | 21 ++++++++++ README.md | 1 + RELEASE-NOTES.md | 27 +++++++++++++ package/__init__.py | 1 + requirements.txt | 0 setup.cfg | 3 ++ setup.py | 99 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 157 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 RELEASE-NOTES.md create mode 100644 package/__init__.py create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb75543 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.*/ +__pycache__/ +/build/ +/dist/ +/*.egg-info/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4d59e1a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 AUTHOR + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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..8a256be --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# [package-name](https://dev.lirent.ru/python/package-name) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md new file mode 100644 index 0000000..836aaf5 --- /dev/null +++ b/RELEASE-NOTES.md @@ -0,0 +1,27 @@ +## 0.0.0 (1970-01-01) + +> Description + +### Upgrade Steps +* +* + +### Breaking Changes +* +* + +### New Features +* +* + +### Bug Fixes +* +* + +### Performance Improvements +* +* + +### Other Changes +* +* diff --git a/package/__init__.py b/package/__init__.py new file mode 100644 index 0000000..a7ef950 --- /dev/null +++ b/package/__init__.py @@ -0,0 +1 @@ +# This software is licensed by the MIT License (MIT), see LICENSE file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..96fadd5 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[egg_info] +tag_build = +tag_date = 0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7315353 --- /dev/null +++ b/setup.py @@ -0,0 +1,99 @@ +# This software is licensed by the MIT License (MIT), see LICENSE file + +# Use it with: `python setup.py sdist bdist_wheel` + +import os + +from pathlib import Path +from setuptools import setup, find_packages + +AUTHOR = 'Author' +AUTHOR_EMAIL = 'email@example.com' +PROJECT_URL = 'https://dev.lirent.ru/python/package-name' +PROJECT_REPO = f'{PROJECT_URL}/src/branch/master' +PROJECT_DOCS = f'{PROJECT_REPO}/README.md' +DESCRIPTION = 'Package description' +KEYWORDS = '' +PYTHON_VERSION = "3.11" + +CLASSIFIERS = [ + f'Programming Language :: Python :: {PYTHON_VERSION}', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Framework :: Django :: 5.0' +] + + +CWD = Path(__file__).resolve().parent + + +def get_package_name(): + excludes = [('.git', '.git'), ('test', '')] + candidates = [] + + with open(CWD / '.gitignore', 'r', -1, 'utf8') as f: + for line in f.readlines(): + line = line.strip() + if line.endswith('/'): + line = line[1:-1] if line.startswith('/') else line[:-1] + if line.count('*') == 1: + line = line.split('*') + elif line.count('*') > 1: + raise AttributeError(f'unexpected value in .gitignore: {line}/') + else: + line = (line, line) + excludes.append(line) + + for instance in os.listdir(CWD): + if os.path.isdir(CWD / instance): + exclude = False + for x in excludes: + if instance.startswith(x[0]) and instance.endswith(x[1]): + exclude = True + break + if not exclude: + candidates.append(instance) + if len(candidates) != 1: + raise AttributeError('package name cannot be determined') + else: + return candidates[0] + + +def readme(): + with open(CWD / 'README.md', 'r', -1, 'utf8') as f: + return f.read() + + +def version(): + with open(CWD / 'RELEASE-NOTES.md', 'r', -1, 'utf8') as f: + for line in f.readlines(): + if line.startswith('## '): + return line[2:].strip().split(' ')[0] + raise AttributeError('version not found') + + +def requirements(): + with open(CWD / 'requirements.txt', 'r', -1, 'utf8') as f: + return [line.strip() for line in f.readlines() if line.strip()] + + +setup( + name=get_package_name(), + version=version(), + author=AUTHOR, + author_email=AUTHOR_EMAIL, + description=DESCRIPTION, + long_description=readme(), + long_description_content_type='text/markdown', + url=PROJECT_URL, + packages=find_packages(), + install_requires=requirements(), + classifiers=CLASSIFIERS, + keywords=KEYWORDS, + project_urls={ + 'homepage': PROJECT_URL, + 'repository': PROJECT_REPO, + 'documentation': PROJECT_DOCS + }, + python_requires=f'>={PYTHON_VERSION}' +)