2012-02-20 11 views

risposta

15

è necessario creare account su http://pypi.python.org/. Quindi puoi caricare il modulo su http://pypi.python.org/pypi?%3Aaction=submit_form.

Doc in questo sito contiene tutti i comandi come

Come creare moduli che possono essere caricatela su pipy?

Come scaricare fro pip?

ecc ...

Si otterrà aiuto su http://docs.python.org/distutils/index.html

Inoltre è possibile registrare direttamente su http://docs.python.org/distutils/packageindex.html

+0

La mia domanda era come creare un modulo pip di base? Non ho trovato alcuna documentazione adeguata su come posso creare un pacchetto installabile di base. – gpasse

+0

Si prega di verificare la risposta modificata. – Nilesh

+0

Questo sembra quello che avevo davvero bisogno – gpasse

1

Si può anche provare questo codice:

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

Poi eseguirlo e inserire i parametri nella funzione di creazione. Questo renderà il pacchetto e lo carica pip con il nome specificato.

Problemi correlati