上传到pypi后使用我的库时,我必须使用from package import package
,而不仅仅是import package
。我该如何更改?
我的setup.py文件:
import pathlib
from setuptools import setup
# The directory containing this file
HERE = pathlib.Path(__file__).parent
# The text of the README file
README = (HERE / "README.md").read_text()
# This call to setup() does all the work
setup(
name="cool-library",
version="0.5.3",
description="Libary",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/user/repo",
author="Author",
author_email="user@site.com",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
],
packages=["mylib"],
include_package_data=True,
install_requires=[],
entry_points={
"console_scripts": [
"cool-library=mylib.__main__:main",
]
},
)
这是目录布局:
cool-library
├── README.md
├── setup.py
├── mylib
│ ├── __main__.py
│ └── mylib.py
如何重新排列以便可以直接导入?我尝试做package_dir = {'':'mylib'}
,但这对我没有用。