setup.py sdist 创建一个没有包的存档
我有一个名为 Alexandria 的项目,我想将其作为包上传到 PyPi 上。为此,我有一个名为 alexandria-python 的顶级文件夹,其中放置了包以及使用 setup.py 创建包存档所需的所有元素。文件夹 alexandria-python 具有以下结构:
|- setup.py
|- README.md
|- alexandria (root folder for the package)
|- __init__.py
|- many sub-packages
然后,按照许多教程创建可上传的存档,我打开一个终端,cd 到 alexandria-python,并使用命令:
python setup.py sdist
这会创建其他文件夹,因此 alexandria-python 的结构是现在:
|- setup.py
|- README.md
|- alexandria (root folder for the package)
|- __init__.py
|- many sub-packages
|- alexandria.egg-info
|- dist
一切看起来都很好,根据我的理解,该包现在应该存档在 dist 文件夹中。但是,当我打开 dist 文件夹并提取已创建的 alexandria-0.0.2.tar.gz 存档时,它不包含“alexandria”包。因此,除了最重要的元素:包,其他所有东西似乎都在那里,如图所示:
< img src="https://i.sstatic.net/FhMdp.png" alt="在此处输入图像描述">
接下来,当我将项目上传到 test-PyPi 然后 pip 安装它时,任何尝试导入模块从工具箱中获取会导致 ModuleNotFoundError。我的包怎么没有上传到存档?我是不是在做一些非常愚蠢的事情?
注意:如果它有帮助,这是我的 setup.py 文件的结构:
from setuptools import setup
# set up the package
setup(
name = "alexandria",
license = "Other/Proprietary License",
version = "0.0.2",
author = "Romain Legrand",
author_email = "[email protected]",
description = "a software for Bayesian time-series econometrics applications",
python_requires = ">=3.6",
keywords=["python", "Bayesian", "time-series", "econometrics"])
I have a project called Alexandria that I want to upload on PyPi as a package. To do so, I have a top folder called alexandria-python in which I put the package and all the elements required to create a package archive with setup.py. The folder alexandria-python has the following structure:
|- setup.py
|- README.md
|- alexandria (root folder for the package)
|- __init__.py
|- many sub-packages
Then, following many tutorials to create an uploadable archive, I open a terminal, cd to alexandria-python, and use the command:
python setup.py sdist
This creates additional folders, so the structure of alexandria-python is now:
|- setup.py
|- README.md
|- alexandria (root folder for the package)
|- __init__.py
|- many sub-packages
|- alexandria.egg-info
|- dist
everything looks fine, and from my understanding the package should now be archived in the dist folder. But when I open the dist folder and extract the alexandria-0.0.2.tar.gz archive that has been created, it does not contain the 'alexandria' package. Everything else thus seems to be there, except the most important element: the package, as shown on the image:
Following, when I upload the project to test-PyPi and then pip install it, any attempt to import a module from the toolbox results in a ModuleNotFoundError. How is it that my package does not get uploaded to the archive? Am I doing something very silly?
Note: in case it can help, this is the structure of my setup.py file:
from setuptools import setup
# set up the package
setup(
name = "alexandria",
license = "Other/Proprietary License",
version = "0.0.2",
author = "Romain Legrand",
author_email = "[email protected]",
description = "a software for Bayesian time-series econometrics applications",
python_requires = ">=3.6",
keywords=["python", "Bayesian", "time-series", "econometrics"])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
setup.py
既没有py_modules
也没有包
。必须有其中之一。在你的情况下,alexandria
是一个包,所以或者
......
Your
setup.py
has neitherpy_modules
norpackages
. Must have one of those. In your casealexandria
is a package soor
…