I have a setup.py
file that looks like this:
import setuptools
from distgradle import GradleDistribution
setuptools.setup(
distclass=GradleDistribution,
package_dir={'': 'src'},
packages=setuptools.find_packages('src'),
include_package_data=True,
namespace_packages=['foo'],
entry_points={
'console_scripts': [
'first = foo.something.first:main',
'second = foo.somethingelse.second:main',
],
},
)
What is the significance of package_dir={'': 'src'}
? Why do we have an empty string as the key?
What is python setup py bdist_wheel? python setup.py bdist_wheel. This will build any C extensions in the project and then package those and the pure Python code into a . whl file in the dist directory.
The setup.py file may be the most significant file that should be placed at the root of the Python project directory. It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on.
Most Python users will not want to use this module directly, but instead use the cross-version tools maintained by the Python Packaging Authority. In particular, setuptools is an enhanced alternative to distutils that provides: support for declaring project dependencies.
When you have multiple directories at the root level and under one directory the modules reside, then you can define that directory as root package and then all packages provided to packages
named argument would be looked up inside that dir. Python's official documentation describes this very well:
https://docs.python.org/3/distutils/setupscript.html#listing-whole-packages
Here, if code resides under lib
directory then defining package_dir = {'': 'lib'}
& packages = ['foo']
would mean that you are telling that system to look for foo
module under lib
i.e. lib/foo/__init__.py
exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With