pyccel.codegen.compiling.project module#

Module providing objects that are useful for describing the compilation of a project via the pyccel make command.

class pyccel.codegen.compiling.project.BuildProject(root_dir, compile_targets, languages, stdlib_deps)[source]#

Bases: object

Class representing the overall build project structure.

This class encapsulates the directory structure, compilation targets, programming languages, and standard library dependencies of a project. It serves as the main data container for build configuration.

Parameters:
  • root_dir (str | Path) – Root directory of the project where the original Python code is found.

  • compile_targets (iterable[CompileTarget]) – An iterable of all compile targets in the project.

  • languages (iterable[str]) – An iterable of languages used in the project (e.g., [‘C’, ‘Fortran’]).

  • stdlib_deps (dict[str, CompileObj]) – A dictionary mapping the names of standard library dependencies required for the build to the CompileObj describing how they are used.

property dir_info#

Get the DirTarget describing the target hierarchy within the project.

Get the DirTarget describing the target hierarchy within the project.

property languages#

Get all programming languages used in the project.

Get all programming languages used in the project.

property project_name#

Get the name of the project.

Get the name of the project.

property root_dir#

Get the root directory of the project where the original Python code is found.

Get the root directory of the project where the original Python code is found.

property stdlib_deps#

Get the dependencies injected by Pyccel.

Get a dictionary mapping the names of standard library dependencies required for the build to the CompileObj describing how they are used.

class pyccel.codegen.compiling.project.CompileTarget(name, pyfile, file, wrapper_files, program_file, stdlib_deps)[source]#

Bases: object

Class describing a compilation target.

Class describing the compilation target of a translated Python file. The class contains all the information necessary to create the necessary targets in a build system (e.g. CMake, meson).

Parameters:
  • name (str) – The unique identifier for the target.

  • pyfile (Path) – The absolute path to the Python file that was translated.

  • file (str | Path) – The absolute path to the low-level translation of the Python file.

  • wrapper_files (dict[Path, iterable[str]]) – A dictionary whose keys are the absolute paths to the generated wrapper files, and whose values are iterables containing the names of the stdlib targets for these additional files.

  • program_file (str | Path | None) – The absolute path to the low-level translation of the program found in the Python file (if the file contained a program). None if no program is generated.

  • stdlib_deps (iterable[str]) – An iterable containing the names of the stdlib targets of this object.

add_dependencies(*new_dependencies)[source]#

Add dependencies to the target.

Add dependencies to the target. A dependency is something that is imported by the file and must therefore be compiled before this object.

Parameters:

*new_dependencies (CompileTarget) – The dependencies that should be added.

property dependencies#

Get the dependencies of the target.

Get all CompileTarget objects describing targets which are imported by the file and must therefore be compiled before this object.

property file#

The absolute path to the low-level translation of the Python file.

The absolute path to the low-level translation of the Python file.

property is_exe#

Indicates if an executable should be created from this target.

Indicates if an executable should be created from this target.

property name#

The unique identifier for the target.

The unique identifier for the target.

property program_file#

The absolute path to the low-level translation of the program.

The absolute path to the low-level translation of the program found in the Python file (if the file contained a program). None, if the file didn’t contain a program.

property pyfile#

The absolute path to the Python file that was translated.

The absolute path to the Python file that was translated.

property stdlib_dependencies#

Get the stdlib dependencies of the target.

Get a list of strings containing the name of the targets from Pyccel’s standard library which are required to compile this object.

property wrapper_files#

The absolute path to the generated wrapper files.

The absolute path to the generated wrapper files.

class pyccel.codegen.compiling.project.DirTarget(folder, compile_targets: Iterable[CompileTarget])[source]#

Bases: object

Class describing a folder containing compilation targets.

Class describing a folder containing compilation targets. This class sorts the compilation targets to ensure they are compiled before they are used.

Parameters:
  • folder (Path) – The absolute path to the folder containing the generated code.

  • compile_targets (iterable[CompileTarget]) – An iterable of the CompileTarget objects which are found in this directory.

property dependencies#

Get all directories which must be compiled before this directory.

Get all directories which must be compiled before this directory.

property folder#

Get the path to the folder being described by this target.

Get the path to the folder being described by this target.

property targets#

Get all targets found in this directory.

Get all targets found in this directory. This includes compilation targets and sub-directories.