如何在pip-ins之后在PyPi中公开单个模块

2024-09-26 22:42:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试添加一个使用distutils编写到PyPi的模块/设置.py等等。一切都很顺利,除了为了访问模块(在pip安装之后),我必须这样做:

from svdRec import svdRec
svd = svdRec.svdRec()

理想情况下,我想这样做:

import svdRec
svd = svdRec.svdRec()

我的文件结构如下:

svdRec
... setup.py
... README.md
... setup.cfg
... MANIFEST
... svdRec/
... ... svdRec.py

还有我的设置.py看起来像这样:

from distutils.core import setup
setup(
  name = 'svdRec',
  packages = ['svdRec'], # this must be the same as the name above
  version = '0.1.2',
  description = 'A Python3 Collaborative Recommendation Engine with Sparse Matrices',
  author = 'REDACTED',
  author_email = 'REDACTED',
  url = 'https://github.com/REDACTED', # use the URL to the github repo
  download_url = 'https://github.com/REDACTED', # Points to the github TAR file made by tagging
  keywords = ['recommender', 'sparse', 'matrix', 'recsys', 'svd'], # arbitrary keywords
  classifiers = [],
  install_requires = ['scipy','numpy'], # required packages
)

这是我第一次尝试让一个模块可安装,所以任何指导都将非常感谢它如何通过一个单一的调用,而不是需要做模块公开

from PACKAGE import MODULE


Tags: 模块thenamefrompyimportgithuburl

热门问题