首页
/ mmh3 项目使用教程

mmh3 项目使用教程

2024-08-19 14:31:21作者:董宙帆

1. 项目的目录结构及介绍

mmh3 项目的目录结构如下:

mmh3/
├── docs/
├── src/
│   └── mmh3/
├── tests/
├── util/
├── .clang-format
├── .gitignore
├── .gitmodules
├── .readthedocs.yaml
├── LICENSE
├── MANIFEST.in
├── README.md
├── pyproject.toml
└── setup.py

目录介绍

  • docs/: 存放项目文档的目录。
  • src/mmh3/: 存放 mmh3 源代码的目录。
  • tests/: 存放测试文件的目录。
  • util/: 存放工具文件的目录。
  • .clang-format: 用于代码格式化的配置文件。
  • .gitignore: 指定 Git 忽略的文件和目录。
  • .gitmodules: 用于管理子模块的配置文件。
  • .readthedocs.yaml: 用于配置 Read the Docs 的文件。
  • LICENSE: 项目的许可证文件。
  • MANIFEST.in: 指定打包时包含的文件。
  • README.md: 项目说明文件。
  • pyproject.toml: 项目配置文件,用于构建工具。
  • setup.py: 用于安装和打包项目的脚本。

2. 项目的启动文件介绍

mmh3 项目的启动文件主要是 setup.py。这个文件用于安装和打包项目。以下是 setup.py 的主要内容:

from setuptools import setup, Extension

module1 = Extension('mmh3',
                    sources = ['src/mmh3.cpp'],
                    include_dirs = ['src'],
                    extra_compile_args=['-std=c++11'])

setup(name = 'mmh3',
      version = '3.0.0',
      description = 'Python wrapper for MurmurHash (MurmurHash3)',
      ext_modules = [module1],
      author='Hajime Senuma',
      author_email='hajime.senuma@gmail.com',
      url='https://github.com/hajimes/mmh3',
      license='MIT',
      classifiers=[
          'Development Status :: 5 - Production/Stable',
          'Intended Audience :: Developers',
          'License :: OSI Approved :: MIT License',
          'Programming Language :: Python :: 3',
          'Programming Language :: Python :: 3.8',
          'Programming Language :: Python :: 3.9',
          'Programming Language :: Python :: 3.10',
          'Programming Language :: Python :: 3.11',
          'Programming Language :: Python :: 3.12',
          'Topic :: Software Development :: Libraries :: Python Modules',
      ],
      python_requires='>=3.8',
      )

启动文件介绍

  • setup.py: 这个文件定义了如何安装和打包 mmh3 项目。它包含了项目的名称、版本、描述、作者、许可证等信息,并且定义了扩展模块 mmh3 的源文件和编译选项。

3. 项目的配置文件介绍

mmh3 项目的配置文件主要是 pyproject.toml.readthedocs.yaml

pyproject.toml

pyproject.toml 文件用于配置构建工具。以下是 pyproject.toml 的主要内容:

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

.readthedocs.yaml

.readthedocs.yaml 文件用于配置 Read the Docs。以下是 .readthedocs.yaml 的主要内容:

version: 2

build:
  os: ubuntu-20.04
  tools:
    python: "3.8"

python:
  install:
    - method: pip
      path: .
    - requirements: docs/requirements.txt

配置文件介绍

  • pyproject.toml: 这个文件定义了构建系统所需的工具和后端。它指定了 setuptoolswheel 作为构建工具,并使用 setuptools.build_meta 作为构建后端
登录后查看全文
热门项目推荐