1. 程式人生 > 其它 >python安裝包製作

python安裝包製作

myodc是一個python包,需要製作成tar安裝包

mydoc目錄結構如下:

mydoc
├── demo
│ ├── demo.py
│ └── setup.py
├── mydatetime.py
├── myexcel.py
├── myfiles.py
├── myftp.py
├── mygeneral.py
├── mylogs.py
├── mymail.py
├── mysql.py
├── myparamiko.py
├── mypsutil.py
├── mysecret.py
├── __init__.py
├── README.rst
└── settings.py

1、setup.py檔案編寫。(注意:需要放置在和mydoc同級目錄)

從setuptools包引入setup,需要同時引進find_packsges包,用來搜尋專案內各packsges

# -*- coding: utf-8 -*-
from setuptools import setup, find_packages

setup(
    name="myapi",
    version="0.0.3",
    author="宇宙劉",
    author_email="[email protected]",
    description="gamesoul common api.
", packages=find_packages(), platforms="Linux", install_requires=[ # "nptlib", # apt or yum to install # "dateutil", # apt or yum to install "pytz>=2021.07", "xlsxwriter>=0.9.3", ## "shutil", # already exists ## "ftplib", # already exists
# "MySQLdb", # apt or yum to install "paramiko>=2.0.2", "psutil>=4.4.2", "cryptography>=1.5", "pycrypto>=2.6.1" ] )

2、執行python setup.py sdist,在 ./dist下生成了一個tar包myapi-0.0.3.tar.gz

3、cd./dist, 執行pip install myapi-0.0.3.tar.gz安裝模組