python打包wheel文件

1.创建功能性函数

pytest.py

def test():
    print('print test')
2.创建setup.py文件
from setuptools import  setup
setup(
    name='printtest',
    version='1.0',
    py_modules=['printtest']
)
3.制作wheel文件
python setup.py bdist_wheel
4.使用.whl文件安装依赖库

.whl文件在dist目录下

$ CD ./dist
$ pip install printtest-1.0-py3-none-any.whl
5.导入安装好的pytest库使用

demo1.py

import pytest
pytest.test()

执行结果

C:\Users\Jim\env\demo\Scripts\python.exe  C:/Users/Jim/Desktop/demo.py
print test

Process finished with exit code 0

你可能感兴趣的:(python,运维)