2012-02-20 24 views

回答

15

你必須對http://pypi.python.org/創建賬戶。然後您可以上傳模塊http://pypi.python.org/pypi?%3Aaction=submit_form。本網站

文件包含像

如何創建它可以在管狀的被上傳模塊的所有命令?

如何從pip下載?

等等

您將獲得http://docs.python.org/distutils/index.html

幫助您也可以直接註冊在http://docs.python.org/distutils/packageindex.html

+0

我的問題是如何創建一個基本的點子模塊?我沒有找到任何關於如何創建基本pip可安裝軟件包的適當文檔。 – gpasse 2012-02-20 12:57:09

+0

請檢查編輯的答案。 – Nilesh 2012-02-20 13:16:18

+0

這似乎是我需要的確實 – gpasse 2012-02-20 13:28:07

1

你也可以試試這個代碼:

def create(name,path_to_code,description,version,username,password,readme='',keywords=[]): 
    import os 
    from os.path import expanduser 
    with open(path_to_code,'r') as file: 
     code=file.read() 
    os.system('mkdir '+name) 
    with open(os.path.join(os.getcwd(),name+"/code.py"),'w') as file: 
     file.write(code) 
    with open(os.path.join(os.getcwd(),name+"/README.txt"),'w') as file: 
     file.write(readme) 
    with open(os.path.join(expanduser("~"),".pypirc"),'w') as file: 
     file.write(""" 
[distutils] 
index-servers=pypi 

[pypi] 
repository = https://upload.pypi.org/legacy/ 
username = %s 
password = %s 
[server-login] 
username = %s 
password = %s  
     """%(username,password,username,password,)) 
    with open(os.path.join(os.getcwd(),name+"/setup.py"),'w') as file: 
     file.write(""" 
from setuptools import setup 

setup(
     name='%s', # This is the name of your PyPI-package. 
     keywords='%s', 
     version='%s', 
     description='%s', 
     long_description=open('README.txt').read(), 
     scripts=['%s']     # The name of your scipt, and also the command you'll be using for calling it 
) 
     """%(name,' '.join(keywords),version,description,'code.py')) 

    os.system("cd "+name+";python3 setup.py register sdist upload -r https://upload.pypi.org/legacy/") 

然後運行它並將這些參數放在create函數中。這將使包和上傳它與點名。

相關問題