Skip to content

Migrate to 'src' Project Layout #300

@jorgepiloto

Description

@jorgepiloto

📝 Discussion

Multiple projects inside pyfluent
At the moment, all source files are located inside the ansys/ directory, which is contained at the root of the project. This folder holds:

  • The ansys-fluent-core libary.
  • The ansys-fluent-parametric library.
  • The ansys-fluent-post library.
  • The ansys-api files, which are generated from the logic under codegen and protos directories.

I saw that pymapdl follows the src/ layout exposed in the dev-guide. This is accomplished by having an ansys-api-mapdl in the Ansys GitHub organization.

I do not know which is the reason for not having an ansys-api-fluent repo in the Ansys organization. Is it because this product is still private?

Library layout
The current layout means having three separate libraries inside the ansys/fluent directory, as there is no __init__.py file:

ansys/fluent
├── core/
├── parametric/
└── post/

Ideally, each one of these libraries should be maintained in its own repo while having its own setup.py file. However, to reduce maintenance tasks, some advantage is taken from the find_namespace_packages() function in the setup.py file.

Although all three libraries are installed with the ansys-fluent-solver name, it is possible to run:

from ansys.fluent import core, parametric, post

However, the following is not permitted:

for pkg in [parametric, post]: print(f"{pkg.__version__ = }")

This is because parametric and post lack of a __version__ attribute. To keep using a single-source defined version, the following may be applied:

# Add this line to parametric/__init__.py and post/__init__.py files
__version__ == ansys.fluent.core.__version__

Moving to a src/ layout
This could be done by adding find_namespace_packages(where="src", include="ansys*"), which would still lead to:

import ansys.api.fluent.v0
from ansys.fluent import core, parametric, post

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions