gdstk 开源项目教程

随笔3周前发布 小眼睛
47 0 0

gdstk 开源项目教程

gdstkGdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.项目地址:https://gitcode.com/gh_mirrors/gd/gdstk

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

gdstk 是一个用于处理 GDSII 文件的 Python 库。以下是该项目的目录结构及其简要介绍:

  1. gdstk/

  2. ├── docs/

  3. │ ├── conf.py

  4. │ ├── index.rst

  5. │ └── ...

  6. ├── examples/

  7. │ ├── example1.py

  8. │ ├── example2.py

  9. │ └── ...

  10. ├── gdstk/

  11. │ ├── __init__.py

  12. │ ├── lib/

  13. │ │ └── ...

  14. │ ├── polygon.py

  15. │ ├── cell.py

  16. │ └── ...

  17. ├── tests/

  18. │ ├── test_polygon.py

  19. │ ├── test_cell.py

  20. │ └── ...

  21. ├── .gitignore

  22. ├── LICENSE

  23. ├── README.md

  24. ├── setup.py

  25. └── ...

  • docs/: 包含项目文档的配置文件和源文件。
  • examples/: 包含示例代码,展示如何使用 gdstk 库。
  • gdstk/: 核心代码目录,包含库的主要实现文件。
  • tests/: 包含测试代码,用于验证库的功能。
  • .gitignore: Git 忽略文件列表。
  • LICENSE: 项目许可证。
  • README.md: 项目介绍和使用说明。
  • setup.py: 用于安装和分发项目的脚本。

2. 项目的启动文件介绍

gdstk 项目的启动文件是 gdstk/__init__.py。这个文件初始化库并导入必要的模块,使得用户可以通过 import gdstk 来使用库。

  1. # gdstk/__init__.py

  2. from .polygon import *

  3. from .cell import *

  4. from .library import *

  5. from .rawcell import *

  6. from .flexpath import *

  7. from .robustpath import *

  8. from .curve import *

  9. from .utils import *

  10. __version__ = "0.8.2"

3. 项目的配置文件介绍

gdstk 项目的配置文件主要用于文档生成和项目安装。以下是两个重要的配置文件:

setup.py

setup.py 文件用于安装和分发项目。它定义了项目的元数据和依赖项。

  1. # setup.py

  2. from setuptools import setup, Extension

  3. from pathlib import Path

  4. def get_version():

  5. with open(Path(__file__).parent / "gdstk" / "__init__.py") as f:

  6. for line in f:

  7. if line.startswith("__version__"):

  8. return line.split('"')[1]

  9. setup(

  10. name="gdstk",

  11. version=get_version(),

  12. author="Lucas Heitzmann Gabrielli",

  13. author_email="heitzmann@gmail.com",

  14. description="GDSII manipulation toolkit",

  15. long_description=Path("README.md").read_text(),

  16. long_description_content_type="text/markdown",

  17. url="https://github.com/heitzmann/gdstk",

  18. packages=["gdstk"],

  19. ext_modules=[Extension("gdstk._gdstk", ["gdstk/gdstk.c"], include_dirs=["gdstk"])],

  20. classifiers=[

  21. "Programming Language :: Python :: 3",

  22. "License :: OSI Approved :: MIT License",

  23. "Operating System :: OS Independent",

  24. ],

  25. python_requires='>=3.6',

  26. )

docs/conf.py

docs/conf.py 文件用于配置 Sphinx 文档生成工具。它定义了文档的构建选项和扩展。

  1. # docs/conf.py

  2. import os

  3. import sys

  4. sys.path.insert(0, os.path.abspath('..'))

  5. project = 'gdstk'

  6. copyright = '2021, Lucas Heitzmann Gabrielli'

  7. author = 'Lucas Heitzmann Gabrielli'

  8. extensions = [

  9. 'sphinx.ext.autodoc',

  10. 'sphinx.ext.viewcode',

  11. 'sphinx.ext.napoleon'

  12. ]

  13. templates_path = ['_templates']

  14. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

  15. html_theme = 'alabaster'

  16. html_static_path = ['

gdstkGdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.项目地址:https://gitcode.com/gh_mirrors/gd/gdstk

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...