简体   繁体   English

为不同的python版本准备Pypi包

[英]Preparing packages for Pypi for different python versions

I'm preparing a package for Pypi that calculates the steady-state distributions for Markov chains with discrete state spaces . 我正在为Pypi准备一个包,用于计算具有离散状态空间的马尔可夫链的稳态分布。

The main files with code run without problems both on Python 2.7 and Python 3.5 (tested this in a virtual environment). 带有代码的主文件在Python 2.7和Python 3.5上都运行没有问题(在虚拟环境中测试)。 The setup.py file also seems to work, at least for Python 2.7. setup.py文件似乎也可以工作,至少对于Python 2.7。

From this point on it is unclear to me how to proceed. 从这一点来看,我不清楚如何继续。 Should I run setup.py on all possible version of Python to create separate 'egg' files for each Python version? 我应该在所有可能的Python版本上运行setup.py来为每个Python版本创建单独的“egg”文件吗? That seems rather tedious, considering the file runs on both Python versions anyway, and you'd have to redo this every time you update a package. 考虑到文件在两个Python版本上运行,这似乎相当繁琐,而且每次更新软件包时都必须重做这个。

What would be good practice here? 这里有什么好习惯?

If you're looking for a good release checklist (answering the question "what should I do before I push to pypi?"), you can't go past Audrey Roy's PyPI Release Checklist . 如果您正在寻找一个好的发布清单(回答“在推送到pypi之前我该怎么办?”),你就不能超过奥黛丽罗伊PyPI发布清单 That's a living document, and is updated as needed, but the high points are: 这是一份活文件,并根据需要进行更新,但最重要的是:

  • Update your changelog 更新您的更改日志
  • Update your version number 更新您的版本号
  • Run your tests 运行测试
  • Build for pypi, using both source distributions (sdist) and the newer wheel format. 使用源分发(sdist)和较新的轮格式构建pypi。
  • Push to the pypi test instance (using twine ) 推送到pypi测试实例 (使用麻线
  • Check that your README render correctly 检查您的README是否正确呈现
  • Test that installations from the test instance work 测试测试实例中的安装是否有效
  • Push to pypi production 推动pypi生产
  • Update the git repository tags/releases 更新git存储库标记/版本

Other less important thing may include: 其他不太重要的事情可能包括:

With respect to the element of the question about eggs - they are no longer necessary (since the wheel format was introduced). 关于鸡蛋问题的要素 - 它们不再是必要的(因为引入了轮子格式)。 Consider adding something to your .gitignore file to prevent them from being added to your repository. 请考虑在.gitignore文件中添加一些内容,以防止它们被添加到您的存储库中。 Basically, unless you use native code, all you need to do is deploy both sdists and wheels, and you should be fine. 基本上,除非你使用本机代码,你需要做的就是部署sdists和wheel,你应该没问题。

With respect to "running without problems" consider converting your examples to tests, and then running those tests as part of every release. 关于“无问题运行”,请考虑将示例转换为测试,然后将这些测试作为每个版本的一部分运行。 You can either use tox locally, or use a service like travis or appveyor . 您可以在本地使用tox ,也可以使用travisappveyor等服务。 This is particularly important if you have behaviour that should be preserved between releases - this is an important part of semantic versioning 如果您的行为应该在版本之间保留,这一点尤其重要 - 这是语义版本控制的重要部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM