Typed Argument Parser 项目教程
项目的目录结构及介绍
typed-argument-parser/
├── docs/
│ ├── ...
│ └── ...
├── examples/
│ ├── ...
│ └── ...
├── src/
│ ├── tap/
│ │ ├── ...
│ │ └── ...
│ └── ...
├── tests/
│ ├── ...
│ └── ...
├── .gitignore
├── LICENSE
├── README.md
├── setup.py
└── ...
- docs/: 包含项目的文档文件。
- examples/: 包含使用示例代码。
- src/tap/: 包含项目的主要源代码。
- tests/: 包含测试代码。
- .gitignore: Git 忽略文件配置。
- LICENSE: 项目许可证。
- README.md: 项目介绍和使用说明。
- setup.py: 项目安装脚本。
项目的启动文件介绍
项目的启动文件通常是 setup.py
,它负责项目的安装和配置。以下是 setup.py
的基本内容:
from setuptools import setup, find_packages
setup(
name='typed-argument-parser',
version='1.10.1',
description='A typed modernization of Python\'s argparse library',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Jesse Michel and Kyle',
author_email='example@example.com',
url='https://github.com/swansonk14/typed-argument-parser',
packages=find_packages(where='src'),
package_dir={'': 'src'},
install_requires=[
# 依赖列表
],
classifiers=[
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
)
项目的配置文件介绍
项目的配置文件通常是 setup.py
和 .gitignore
。setup.py
已经在上一部分介绍过,下面是 .gitignore
的基本内容:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-