跳转到主要内容

简单的pypi包

项目描述

简单的Python包索引

simpypi的工作原理

simpypi的核心是simpypi.wsgi.SimPyPI,一个简单的WSGI网络应用程序,它接受一个上传的python包分发,并根据其名称和版本元数据按照简单索引协议放置它。

出于安全考虑,SimPyPI对于无效请求返回直接的HTTP 400响应。这或许可以改进。

SimPyPI本身不提供这个目录。该目录应由文件服务器提供,例如Apache或FileServer,它将生成目录索引(根据http://guide.python-distribute.org/contributing.html#the-simple-index-protocol)。simpypi.factory.factory提供了一个工厂,用于创建一个包装FileServer的中间件并服务简单索引的WSGI应用程序,在/index/下服务简单索引,在/下服务SimPyPI应用程序。此外,还提供了一个simpypi命令行程序,作为前端。

目前simpypi仅适用于源分发(即,使用python setup.py sdist制作的包)。

示例

为了演示目的,我在http://k0s.org:8080安装了simpypi的一个实例,其包索引在http://k0s.org:8080/index/。为了测试目的,我编写了一个名为upload_mozbase.py的脚本,该脚本将mozbase包上传到simpypi。因此,现在索引已包含这些包。

您可以使用curl上传包。

> wget http://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.10.tar.gz
> curl -F 'package=@PyYAML-3.10.tar.gz' http://k0s.org:8080/

您可以从http://k0s.org:8080/index/使用easy_install安装mozbase。如果包的依赖项可以在simpypi包索引中找到,它们也将从索引中安装。

> virtualenv.py tmp
New python executable in tmp/bin/python
Installing setuptools............done.
Installing pip...............done.
> cd tmp/
(tmp)│easy_install -i http://k0s.org:8080/index/ mozrunner
Searching for mozrunner
Reading http://k0s.org:8080/index/mozrunner/
Best match: mozrunner 5.1
Downloading http://k0s.org:8080/index/mozrunner/mozrunner-5.1.tar.gz
Processing mozrunner-5.1.tar.gz
Running mozrunner-5.1/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-gqerOV/mozrunner-5.1/egg-dist-tmp-Qyx3Cr
Adding mozrunner 5.1 to easy-install.pth file
Installing mozrunner script to /home/jhammel/tmp/bin
Installed
/home/jhammel/tmp/lib/python2.7/site-packages/mozrunner-5.1-py2.7.egg
Processing dependencies for mozrunner
Searching for mozprofile>=0.1
Reading http://k0s.org:8080/index/mozprofile/
Best match: mozprofile 0.1
Downloading http://k0s.org:8080/index/mozprofile/mozprofile-0.1.tar.gz
Processing mozprofile-0.1.tar.gz
Running mozprofile-0.1/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-4Im6x0/mozprofile-0.1/egg-dist-tmp-9Jp5TR
Adding mozprofile 0.1 to easy-install.pth file
Installing mozprofile script to /home/jhammel/tmp/bin
Installed
/home/jhammel/tmp/lib/python2.7/site-packages/mozprofile-0.1-py2.7.egg
Searching for mozprocess
Reading http://k0s.org:8080/index/mozprocess/
Best match: mozprocess 0.1b2
Downloading
http://k0s.org:8080/index/mozprocess/mozprocess-0.1b2.tar.gz
Processing mozprocess-0.1b2.tar.gz
Running mozprocess-0.1b2/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-KU6AiF/mozprocess-0.1b2/egg-dist-tmp-4j5CMP
Adding mozprocess 0.1b2 to easy-install.pth file
Installed
/home/jhammel/tmp/lib/python2.7/site-packages/mozprocess-0.1b2-py2.7.egg
Searching for mozinfo
Reading http://k0s.org:8080/index/mozinfo/
Best match: mozinfo 0.3.3
Downloading http://k0s.org:8080/index/mozinfo/mozinfo-0.3.3.tar.gz
Processing mozinfo-0.3.3.tar.gz
Running mozinfo-0.3.3/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-JaKeaz/mozinfo-0.3.3/egg-dist-tmp-xWojez
Adding mozinfo 0.3.3 to easy-install.pth file
Installing mozinfo script to /home/jhammel/tmp/bin
Installed
/home/jhammel/tmp/lib/python2.7/site-packages/mozinfo-0.3.3-py2.7.egg
Searching for ManifestDestiny>=0.5.4
Reading http://k0s.org:8080/index/ManifestDestiny/
Best match: ManifestDestiny 0.5.4
Downloading
http://k0s.org:8080/index/ManifestDestiny/ManifestDestiny-0.5.4.tar.gz
Processing ManifestDestiny-0.5.4.tar.gz
Running ManifestDestiny-0.5.4/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-2blF3S/ManifestDestiny-0.5.4/egg-dist-tmp-R3KZde
Adding ManifestDestiny 0.5.4 to easy-install.pth file
Installing manifestparser script to /home/jhammel/tmp/bin
Installed
/home/jhammel/tmp/lib/python2.7/site-packages/ManifestDestiny-0.5.4-py2.7.egg
Finished processing dependencies for mozrunner

请注意,所有包都来自k0s.org安装,而不是来自http://pypi.python.org/

运行测试

测试目录包含doctests和测试运行程序test.py。这些测试说明了基本功能,并在代码提交之前运行时可以防止回归。文件tests-require.txt包含运行测试所需的依赖项。尽管如此,可以使用Paste TestApp,但这也可能过渡到WebTest。使用virtualenv用于隔离python环境。

要运行测试,请执行

python test.py

待办事项

尽管simpypi相当简单,但这并不意味着它只有100行代码就是正确的100行代码。以下问题可以解决

  • 临时包应该尽可能全部在内存中处理,目前我们写入文件并移动它。

  • simpypi使用pkginfo.sdist从源分布读取数据。相反,上传的包可能需要解包并运行python setup.py sdist,然后将生成的包放在适当的位置。这将允许上传没有PKG-INFO的存档(例如,http://hg.mozilla.org/build/talos/archive/tip.tar.gz),并且至少部分解决当前simpypi仅适用于上传的源分布的问题。

http://k0s.org/mozilla/hg/simpypi

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

simpypi-0.1.3.tar.gz (6.0 kB 查看哈希)

上传

由以下支持