一个用于在本地机器中定位 Ansys 产品的库。
提供了两种安装模式:用户模式和开发者模式。
用户模式
要安装 ansys-tools-path
,请确保已安装最新版本的 pip 。为此,请运行
python -m pip install -U pip
然后,您可以简单地执行:
python -m pip install ansys-tools-path
开发者模式
在开发者模式下安装 ansys-tools-path
可以修改源代码并对其进行增强。
在为该项目做出贡献之前,请参考 PyAnsys Developer's guide 。您需要遵循以下步骤:
首先克隆该版本库:
git clone https://github.com/ansys/ansys-tools-path
创建一个全新的 Python 环境并激活它:
# 创建虚拟环境 python -m venv .venv # 在 POSIX 系统中激活 source .venv/bin/activate # 在 Windows CMD 环境中激活 .venv\Scripts\activate.bat # 在 Windows Powershell 中激活 .venv\Scripts\Activate.ps1
确保拥有最新的所需构建系统、文档、测试和 CI 工具:
python -m pip install .[tests] python -m pip install .[doc] python -m pip install .[build]
以可编辑模式安装项目:
python -m pip install --editable ansys-tools-path
如何测试
如果需要,您可以随时从命令行调用样式命令( black 、 isort 、 flake8 ...)或单元测试命令( pytest )。 不过,这并不能保证你的项目是在一个隔离的环境中进行测试的,这也是 tox 等工具存在的原因。
样式检查利用了 pre-commit 。我们不强制但鼓励开发人员通过以下方式安装该工具:
python -m pip install pre-commit && pre-commit install
在构建文档时,您可以运行 Sphinx Makefile 中提供的常规规则,例如:
make -C doc/ html && your_browser_name doc/html/index.html
make -C doc/ html
:这个命令在 doc/ 目录下执行 make html 命令。make 是一个构建工具,它根据 Makefile 文件中的规则来构建项目。在这个例子中,make html 通常用于从 reStructuredText 文件生成 HTML 文档。&&
:这是一个 shell 命令连接符,它表示只有当前面的命令成功执行后,才会执行后面的命令。your_browser_name doc/html/index.html
:这个命令会在你的浏览器中打开 doc/html/index.html 文件。你需要将 your_browser_name 替换为你的浏览器的命令行名称,例如 firefox、chrome 等。
如果要创建源文件或 wheel 文件,首先要安装 building requirements ,然后执行构建模块:
python -m pip install .[build]
python -m build
python -m twine check dist/*