国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術(shù)及教程分享平臺(tái)!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - Python - 利用setuptools打包python程序的方法步驟

利用setuptools打包python程序的方法步驟

2020-04-16 12:52風(fēng)間悠香 Python

這篇文章主要介紹了利用setuptools打包python程序的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

一、準(zhǔn)備工程文件

1.創(chuàng)建工程leeoo

利用setuptools打包python程序的方法步驟

2.在工程根目錄下創(chuàng)建setup.py文件

利用setuptools打包python程序的方法步驟

3.在工程根目錄下創(chuàng)建同名package

利用setuptools打包python程序的方法步驟

二、編輯setup.py

1.編輯setup.py文件

?
1
2
3
4
5
6
7
8
9
10
11
from setuptools import setup, find_packages
 
setup(
  name='leeoo', # 包的名稱
  version='1.0', # 版本號(hào)
  packages=find_packages(), # 動(dòng)態(tài)獲取packages
  description="leeoo package",
  author='Leo',
  author_email='leo4774177@gmail.com',
  url="None",
)

2.參數(shù)說明

利用setuptools打包python程序的方法步驟

三、編寫測(cè)試代碼

1.在leeoo package下創(chuàng)建pkg

利用setuptools打包python程序的方法步驟

2.test.py文件內(nèi)容

?
1
2
3
4
5
6
7
8
9
10
11
def testfunc():
  print("This is a test function..")
 
 
class TestClass(object):
  def __init__(self, name):
    self.name = name
    print("This is a test Class..")
 
  def get_name(self):
    return self.name

3.將test.py中的內(nèi)容全部導(dǎo)入到leeoo的__init__.py中

利用setuptools打包python程序的方法步驟

這樣,以后import leeoo后,就可以直接使用leeoo.testfunc()了。

四、打包

1.命令行進(jìn)入工程根目錄

利用setuptools打包python程序的方法步驟

2.運(yùn)行命令

?
1
2
(venv) D:\pycharm_workspace\leeoo>python setup.py check
running check
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(venv) D:\pycharm_workspace\leeoo>python setup.py bdist_egg
running bdist_egg
running egg_info
creating leeoo.egg-info
writing leeoo.egg-info\PKG-INFO
writing dependency_links to leeoo.egg-info\dependency_links.txt
writing top-level names to leeoo.egg-info\top_level.txt
writing manifest file 'leeoo.egg-info\SOURCES.txt'
reading manifest file 'leeoo.egg-info\SOURCES.txt'
writing manifest file 'leeoo.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\leeoo
copying leeoo\__init__.py -> build\lib\leeoo
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\leeoo
copying build\lib\leeoo\__init__.py -> build\bdist.win-amd64\egg\leeoo
byte-compiling build\bdist.win-amd64\egg\leeoo\__init__.py to __init__.cpython-37.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist\leeoo-1.0-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)

3.查看生成的文件

在工程根目錄下,可以看到生成了一系列文件:

利用setuptools打包python程序的方法步驟

五、安裝leeoo

1.在工程目錄下(setup.py所在目錄)運(yùn)行命令

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
D:\pycharm_workspace\leeoo>python setup.py install
running install
running bdist_egg
running egg_info
writing leeoo.egg-info\PKG-INFO
writing dependency_links to leeoo.egg-info\dependency_links.txt
writing top-level names to leeoo.egg-info\top_level.txt
reading manifest file 'leeoo.egg-info\SOURCES.txt'
writing manifest file 'leeoo.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\leeoo
copying build\lib\leeoo\__init__.py -> build\bdist.win-amd64\egg\leeoo
byte-compiling build\bdist.win-amd64\egg\leeoo\__init__.py to __init__.cpython-37.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying leeoo.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist\leeoo-1.0-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing leeoo-1.0-py3.7.egg
Copying leeoo-1.0-py3.7.egg to d:\dev_apps\anaconda5.3.0\lib\site-packages
Adding leeoo 1.0 to easy-install.pth file
 
Installed d:\dev_apps\anaconda5.3.0\lib\site-packages\leeoo-1.0-py3.7.egg
Processing dependencies for leeoo==1.0
Finished processing dependencies for leeoo==1.0

2.查看安裝好的文件

我們看到上述打印日志中,將leeoo-1.0-py3.7.egg安裝到了d:\dev_apps\anaconda5.3.0\lib\site-packages。

利用setuptools打包python程序的方法步驟

六、使用leeoo

新建一個(gè)項(xiàng)目,然后導(dǎo)入leeoo:

?
1
2
3
4
5
import leeoo
 
leeoo.testfunc()
obj = leeoo.TestClass("demo")
print(obj.get_name())

也可以使用:

?
1
2
3
4
5
from leeoo.pkg import test
 
test.testfunc()
obj = test.TestClass("demo")
print(obj.get_name())

當(dāng)然也可以直接將testfunc()和TestClass導(dǎo)入,但是容易引起命名沖突。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://www.cnblogs.com/leokale-zz/p/12207923.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 中文在线一区 | 成人午夜精品久久久久久久蜜臀 | 精品一区二区久久久久久久网站 | 综合伊人| 小川阿佐美88av在线播放 | 久久综合888 | 一级片黄色免费 | 亚洲高清视频一区二区 | 自拍一区视频 | 久久久久久久国产精品 | 中文字幕在线精品 | 国产精品久久亚洲 | 99视频在线 | 久久艹天天艹 | 在线不卡a资源高清 | 午夜小电影 | 午夜网 | 亚洲福利在线观看 | 日韩小视频在线观看 | 激情图区在线观看 | 国产一区二区三区欧美 | 日韩美女av在线 | 久久亚洲欧美日韩精品专区 | 亚洲精品一区在线 | 欧美亚洲一 | 欧美a级成人淫片免费看 | 538在线| 久久久无码精品亚洲日韩按摩 | 欧美日本韩国一区二区 | 亚洲伊人久久综合 | 国产福利电影 | 红桃成人少妇网站 | 国产传媒自拍 | 爱爱视频网址 | 亚洲精品在线中文字幕 | 欧美在线观看免费观看视频 | 中文字幕av亚洲精品一部二部 | 国产精品午夜在线观看 | 日韩欧美精品 | 一级特黄录像免费播放全99 | 久久精品一区二区三区四区 |