Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we replace find_packages with find_namespace_packages in python 3.3 onwards and get rid of the empty init.py files?

I have a distribution with multiple package and sub packages. There are many empty __init__.py files used to tell setuptools that the folders are packages.

In python 3.3 onwards, setuptools supports find_namespace_packages. So is it a good idea to get rid of the empty __init__.py files and replace the find_packages with find_namespace_packages?

like image 430
variable Avatar asked Sep 19 '25 13:09

variable


1 Answers

There are three ways to namespace packages, each with its own pros and cons. It is true that find_namespace_packages is the recommended solution for Python3+ projects; though remember that this does not mean you omit all __init__.py files, you only remove the __init__.py in the namespace root.

like image 120
tankthinks Avatar answered Sep 21 '25 02:09

tankthinks