|
35 | 35 | - [5.2.2 MANIFEST.in](#522-manifestin) |
36 | 36 | - [5.2.3 tox.ini](#523-toxini) |
37 | 37 | - [5.2.4 setup.cfg](#524-setupcfg) |
38 | | - - [5.2.5 README.md](#525-readmemd) |
| 38 | + - [5.2.5 setup.py](#525-setuppy) |
| 39 | + - [5.2.6 README.md](#526-readmemd) |
39 | 40 | - [5.3 构建](#53-构建) |
40 | 41 | - [5.3.1 tox 脚本测试](#531-tox-脚本测试) |
41 | 42 | - [5.3.2 build](#532-build) |
@@ -469,14 +470,14 @@ commands = |
469 | 470 | # 1. https://setuptools.readthedocs.io/en/latest/ |
470 | 471 | # 2. https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html |
471 | 472 | # 3. https://setuptools.readthedocs.io/en/latest/references/keywords.html |
472 | | -name = com.dvsnier.directory |
| 473 | +name = com.dvsnier.xxx |
473 | 474 | version = 0.0.1.dev1 |
474 | 475 | author = dvsnier |
475 | 476 | author_email = dovsnier@qq.com |
476 | 477 | description = this is dvsnier directory. |
477 | 478 | long_description = file: ./doc/description/directory/README.md |
478 | 479 | long_description_content_type = text/markdown |
479 | | -keywords = dir, development |
| 480 | +keywords = xxx, development |
480 | 481 | url = https://github.com/Alinvor/Python-DeMo |
481 | 482 | project_urls = |
482 | 483 | Documentation = https://packaging.python.org/tutorials/distributing-packages/ |
@@ -527,7 +528,321 @@ universal = 1 |
527 | 528 |
|
528 | 529 | 实际项目中, 可依据如上配置信息稍加修改和增添; |
529 | 530 |
|
530 | | -#### 5.2.5 README.md |
| 531 | +#### 5.2.5 setup.py |
| 532 | + |
| 533 | +最后配置 `setup.py` 构建脚本, 指定软件包所要构建的软件细节部分, 举例配置信息如下: |
| 534 | + |
| 535 | +```bash |
| 536 | +# -*- coding:utf-8 -*- |
| 537 | +"""A setuptools based setup module. |
| 538 | +
|
| 539 | +See: |
| 540 | +https://packaging.python.org/guides/distributing-packages-using-setuptools/ |
| 541 | +https://github.com/Alinvor/Python-DeMo |
| 542 | +""" |
| 543 | + |
| 544 | +# Always prefer setuptools over distutils |
| 545 | +from setuptools import setup, find_packages |
| 546 | +import os |
| 547 | +import sys |
| 548 | + |
| 549 | + |
| 550 | +def read_text(file_name): |
| 551 | + ''' the read describe readme files content. ''' |
| 552 | + content = '' |
| 553 | + with open(file_name, 'r') as file: |
| 554 | + lines = file.readlines() |
| 555 | + for line in lines: |
| 556 | + if sys.version_info.major > 2: |
| 557 | + content += str(line) |
| 558 | + else: |
| 559 | + content += str(line).encode('utf-8') |
| 560 | + # print(content) |
| 561 | + return content |
| 562 | +# |
| 563 | +# the repaired your home name |
| 564 | +# |
| 565 | +PROJECT_PREFIX = '/Users/.../Python-DeMo/' |
| 566 | +project = PROJECT_PREFIX |
| 567 | +print(project) |
| 568 | +PROJECT_DIRECTORY = 'directory' # project directory |
| 569 | +PROJECT_README_FILE = 'README.md' # project readme file |
| 570 | +README_ROOT_DIRECTORY = os.path.join(project, 'doc/description') |
| 571 | +README_PROJECT_DIRECTORY = os.path.join(README_ROOT_DIRECTORY, PROJECT_DIRECTORY) |
| 572 | +PROJECT_DESCRIPTION = os.path.join(README_PROJECT_DIRECTORY, PROJECT_README_FILE) |
| 573 | +# |
| 574 | +# Arguments marked as "Required" below must be included for upload to PyPI. |
| 575 | +# Fields marked as "Optional" may be commented out. |
| 576 | +# |
| 577 | +# | 序列 | 字段 | 数据类型 | 选项 | 描述 | 备注 | |
| 578 | +# | :---: | :-----------------------------------: | :---------: | :---: | -------------------- | ---- | |
| 579 | +# | 1 | DVSNIER_NAME | string | Y | 包名称 | | |
| 580 | +# | 2 | DVSNIER_VERSION | string | Y | 包版本 | | |
| 581 | +# | 3 | DVSNIER_DESCRIPTOIN | string | | 包简单描述 | | |
| 582 | +# | 4 | DVSNIER_LONG_DESCRIPTOIN | file | | 较长文档描述 | | |
| 583 | +# | 5 | DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE | string | | 长文本类型描述 | | |
| 584 | +# | 6 | DVSNIER_URL | http | | 项目主页 | | |
| 585 | +# | 7 | DVSNIER_AUTHOR | string | | 项目作者 | | |
| 586 | +# | 8 | DVSNIER_AUTHOR_EMAIL | email | | 项目作者邮箱 | | |
| 587 | +# | 9 | DVSNIER_LICENSE | 许可证 | | 许可证 | | |
| 588 | +# | 10 | DVSNIER_CLASSIFIERS | classifiers | | 项目分类器 | | |
| 589 | +# | 11 | DVSNIER_KEYWORDS | keywords | | 项目关键字 | | |
| 590 | +# | 12 | DVSNIER_PACKAGE_DIR | string | | 包目录 | | |
| 591 | +# | 13 | DVSNIER_PY_MODULES | string | Y | 模块名称 | | |
| 592 | +# | 14 | DVSNIER_PACKAGES | string | Y | 包名称 | | |
| 593 | +# | 15 | DVSNIER_PYTHON_REQUIRES | string | Y | 版本匹配分类器描述符 | | |
| 594 | +# | 16 | DVSNIER_INSTALL_REQUIRES | list | | 依赖库 | | |
| 595 | +# | 17 | DVSNIER_EXTRAS_REQUIRE | dict | | 附加/扩展依赖 | | |
| 596 | +# | 18 | DVSNIER_PACKAGE_DATA | dict | | 包数据文件 | | |
| 597 | +# | 19 | DVSNIER_DATA_FILES | list | | 包外数据文件 | | |
| 598 | +# | 20 | DVSNIER_ENTRY_POINTS | dict | | 入口点 | | |
| 599 | +# | 21 | DVSNIER_PROJECT_URLS | dict | | 项目 URL | | |
| 600 | +# | 22 | | | | | | |
| 601 | +DVSNIER_NAME = 'com.dvsnier.xxx' # Required |
| 602 | +DVSNIER_VERSION = '0.0.1.dev1' # Required |
| 603 | +DVSNIER_DESCRIPTOIN = 'this is dvsnier directory.' # Optional |
| 604 | +# Get the long description from the README file |
| 605 | +DVSNIER_LONG_DESCRIPTOIN = read_text(str(PROJECT_DESCRIPTION)) # Optional |
| 606 | +DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE = 'text/markdown' # Optional |
| 607 | +DVSNIER_URL = 'https://github.com/Alinvor/Python-DeMo' # Optional |
| 608 | +DVSNIER_AUTHOR = 'dvsnier' # Optional |
| 609 | +DVSNIER_AUTHOR_EMAIL = 'dovsnier@qq.com' # Optional |
| 610 | +DVSNIER_LICENSE = 'MIT' # Optional |
| 611 | +DVSNIER_CLASSIFIERS = [ # Optional |
| 612 | + # How mature is this project? Common values are |
| 613 | + # 3 - Alpha |
| 614 | + # 4 - Beta |
| 615 | + # 5 - Production/Stable |
| 616 | + 'Development Status :: 3 - Alpha', |
| 617 | + |
| 618 | + # Indicate who your project is intended for |
| 619 | + # 'Intended Audience :: Developers', |
| 620 | + # 'Topic :: Software Development :: Build Tools', |
| 621 | + |
| 622 | + # Pick your license as you wish |
| 623 | + 'License :: OSI Approved :: MIT License', |
| 624 | + |
| 625 | + # Specify the Python versions you support here. In particular, ensure |
| 626 | + # that you indicate you support Python 3. These classifiers are *not* |
| 627 | + # checked by 'pip install'. See instead 'python_requires' below. |
| 628 | + 'Programming Language :: Python :: 2.7', |
| 629 | + 'Programming Language :: Python :: 3.8', |
| 630 | + 'Programming Language :: Python :: 3.9', |
| 631 | + # 'Programming Language :: Python :: 3 :: Only', |
| 632 | + 'Operating System :: OS Independent' |
| 633 | +] |
| 634 | +DVSNIER_KEYWORDS = 'xxx, development' # Optional |
| 635 | +DVSNIER_PACKAGE_DIR = {'': 'src'} # Optional |
| 636 | +# DVSNIER_PY_MODULES = ["xxx"] # Required |
| 637 | +# DVSNIER_PACKAGES = find_packages(include=['xxx', 'xxx.*']) # Required |
| 638 | +DVSNIER_PACKAGES = find_packages(where='src') # Required |
| 639 | +# DVSNIER_PYTHON_REQUIRES = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*' |
| 640 | +DVSNIER_PYTHON_REQUIRES = '>=2.7, <4' |
| 641 | +DVSNIER_INSTALL_REQUIRES = [ # Optional |
| 642 | + # 'discover==0.4.0', |
| 643 | + # 'build==0.4.0', |
| 644 | + # 'pathlib2==2.3.5', |
| 645 | + # 'toml==0.10.2', |
| 646 | + # 'twine==1.15.0', |
| 647 | +] |
| 648 | +DVSNIER_EXTRAS_REQUIRE = { # Optional |
| 649 | + 'dev': ['check-manifest'], |
| 650 | + 'test': ['coverage'] |
| 651 | +} |
| 652 | +DVSNIER_PACKAGE_DATA = { # Optional |
| 653 | + # 'sample': ['package_data.dat'], |
| 654 | +} |
| 655 | +DVSNIER_DATA_FILES = [ # Optional |
| 656 | + # ('my_data', ['data/data_file']) |
| 657 | +] |
| 658 | +DVSNIER_ENTRY_POINTS = { # Optional |
| 659 | + # 'console_scripts': [ |
| 660 | + # 'dvs-dir=dvs:main', |
| 661 | + # ], |
| 662 | +} |
| 663 | +DVSNIER_PROJECT_URLS = { # Optional |
| 664 | + 'Bug_Tracker': 'https://github.com/Alinvor/Python-DeMo/issues', |
| 665 | + 'Documentation': 'https://packaging.python.org/tutorials/distributing-packages/', |
| 666 | + 'Funding': 'https://donate.pypi.org', |
| 667 | + 'Wiki': 'https://github.com/Alinvor/Python-DeMo/wiki', |
| 668 | + 'Source': 'https://github.com/Alinvor/Python-DeMo' |
| 669 | +} |
| 670 | + |
| 671 | +setup( |
| 672 | + # This is the name of your project. The first time you publish this |
| 673 | + # package, this name will be registered for you. It will determine how |
| 674 | + # users can install this project, e.g.: |
| 675 | + # |
| 676 | + # $ pip install com.dvsnier.xxx |
| 677 | + # |
| 678 | + # And where it will live on PyPI: https://pypi.org/project/com.dvsnier.xxx/ |
| 679 | + # |
| 680 | + # There are some restrictions on what makes a valid project name |
| 681 | + # specification here: |
| 682 | + # https://packaging.python.org/specifications/core-metadata/#name |
| 683 | + name=DVSNIER_NAME, # Required |
| 684 | + |
| 685 | + # Versions should comply with PEP 440: |
| 686 | + # https://www.python.org/dev/peps/pep-0440/ |
| 687 | + # https://semver.org/lang/zh-CN/ |
| 688 | + # |
| 689 | + # 1.2.0.dev1 Development release |
| 690 | + # 1.2.0a1 Alpha Release |
| 691 | + # 1.2.0b1 Beta Release |
| 692 | + # 1.2.0rc1 Release Candidate |
| 693 | + # 1.2.0 Final Release |
| 694 | + # 1.2.0.post1 Post Release |
| 695 | + # 15.10 Date based release |
| 696 | + # 23 Serial release |
| 697 | + # |
| 698 | + # For a discussion on single-sourcing the version across setup.py and the |
| 699 | + # project code, see |
| 700 | + # https://packaging.python.org/en/latest/single_source_version.html |
| 701 | + version=DVSNIER_VERSION, # Required |
| 702 | + |
| 703 | + # This is a one-line description or tagline of what your project does. This |
| 704 | + # corresponds to the "Summary" metadata field: |
| 705 | + # https://packaging.python.org/specifications/core-metadata/#summary |
| 706 | + description=DVSNIER_DESCRIPTOIN, # Optional |
| 707 | + |
| 708 | + # This is an optional longer description of your project that represents |
| 709 | + # the body of text which users will see when they visit PyPI. |
| 710 | + # |
| 711 | + # Often, this is the same as your README, so you can just read it in from |
| 712 | + # that file directly (as we have already done above) |
| 713 | + # |
| 714 | + # This field corresponds to the "Description" metadata field: |
| 715 | + # https://packaging.python.org/specifications/core-metadata/#description-optional |
| 716 | + long_description=DVSNIER_LONG_DESCRIPTOIN, # Optional |
| 717 | + |
| 718 | + # Denotes that our long_description is in Markdown; valid values are |
| 719 | + # text/plain, text/x-rst, and text/markdown |
| 720 | + # |
| 721 | + # Optional if long_description is written in reStructuredText (rst) but |
| 722 | + # required for plain-text or Markdown; if unspecified, "applications should |
| 723 | + # attempt to render [the long_description] as text/x-rst; charset=UTF-8 and |
| 724 | + # fall back to text/plain if it is not valid rst" (see link below) |
| 725 | + # |
| 726 | + # This field corresponds to the "Description-Content-Type" metadata field: |
| 727 | + # https://packaging.python.org/specifications/core-metadata/#description-content-type-optional |
| 728 | + long_description_content_type=DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE, # Optional (see note above) |
| 729 | + |
| 730 | + # This should be a valid link to your project's main homepage. |
| 731 | + # |
| 732 | + # This field corresponds to the "Home-Page" metadata field: |
| 733 | + # https://packaging.python.org/specifications/core-metadata/#home-page-optional |
| 734 | + url=DVSNIER_URL, # Optional |
| 735 | + |
| 736 | + # This should be your name or the name of the organization which owns the project. |
| 737 | + author=DVSNIER_AUTHOR, # Optional |
| 738 | + |
| 739 | + # This should be a valid email address corresponding to the author listed above. |
| 740 | + author_email=DVSNIER_AUTHOR_EMAIL, # Optional |
| 741 | + |
| 742 | + # The license argument doesn’t have to indicate the license under which your package is being released, |
| 743 | + # although you may optionally do so if you want. If you’re using a standard, well-known license, then |
| 744 | + # your main indication can and should be via the classifiers argument. Classifiers exist for all major |
| 745 | + # open-source licenses. |
| 746 | + license=DVSNIER_LICENSE, # Optional |
| 747 | + |
| 748 | + # Classifiers help users find your project by categorizing it. |
| 749 | + # |
| 750 | + # For a list of valid classifiers, see https://pypi.org/classifiers/ |
| 751 | + classifiers=DVSNIER_CLASSIFIERS, # Optional |
| 752 | + |
| 753 | + # This field adds keywords for your project which will appear on the |
| 754 | + # project page. What does your project relate to? |
| 755 | + # |
| 756 | + # Note that this is a list of additional keywords, separated |
| 757 | + # by commas, to be used to assist searching for the distribution in a |
| 758 | + # larger catalog. |
| 759 | + keywords=DVSNIER_KEYWORDS, # Optional |
| 760 | + |
| 761 | + # When your source code is in a subdirectory under the project root, e.g. |
| 762 | + # `src/`, it is necessary to specify the `package_dir` argument. |
| 763 | + package_dir=DVSNIER_PACKAGE_DIR, # Optional |
| 764 | + |
| 765 | + # You can just specify package directories manually here if your project is |
| 766 | + # simple. Or you can use find_packages(). |
| 767 | + # |
| 768 | + # Alternatively, if you just want to distribute a single Python file, use |
| 769 | + # the `py_modules` argument instead as follows, which will expect a file |
| 770 | + # called `my_module.py` to exist: |
| 771 | + # |
| 772 | + # py_modules=["my_module"], |
| 773 | + # |
| 774 | + packages=DVSNIER_PACKAGES, # Required |
| 775 | + |
| 776 | + # If your project contains any single-file Python modules that aren’t part of |
| 777 | + # a package, set py_modules to a list of the names of the modules (minus the .py |
| 778 | + # extension) in order to make setuptools aware of them. |
| 779 | + # py_modules=DVSNIER_PY_MODULES, # Required |
| 780 | + |
| 781 | + # Specify which Python versions you support. In contrast to the |
| 782 | + # 'Programming Language' classifiers above, 'pip install' will check this |
| 783 | + # and refuse to install the project if the version does not match. See |
| 784 | + # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires |
| 785 | + python_requires=DVSNIER_PYTHON_REQUIRES, |
| 786 | + |
| 787 | + # This field lists other packages that your project depends on to run. |
| 788 | + # Any package you put here will be installed by pip when your project is |
| 789 | + # installed, so they must be valid existing projects. |
| 790 | + # |
| 791 | + # For an analysis of "install_requires" vs pip's requirements files see: |
| 792 | + # https://packaging.python.org/en/latest/requirements.html |
| 793 | + # https://packaging.python.org/discussions/install-requires-vs-requirements/ |
| 794 | + install_requires=DVSNIER_INSTALL_REQUIRES, # Optional |
| 795 | + |
| 796 | + # List additional groups of dependencies here (e.g. development |
| 797 | + # dependencies). Users will be able to install these using the "extras" |
| 798 | + # syntax, for example: |
| 799 | + # |
| 800 | + # $ pip install sampleproject[dev] |
| 801 | + # |
| 802 | + # Similar to `install_requires` above, these must be valid existing projects. |
| 803 | + extras_require=DVSNIER_EXTRAS_REQUIRE, # Optional |
| 804 | + |
| 805 | + # If there are data files included in your packages that need to be |
| 806 | + # installed, specify them here. |
| 807 | + # https://setuptools.readthedocs.io/en/latest/userguide/datafiles.html |
| 808 | + package_data=DVSNIER_PACKAGE_DATA, # Optional |
| 809 | + |
| 810 | + # Although 'package_data' is the preferred approach, in some case you may |
| 811 | + # need to place data files outside of your packages. See: |
| 812 | + # http://docs.python.org/distutils/setupscript.html#installing-additional-files |
| 813 | + # http://docs.python.org/3/distutils/setupscript.html#installing-additional-files |
| 814 | + # |
| 815 | + # In this case, 'data_file' will be installed into '<sys.prefix>/my_data' |
| 816 | + data_files=DVSNIER_DATA_FILES, # Optional |
| 817 | + |
| 818 | + # To provide executable scripts, use entry points in preference to the |
| 819 | + # "scripts" keyword. Entry points provide cross-platform support and allow |
| 820 | + # `pip` to create the appropriate form of executable for the target |
| 821 | + # platform. |
| 822 | + # |
| 823 | + # For example, the following would provide a command called `dvsnier` which |
| 824 | + # executes the function `main` from this package when invoked: |
| 825 | + entry_points=DVSNIER_ENTRY_POINTS, # Optional |
| 826 | + |
| 827 | + # List additional URLs that are relevant to your project as a dict. |
| 828 | + # |
| 829 | + # This field corresponds to the "Project-URL" metadata fields: |
| 830 | + # https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use |
| 831 | + # |
| 832 | + # Examples listed include a pattern for specifying where the package tracks |
| 833 | + # issues, where the source is hosted, where to say thanks to the package |
| 834 | + # maintainers, and where to support the project financially. The key is |
| 835 | + # what's used to render the link text on PyPI. |
| 836 | + project_urls=DVSNIER_PROJECT_URLS, # Optional |
| 837 | +) |
| 838 | + |
| 839 | +``` |
| 840 | +
|
| 841 | +> 软件包`名称`和软件包`版本`信息, 一定要明确具体发布规则; |
| 842 | +
|
| 843 | +实际项目中, 可依据如上配置信息稍加修改和增添; |
| 844 | +
|
| 845 | +#### 5.2.6 README.md |
531 | 846 |
|
532 | 847 | 更新`README.md` 版本和摘要信息; |
533 | 848 |
|
|
0 commit comments