Skip to content

Commit 5110fe9

Browse files
author
zhenwei-li
committed
添加 git 打包脚本
1 parent 8540ddd commit 5110fe9

1 file changed

Lines changed: 305 additions & 0 deletions

File tree

setup.py

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

0 commit comments

Comments
 (0)