osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Distributing multiple packages with on setup.py


Hi,

I've reorganized my Python project to be under a same name umbrella.
My project can now be seen as multiple subsystems than can depend on
each other. That means that every sub-package can now be distributed
alone so that only required dependencies can be installed.

The old structure:


    /
    ?? myproj/
    ?  ?? __init__.py
    ?  ?? mod1.py
    ?  ?? subpackage1/
    ?  ?? subpackage2/
    ?? setup.py


The new structure:


    /
    ?? myproj/
    ?  ?? common/
    ?  ?  ?? mod1.py
    ?  ?? subpackage1/
    ?  ?? subpackage2/
    ?  ?? __init__.py
    ?? setup.py


As you can see not much has changed except that `myproj` is now a
`namespace package
<https://packaging.python.org/guides/packaging-namespace-packages/>`_
and that sub-packages ``common``, ``subpackage1`` and ``subpackage2``
can now be distributed independently.

Is it possible, still keeping one unique ``setup.py`` file, to create
3 independent packages?

* ``myproj.common``
* ``myproj.subpackage1``
* ``myproj.subpackage2``

Also I'd like to specify that when installing ``myproj.subpackage1``,
``myproj.common`` is required or that ``myproj.subpackage2`` will
require both ``myproj.common`` and ``myproj.subpackage1``.

Regards,
Jimmy