python-packaging

Relative imports in Python

雨燕双飞 提交于 2019-11-26 19:35:52
问题 Hey all -- I am pulling my hair out with relative imports in Python. I've read the documentation 30 times and numerous posts here on SO and other forums -- still doesn't seem to work. My directory structure currently looks like this src/ __init__.py main.py components/ __init__.py expander.py language_id.py utilities/ __init__.py functions.py I want expander.py and language_id.py to have access to the functions module. I run python main.py which accesses the modules just fine with from

What is setup.py?

£可爱£侵袭症+ 提交于 2019-11-26 00:29:31
问题 Can anyone please explain, what is setup.py and how can it be configured or used? 回答1: setup.py is a python file, which usually tells you that the module/package you are about to install has been packaged and distributed with Distutils, which is the standard for distributing Python Modules. This allows you to easily install Python packages. Often it's enough to write: $ pip install . pip will use setup.py to install your module. Avoid calling setup.py directly. https://docs.python.org/3

What is __init__.py for?

*爱你&永不变心* 提交于 2019-11-25 21:38:03
问题 What is __init__.py for in a Python source directory? 回答1: It used to be a required part of a package (old, pre-3.3 "regular package", not newer 3.3+ "namespace package"). Here's the documentation. Python defines two types of packages, regular packages and namespace packages. Regular packages are traditional packages as they existed in Python 3.2 and earlier. A regular package is typically implemented as a directory containing an __init__.py file. When a regular package is imported, this _