2012-02-20 34 views

Trả lời

15

Bạn phải tạo tài khoản trên http://pypi.python.org/. Sau đó, bạn có thể tải lên mô-đun trên http://pypi.python.org/pypi?%3Aaction=submit_form.

Doc trên trang web này chứa tất cả các lệnh như

Làm thế nào để tạo ra mô-đun có thể được tải lên trên như tiếng sáo?

Cách tải xuống fro pip?

vv ...

Bạn sẽ nhận được sự giúp đỡ trên http://docs.python.org/distutils/index.html

Ngoài ra bạn có thể trực tiếp đăng ký trên http://docs.python.org/distutils/packageindex.html

+0

Câu hỏi của tôi là cách tạo mô-đun pip cơ bản? Tôi đã không tìm thấy bất kỳ tài liệu thích hợp về cách tôi có thể tạo ra một gói cài đặt pip cơ bản. – gpasse

+0

Vui lòng kiểm tra câu trả lời đã chỉnh sửa. – Nilesh

+0

Điều này có vẻ như những gì tôi cần thực sự – gpasse

1

Bạn cũng có thể thử mã này:

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/") 

Sau đó chạy nó và đặt các tham số trong hàm tạo. Điều này sẽ làm cho gói và tải lên nó pip với tên đã cho.

Các vấn đề liên quan