anod.package
============

.. py:module:: anod.package


Attributes
----------

.. autoapisummary::

   anod.package.PrepareSrcCB


Classes
-------

.. autoapisummary::

   anod.package.Package
   anod.package.Source
   anod.package.SharedSource
   anod.package.SourceBuilder
   anod.package.UnmanagedSourceBuilder
   anod.package.ThirdPartySourceBuilder
   anod.package.ExternalSourceBuilder


Module Contents
---------------

.. py:data:: PrepareSrcCB

.. py:class:: Package(prefix: str, publish: bool = False, version: Callable[[], str] | None = None)

   Describe and generate a binary package.


   .. py:attribute:: prefix


   .. py:attribute:: name


   .. py:attribute:: publish
      :value: False



   .. py:attribute:: version
      :value: None



   .. py:property:: is_simple_archive
      :type: bool


      Check if package creation can be bypassed.

      If true it means that package creation can be bypassed
      in some context such as user mode. By default it is
      True



   .. py:method:: pkg_name(anod_instance: e3.anod.spec.Anod) -> str

      Return the final package filename.

      :param anod_instance: the Anod instance that creates the package
      :return: the name without extension of the package filename



   .. py:method:: pkg_path(anod_instance: e3.anod.spec.Anod) -> str

      Return the full path in which a package will be generated.

      :param anod_instance: the Anod instance that creates the package
      :return: the full path to the generated archive



   .. py:method:: create_package(anod_instance: e3.anod.spec.Anod) -> str

      Generate a package as a ZIP archive.

      :param anod_instance: the Anod instance that creates the package
      :return: the full path to the generated archive



.. py:class:: Source(name: str, publish: bool, dest: str | None = None, unpack_cmd: Callable | None = None, remove_root_dir: bool = True, ignore: None = None)

   Source package.


   .. py:attribute:: name


   .. py:attribute:: publish


   .. py:attribute:: dest
      :value: None



   .. py:attribute:: unpack_cmd
      :value: None



   .. py:attribute:: remove_root_dir
      :value: True



   .. py:attribute:: builder
      :type:  SourceBuilder | None
      :value: None



   .. py:attribute:: other_sources
      :type:  list[Source]
      :value: []



   .. py:method:: set_builder(builder_function: SourceBuilder) -> None

      Set the SourceBuilder associated to this Source object.



   .. py:method:: set_other_sources(other_sources: list[Source]) -> None

      Get the list of other sources to compute ``ignore`` property.



   .. py:property:: ignore
      :type: list[str]


      Return list of paths to ignore when installing the source.

      By default, a source package is first unpacked and then install
      in the `dest` directory by using e3.fs.sync_tree. The ignore
      property returns a value that can be passed to e3.fs.sync_tree.



.. py:class:: SharedSource(name: str, publish: bool, dest: str | None = None, unpack_cmd: Callable | None = None, remove_root_dir: bool = True, ignore: None = None)

   Bases: :py:obj:`Source`


   Shared sources are installed directly in the sandbox.

   This is useful when you need to use the same sources for different
   modules/platforms and you don't need to write in the sources
   directory


.. py:class:: SourceBuilder(name: str, fullname: Callable[[], str], checkout: list[str] | None, prepare_src: PrepareSrcCB | None = None, apply_patch: Literal[1] | ApplyPatchCB | None = None, kind: str = 'source')

   .. py:attribute:: DEFAULT_PATCH_CMD
      :type:  Final
      :value: 1



   .. py:attribute:: name


   .. py:attribute:: checkout


   .. py:attribute:: repositories


   .. py:attribute:: kind
      :value: 'source'



   .. py:attribute:: from_spec
      :value: None



   .. py:attribute:: source_query
      :type:  dict[str, str | None] | None
      :value: None



   .. py:attribute:: __fullname


   .. py:attribute:: __prepare_src
      :value: None



   .. py:attribute:: __apply_patch
      :value: None



   .. py:method:: fullname(*args: Any, **kwargs: Any) -> str


   .. py:property:: prepare_src
      :type: PrepareSrcCB | None


      Return the callback used to prepare the source package.

      :return: the callback or None if no prepare_src is defined
      :raise: SpecError



   .. py:property:: apply_patch
      :type: ApplyPatchCB


      Return the callback used to apply a patch.

      :return: the callback



.. py:class:: UnmanagedSourceBuilder(name: str, fullname: Callable[[], str], checkout: list[str] | None, prepare_src: PrepareSrcCB | None = None, apply_patch: Literal[1] | ApplyPatchCB | None = None, kind: str = 'source')

   Bases: :py:obj:`SourceBuilder`


   Source builder for sources not managed by anod.


   .. py:property:: prepare_src
      :type: None


      Do not create source package.



.. py:class:: ThirdPartySourceBuilder(name: str)

   Bases: :py:obj:`UnmanagedSourceBuilder`


   SourceBuilder for thirdparty packages.


.. py:class:: ExternalSourceBuilder(name: str, bid: str | None = None, setup: str | None = None, date: str | None = None, query_name: str | None = None)

   Bases: :py:obj:`UnmanagedSourceBuilder`


   SourceBuilder to reference sources produced outside the setup.


   .. py:attribute:: source_query


