Assume the project directory structure is below:
test-package:
__init__.py
hello.py
setup.py
And the setup.py is:
from setuptools import setup, find_packages
setup(
name="test-package",
packages=find_packages(),
version="1.0",
include_package_data=True,
)
'test-package' is the root directory of the project. Then do:
pip install .
In the site-packages directory, there is only:
test_package-1.0-py3.7.egg-info/
I can't see the source file 'hello.py'.
I know most python projects's package name is not the root directory of the project. But in case I want to create a root directory name as the package name like this, is that possible?
You need to make a parent folder for test-package and put setup.py in there also use underscores for the package name. Technically PEP8 recommends all lowercase with no underscores for package names, but it's not a strict recommendation.
my-project:
setup.py
test_package:
__init__.py
hello.py
this has a helpful tutorial: https://packaging.python.org/tutorials/packaging-projects/
Edit: package name should use underscores not dashes
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.