1
- .. ref_project_structure : :
1
+ .. _ ref_project_structure :
2
2
3
3
#################
4
4
Project Structure
5
5
#################
6
6
7
7
Most of the projects in the PyAnsys ecosystem ship in the form of a Python
8
- package. This is the formal way of distributing Python-based projects.
8
+ library with other additional files. All these files form what it is called a
9
+ "project". A project can be uploaded to a repository to better track the changes
10
+ applied to it. The high-level structure of a PyAnsys project is exposed in
11
+ figure :numref: `high level pyansys structure `.
9
12
10
- The guide presented in this page is compliant with the `Python Packaging
11
- Authority `_ and `PyAnsys `_ recommendations.
13
+ .. include :: diagrams/ansys_project_diagram.rst
14
+
15
+ Python Libraries
16
+ ================
17
+
18
+ A Python library is the formal way of distributing Python source code. It allows
19
+ to reuse and specify Python code dependencies. The guide presented in this page
20
+ is compliant with the `Python Packaging Authority `_ and PyAnsys recommendations.
12
21
13
22
.. note ::
14
23
@@ -17,9 +26,43 @@ Authority`_ and `PyAnsys`_ recommendations.
17
26
PyAnsys guidelines are built on top of PyPA guidelines.
18
27
19
28
20
- .. TODO: Explain the difference between Package and Library?
21
- Package: only holds modules
22
- Library: a collection of packages
29
+ Scripts, Modules, Sub-packages, and Packages
30
+ --------------------------------------------
31
+
32
+ To understand the structure of a Python Library, it is important to know
33
+ the difference between Python scripts, modules, sub-packages, and packages.
34
+ Figure :numref: `python elements diagram ` provides a graphical interpretation.
35
+
36
+ * ``Script ``: Any Python file with logic source code.
37
+ * ``Module ``: Any Python script hosted next to an ``__init__.py `` file.
38
+ * ``Sub-package ``: Any directory containing various Python modules.
39
+ * ``Package ``: Any directory containing Python modules and sub-packages.
40
+
41
+ .. include :: diagrams/python_elements_diagram.rst
42
+
43
+
44
+ Differences Between a Python Package and Library
45
+ ------------------------------------------------
46
+
47
+ Although both terms are used interchangeably, there is a key difference between
48
+ them: a Python package is a collection of Python modules and sub-packages while
49
+ a Python Library is a collection of Python packages. Figure :numref: `python pkg
50
+ lib diagram` exposes this.
51
+
52
+ .. include :: diagrams/python_pkg_lib_diagram.rst
53
+
54
+
55
+ Other Files
56
+ ===========
57
+
58
+ Additional files can be stored next to a Python Library. These files will not be
59
+ included when distributing the library. Most of these files are metadata, tool
60
+ configuration files, and CI workflows definitions.
61
+
62
+ .. tip ::
63
+
64
+ Avoid having lots of additional files. This reduces mainteinance tasks and
65
+ provides a clean root project directory.
23
66
24
67
25
68
Required Files for a PyAnsys Project
0 commit comments