一些有助于构建python2/3源代码和轮子库的工具

build-utils的Python项目详细描述


构建实用程序

Latest VersionLicenseimage

有很多锅炉板代码我会一遍又一遍地为我的 项目,尤其是当我试图同时支持python2python3时。 这个项目的目的是简化它,让我可以很容易地添加 立即更新/改进我的所有项目。

安装

大多数系统都安装了python2,但是如果您打算这样做 python3开发然后您应该为您的平台安装它。 对于MacOS:

brew install python3

PIP

建议使用pip

安装此库
pip install build_utils

发展

如果您希望开发并提交git拉取,可以执行以下操作:

git clone https://github.com/walchko/build_utils
cd build_utils
pip install -e .

用法

若要使用此软件包,请至少将您的回购设置为:

myLibrary/
|
+- myLibrary/
|   |
|   +- src files
+- tests/
|   |
|   +- test.py
+- setup.py

还可以在您的setup.py中添加以下内容:

... other imports ...
from build_utils import BuildCommand
from build_utils import PublishCommand
from build_utils import BinaryDistribution
from build_utils import SetGitTag

VERSION = '1.0.0'
PACKAGE_NAME = 'myLibrary'

# class to test and build the module
BuildCommand.pkg = PACKAGE_NAME
BuildCommand.test = True  # run all tests, True by default, False, no tests run
BuildCommand.py2 = True   # test and build python2, True by default
BuildCommand.py3 = True   # test and build python3, True by default

# class to publish the module to PyPi
PublishCommand.pkg = PACKAGE_NAME
PublishCommand.version = VERSION
SetGitTag.version = VERSION

setup(
    name=PACKAGE_NAME,
    version=VERSION,
    ... other options ...
    cmdclass={
        'publish': PublishCommand,  # run this to publish to pypi
        'make': BuildCommand,       # run this to test/build library
        'git': SetGitTag            # this creates a new tag on your repo
    }
)

github上此库的设置为例。 注意,默认情况下,testing和py2和py3都是Trueby 违约。现在您可以通过:

python setup.py make
python setup.py publish
python setup.py git

其他

获取一些基本系统信息:

>>>importbuild_utilsasbu>>>bu.get_system()System(os='macos',arch='x86_64',kernel='17.5.0',os_version='17.5.0')

获取库的版本号:

>>>importbuild_utilsasbu>>>bu.get_pkg_version('build_utils/__init__.py')"0.2.0"

测试

它使用nose运行测试并发出命令 python -m nose -w tests -v test.py其中python将是 python2python3取决于您启用的功能。

如果您有多个测试文件,请尝试:

# assume you have test1.py, test2.py and test3.py ... do:
from .test1 import *
from .test2 import *
from .test3 import *

一切都会好起来的。

image

发布

默认情况下使用twine。确保您的配置文件设置如下 在主目录中:

[distutils]
index-servers = pypi

[pypi]
repository: https://pypi.python.org/pypi
username: my-awesome-username
password: super-cool-passworld

更改日志

DateVersionNotes
2018-07-080.3.0added git version command and colorama
2018-06-200.2.2added some helper functions
2017-04-090.1.0init

麻省理工学院许可证

版权所有(c)2017 Kevin J.Walchko

特此免费向任何获得 本软件和相关文档文件的副本 “软件”),无限制地处理软件,包括 但不限于使用、复制、修改、合并、发布, 分发、再授权和/或出售软件副本,以及 允许向其提供软件的人员这样做,但须遵守 以下条件:

上述版权公告及本许可公告须包括在内 在软件的所有副本或大部分中。

软件按“原样”提供,不作任何保证, 明示或默示,包括但不限于 适销性、适合特定目的和不侵权。 在任何情况下,作者或版权持有人均不对任何 索赔、损害赔偿或其他责任,无论是在合同诉讼中, 侵权行为或其他,由 软件或软件中的使用或其他交易。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法使用JAXB配置Moxy   java如何让我的简单Swing telnet客户端正确显示字符?   java中从可运行线程调用主线程的多线程处理   java数据源。EBJ3会话bean中的getConnection()   使用java和正则表达式从xml文件提取值时出现问题   java定制Jersy胡须Mvc   在Java中,“限制并发”是什么意思?   java有没有更干净的方法可以在这里使用Optional,而不在三个地方返回“NA”?   java Tomcat启动,然后崩溃,除非我打电话   java理解客户机和服务器   java时间戳将在视图对象>实体转换期间丢失   如何在java中返回布尔值(基元)?   java使用spring mvc设置日志记录,希望仅对我的代码进行跟踪/调试   用Jackson解析嵌套对象