简体   繁体   中英

How to distributing a Python package(just distributing some model in sub package)

For example, the file structure is

<root>/
    setup.py
    sub_package1/
        __init__.py
        sub_model1
        sub_model2
    sub_package2/
        __init__.py
        sub_model3

I want to distributing the sub_package1( just include sub_model1 ) and sub_package2(include sub_model3) package.

setup(name='example',
      version='0.1',
      packages=['sub_package1', 'sub_package2',)

This code distributing the two package, all models are distributed. I don't wanna the sub_model2 be distributed.

How to do that?

any ideas?

Thanks! :D

Distutils is not designed for such selective packaging. You can package zero or more modules, and/or zero or more packages, but you can't select specific submodules for a selected package. What's your use case? The most common way to have files distributed separately is to make them separate Python projects, each with their own setup.py script (and most probably each their own repository, now that Subversion is being replaced by leaner DVCSes).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM