|
| 1 | +# -*- coding:utf-8 -*- |
| 2 | +"""A setuptools based setup module. |
| 3 | +
|
| 4 | +See: |
| 5 | +https://packaging.python.org/guides/distributing-packages-using-setuptools/ |
| 6 | +https://github.com/Alinvor/Python-DeMo |
| 7 | +""" |
| 8 | + |
| 9 | +# Always prefer setuptools over distutils |
| 10 | +# from setuptools import setup, find_packages, find_namespace_packages |
| 11 | +from setuptools import setup, find_packages |
| 12 | +import os |
| 13 | +import sys |
| 14 | + |
| 15 | + |
| 16 | +def read_text(file_name): |
| 17 | + ''' the read describe readme files content. ''' |
| 18 | + content = '' |
| 19 | + with open(file_name, 'r') as file: |
| 20 | + lines = file.readlines() |
| 21 | + for line in lines: |
| 22 | + if sys.version_info.major > 2: |
| 23 | + content += str(line) |
| 24 | + else: |
| 25 | + content += str(line).encode('utf-8') |
| 26 | + # print(content) |
| 27 | + return content |
| 28 | + |
| 29 | + |
| 30 | +project = os.getenv('BASE_PROJECT_PREFIX') |
| 31 | +if project is None: |
| 32 | + raise KeyError('the please configure BASE_PROJECT_PREFIX environment variable, otherwise it cannot run') |
| 33 | +print(project) |
| 34 | +PROJECT_DIRECTORY = 'xxx' # project directory |
| 35 | +PROJECT_README_FILE = 'README.md' # project readme file |
| 36 | +README_ROOT_DIRECTORY = os.path.join(project, 'doc/description') |
| 37 | +README_PROJECT_DIRECTORY = os.path.join(README_ROOT_DIRECTORY, PROJECT_DIRECTORY) |
| 38 | +PROJECT_DESCRIPTION = os.path.join(README_PROJECT_DIRECTORY, PROJECT_README_FILE) |
| 39 | +# |
| 40 | +# Arguments marked as "Required" below must be included for upload to PyPI. |
| 41 | +# Fields marked as "Optional" may be commented out. |
| 42 | +# |
| 43 | +# | 序列 | 字段 | 数据类型 | 选项 | 描述 | 备注 | |
| 44 | +# | :---: | :-----------------------------------: | :---------: | :---: | -------------------- | ---- | |
| 45 | +# | 1 | DVSNIER_NAME | string | Y | 包名称 | | |
| 46 | +# | 2 | DVSNIER_VERSION | string | Y | 包版本 | | |
| 47 | +# | 3 | DVSNIER_DESCRIPTOIN | string | | 包简单描述 | | |
| 48 | +# | 4 | DVSNIER_LONG_DESCRIPTOIN | file | | 较长文档描述 | | |
| 49 | +# | 5 | DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE | string | | 长文本类型描述 | | |
| 50 | +# | 6 | DVSNIER_URL | http | | 项目主页 | | |
| 51 | +# | 7 | DVSNIER_AUTHOR | string | | 项目作者 | | |
| 52 | +# | 8 | DVSNIER_AUTHOR_EMAIL | email | | 项目作者邮箱 | | |
| 53 | +# | 9 | DVSNIER_LICENSE | 许可证 | | 许可证 | | |
| 54 | +# | 10 | DVSNIER_CLASSIFIERS | classifiers | | 项目分类器 | | |
| 55 | +# | 11 | DVSNIER_KEYWORDS | keywords | | 项目关键字 | | |
| 56 | +# | 12 | DVSNIER_PACKAGE_DIR | string | | 包目录 | | |
| 57 | +# | 13 | DVSNIER_PY_MODULES | string | Y | 模块名称 | | |
| 58 | +# | 14 | DVSNIER_PACKAGES | string | Y | 包名称 | | |
| 59 | +# | 15 | DVSNIER_PYTHON_REQUIRES | string | Y | 版本匹配分类器描述符 | | |
| 60 | +# | 16 | DVSNIER_INSTALL_REQUIRES | list | | 依赖库 | | |
| 61 | +# | 17 | DVSNIER_EXTRAS_REQUIRE | dict | | 附加/扩展依赖 | | |
| 62 | +# | 18 | DVSNIER_PACKAGE_DATA | dict | | 包数据文件 | | |
| 63 | +# | 19 | DVSNIER_DATA_FILES | list | | 包外数据文件 | | |
| 64 | +# | 20 | DVSNIER_ENTRY_POINTS | dict | | 入口点 | | |
| 65 | +# | 21 | DVSNIER_PROJECT_URLS | dict | | 项目 URL | | |
| 66 | +# | 22 | | | | | | |
| 67 | +DVSNIER_NAME = 'com.dvsnier.xxx' # Required |
| 68 | +DVSNIER_VERSION = '0.0.1.dev0' # Required |
| 69 | +DVSNIER_DESCRIPTOIN = 'this is dvsnier xxx.' # Optional |
| 70 | +# Get the long description from the README file |
| 71 | +DVSNIER_LONG_DESCRIPTOIN = read_text(str(PROJECT_DESCRIPTION)) # Optional |
| 72 | +DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE = 'text/markdown' # Optional |
| 73 | +DVSNIER_URL = 'https://github.com/Alinvor/Python-DeMo' # Optional |
| 74 | +DVSNIER_AUTHOR = 'dvsnier' # Optional |
| 75 | +DVSNIER_AUTHOR_EMAIL = 'dovsnier@qq.com' # Optional |
| 76 | +DVSNIER_LICENSE = 'MIT' # Optional |
| 77 | +DVSNIER_CLASSIFIERS = [ # Optional |
| 78 | + # How mature is this project? Common values are |
| 79 | + # 3 - Alpha |
| 80 | + # 4 - Beta |
| 81 | + # 5 - Production/Stable |
| 82 | + 'Development Status :: 3 - Alpha', |
| 83 | + |
| 84 | + # Indicate who your project is intended for |
| 85 | + # 'Intended Audience :: Developers', |
| 86 | + # 'Topic :: Software Development :: Build Tools', |
| 87 | + 'Topic :: Software Development :: Libraries', |
| 88 | + |
| 89 | + # Pick your license as you wish |
| 90 | + 'License :: OSI Approved :: MIT License', |
| 91 | + |
| 92 | + # Specify the Python versions you support here. In particular, ensure |
| 93 | + # that you indicate you support Python 3. These classifiers are *not* |
| 94 | + # checked by 'pip install'. See instead 'python_requires' below. |
| 95 | + 'Programming Language :: Python :: 2.7', |
| 96 | + 'Programming Language :: Python :: 3.8', |
| 97 | + 'Programming Language :: Python :: 3.9', |
| 98 | + # 'Programming Language :: Python :: 3 :: Only', |
| 99 | + # 'Operating System :: OS Independent' |
| 100 | +] |
| 101 | +DVSNIER_KEYWORDS = 'xxx, development' # Optional |
| 102 | +DVSNIER_PACKAGE_DIR = {'': 'src'} # Optional |
| 103 | +# DVSNIER_PY_MODULES = ["xxx"] # Required |
| 104 | +# DVSNIER_PACKAGES = find_packages(include=['xxx', 'xxx.*']) # Required |
| 105 | +DVSNIER_PACKAGES = find_packages(where='src') # Required |
| 106 | +# DVSNIER_NAMESPACE_PACKAGES = find_namespace_packages(include=['com.*']) # Required |
| 107 | +# DVSNIER_PYTHON_REQUIRES = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*' |
| 108 | +DVSNIER_PYTHON_REQUIRES = '>=2.7, <4' |
| 109 | +DVSNIER_INSTALL_REQUIRES = [ # Optional |
| 110 | + |
| 111 | +] |
| 112 | +DVSNIER_EXTRAS_REQUIRE = { # Optional |
| 113 | + 'dev': ['check-manifest'], |
| 114 | + 'test': ['coverage'] |
| 115 | +} |
| 116 | +DVSNIER_PACKAGE_DATA = { # Optional |
| 117 | + # 'sample': ['package_data.dat'], |
| 118 | +} |
| 119 | +DVSNIER_DATA_FILES = [ # Optional |
| 120 | + # ('my_data', ['data/data_file']) |
| 121 | +] |
| 122 | +DVSNIER_ENTRY_POINTS = { # Optional |
| 123 | + # 'console_scripts': [ |
| 124 | + # 'dvs-dir=dvs:main', |
| 125 | + # ], |
| 126 | +} |
| 127 | +DVSNIER_PROJECT_URLS = { # Optional |
| 128 | + 'Bug_Tracker': 'https://github.com/Alinvor/Python-DeMo/issues', |
| 129 | + 'Documentation': 'https://packaging.python.org/tutorials/distributing-packages/', |
| 130 | + 'Funding': 'https://donate.pypi.org', |
| 131 | + 'Wiki': 'https://github.com/Alinvor/Python-DeMo/wiki', |
| 132 | + 'Source': 'https://github.com/Alinvor/Python-DeMo' |
| 133 | +} |
| 134 | + |
| 135 | +setup( |
| 136 | + # This is the name of your project. The first time you publish this |
| 137 | + # package, this name will be registered for you. It will determine how |
| 138 | + # users can install this project, e.g.: |
| 139 | + # |
| 140 | + # $ pip install com.dvsnier.xxx |
| 141 | + # |
| 142 | + # And where it will live on PyPI: https://pypi.org/project/com.dvsnier.xxx/ |
| 143 | + # |
| 144 | + # There are some restrictions on what makes a valid project name |
| 145 | + # specification here: |
| 146 | + # https://packaging.python.org/specifications/core-metadata/#name |
| 147 | + name=DVSNIER_NAME, # Required |
| 148 | + |
| 149 | + # Versions should comply with PEP 440: |
| 150 | + # https://www.python.org/dev/peps/pep-0440/ |
| 151 | + # https://semver.org/lang/zh-CN/ |
| 152 | + # |
| 153 | + # 1.2.0.dev1 Development release |
| 154 | + # 1.2.0a1 Alpha Release |
| 155 | + # 1.2.0b1 Beta Release |
| 156 | + # 1.2.0rc1 Release Candidate |
| 157 | + # 1.2.0 Final Release |
| 158 | + # 1.2.0.post1 Post Release |
| 159 | + # 15.10 Date based release |
| 160 | + # 23 Serial release |
| 161 | + # |
| 162 | + # For a discussion on single-sourcing the version across setup.py and the |
| 163 | + # project code, see |
| 164 | + # https://packaging.python.org/en/latest/single_source_version.html |
| 165 | + version=DVSNIER_VERSION, # Required |
| 166 | + |
| 167 | + # This is a one-line description or tagline of what your project does. This |
| 168 | + # corresponds to the "Summary" metadata field: |
| 169 | + # https://packaging.python.org/specifications/core-metadata/#summary |
| 170 | + description=DVSNIER_DESCRIPTOIN, # Optional |
| 171 | + |
| 172 | + # This is an optional longer description of your project that represents |
| 173 | + # the body of text which users will see when they visit PyPI. |
| 174 | + # |
| 175 | + # Often, this is the same as your README, so you can just read it in from |
| 176 | + # that file directly (as we have already done above) |
| 177 | + # |
| 178 | + # This field corresponds to the "Description" metadata field: |
| 179 | + # https://packaging.python.org/specifications/core-metadata/#description-optional |
| 180 | + long_description=DVSNIER_LONG_DESCRIPTOIN, # Optional |
| 181 | + |
| 182 | + # Denotes that our long_description is in Markdown; valid values are |
| 183 | + # text/plain, text/x-rst, and text/markdown |
| 184 | + # |
| 185 | + # Optional if long_description is written in reStructuredText (rst) but |
| 186 | + # required for plain-text or Markdown; if unspecified, "applications should |
| 187 | + # attempt to render [the long_description] as text/x-rst; charset=UTF-8 and |
| 188 | + # fall back to text/plain if it is not valid rst" (see link below) |
| 189 | + # |
| 190 | + # This field corresponds to the "Description-Content-Type" metadata field: |
| 191 | + # https://packaging.python.org/specifications/core-metadata/#description-content-type-optional |
| 192 | + long_description_content_type=DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE, # Optional (see note above) |
| 193 | + |
| 194 | + # This should be a valid link to your project's main homepage. |
| 195 | + # |
| 196 | + # This field corresponds to the "Home-Page" metadata field: |
| 197 | + # https://packaging.python.org/specifications/core-metadata/#home-page-optional |
| 198 | + url=DVSNIER_URL, # Optional |
| 199 | + |
| 200 | + # This should be your name or the name of the organization which owns the project. |
| 201 | + author=DVSNIER_AUTHOR, # Optional |
| 202 | + |
| 203 | + # This should be a valid email address corresponding to the author listed above. |
| 204 | + author_email=DVSNIER_AUTHOR_EMAIL, # Optional |
| 205 | + |
| 206 | + # The license argument doesn’t have to indicate the license under which your package is being released, |
| 207 | + # although you may optionally do so if you want. If you’re using a standard, well-known license, then |
| 208 | + # your main indication can and should be via the classifiers argument. Classifiers exist for all major |
| 209 | + # open-source licenses. |
| 210 | + license=DVSNIER_LICENSE, # Optional |
| 211 | + |
| 212 | + # Classifiers help users find your project by categorizing it. |
| 213 | + # |
| 214 | + # For a list of valid classifiers, see https://pypi.org/classifiers/ |
| 215 | + classifiers=DVSNIER_CLASSIFIERS, # Optional |
| 216 | + |
| 217 | + # This field adds keywords for your project which will appear on the |
| 218 | + # project page. What does your project relate to? |
| 219 | + # |
| 220 | + # Note that this is a list of additional keywords, separated |
| 221 | + # by commas, to be used to assist searching for the distribution in a |
| 222 | + # larger catalog. |
| 223 | + keywords=DVSNIER_KEYWORDS, # Optional |
| 224 | + |
| 225 | + # When your source code is in a subdirectory under the project root, e.g. |
| 226 | + # `src/`, it is necessary to specify the `package_dir` argument. |
| 227 | + package_dir=DVSNIER_PACKAGE_DIR, # Optional |
| 228 | + |
| 229 | + # You can just specify package directories manually here if your project is |
| 230 | + # simple. Or you can use find_packages(). |
| 231 | + # |
| 232 | + # Alternatively, if you just want to distribute a single Python file, use |
| 233 | + # the `py_modules` argument instead as follows, which will expect a file |
| 234 | + # called `my_module.py` to exist: |
| 235 | + # |
| 236 | + # py_modules=["my_module"], |
| 237 | + # |
| 238 | + packages=DVSNIER_PACKAGES, # Required |
| 239 | + |
| 240 | + # |
| 241 | + # Only for Python 3.x and above |
| 242 | + # |
| 243 | + # namespace_packages=DVSNIER_NAMESPACE_PACKAGES, # Optional |
| 244 | + |
| 245 | + # If your project contains any single-file Python modules that aren’t part of |
| 246 | + # a package, set py_modules to a list of the names of the modules (minus the .py |
| 247 | + # extension) in order to make setuptools aware of them. |
| 248 | + # py_modules=DVSNIER_PY_MODULES, # Required |
| 249 | + |
| 250 | + # Specify which Python versions you support. In contrast to the |
| 251 | + # 'Programming Language' classifiers above, 'pip install' will check this |
| 252 | + # and refuse to install the project if the version does not match. See |
| 253 | + # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires |
| 254 | + python_requires=DVSNIER_PYTHON_REQUIRES, |
| 255 | + |
| 256 | + # This field lists other packages that your project depends on to run. |
| 257 | + # Any package you put here will be installed by pip when your project is |
| 258 | + # installed, so they must be valid existing projects. |
| 259 | + # |
| 260 | + # For an analysis of "install_requires" vs pip's requirements files see: |
| 261 | + # https://packaging.python.org/en/latest/requirements.html |
| 262 | + # https://packaging.python.org/discussions/install-requires-vs-requirements/ |
| 263 | + install_requires=DVSNIER_INSTALL_REQUIRES, # Optional |
| 264 | + |
| 265 | + # List additional groups of dependencies here (e.g. development |
| 266 | + # dependencies). Users will be able to install these using the "extras" |
| 267 | + # syntax, for example: |
| 268 | + # |
| 269 | + # $ pip install sampleproject[dev] |
| 270 | + # |
| 271 | + # Similar to `install_requires` above, these must be valid existing projects. |
| 272 | + extras_require=DVSNIER_EXTRAS_REQUIRE, # Optional |
| 273 | + |
| 274 | + # If there are data files included in your packages that need to be |
| 275 | + # installed, specify them here. |
| 276 | + # https://setuptools.readthedocs.io/en/latest/userguide/datafiles.html |
| 277 | + package_data=DVSNIER_PACKAGE_DATA, # Optional |
| 278 | + |
| 279 | + # Although 'package_data' is the preferred approach, in some case you may |
| 280 | + # need to place data files outside of your packages. See: |
| 281 | + # http://docs.python.org/distutils/setupscript.html#installing-additional-files |
| 282 | + # http://docs.python.org/3/distutils/setupscript.html#installing-additional-files |
| 283 | + # |
| 284 | + # In this case, 'data_file' will be installed into '<sys.prefix>/my_data' |
| 285 | + data_files=DVSNIER_DATA_FILES, # Optional |
| 286 | + |
| 287 | + # To provide executable scripts, use entry points in preference to the |
| 288 | + # "scripts" keyword. Entry points provide cross-platform support and allow |
| 289 | + # `pip` to create the appropriate form of executable for the target |
| 290 | + # platform. |
| 291 | + # |
| 292 | + # For example, the following would provide a command called `dvsnier` which |
| 293 | + # executes the function `main` from this package when invoked: |
| 294 | + entry_points=DVSNIER_ENTRY_POINTS, # Optional |
| 295 | + |
| 296 | + # |
| 297 | + # 1. https://www.python.org/dev/peps/pep-0328/ |
| 298 | + # 2. https://setuptools.readthedocs.io/en/latest/userguide/package_discovery.html |
| 299 | + # 3. https://packaging.python.org/guides/packaging-namespace-packages/ |
| 300 | + # 4. https://github.com/pypa/sample-namespace-packages/tree/master/pkgutil |
| 301 | + # |
| 302 | + zip_safe=False, |
| 303 | + |
| 304 | + # List additional URLs that are relevant to your project as a dict. |
| 305 | + # |
| 306 | + # This field corresponds to the "Project-URL" metadata fields: |
| 307 | + # https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use |
| 308 | + # |
| 309 | + # Examples listed include a pattern for specifying where the package tracks |
| 310 | + # issues, where the source is hosted, where to say thanks to the package |
| 311 | + # maintainers, and where to support the project financially. The key is |
| 312 | + # what's used to render the link text on PyPI. |
| 313 | + project_urls=DVSNIER_PROJECT_URLS, # Optional |
| 314 | +) |
0 commit comments