>>> I've updated distlib[1] with a new, high-level API for accessing PyPI. While the existing "locators" API deals with locating distributions already uploaded to PyPI, the "index" API allows the following:
* Registering a project on PyPI * Uploading source and binary distributions to PyPI (incl. support for signing) * Uploading documentation to PyPI * Getting a list of mirror hosts Basic usage: >>> from distlib.index import Index >>> index = Index() # uses PyPI by default, or you can pass the URL of the index If you have a .pypirc, your username and password are read from there. If not, or if you want to override those values, you can just do >>> index.username = 'my_pypi_username' >>> index.password = 'my_pypi_password' To register a project, a version is required (just as from PyPI's Web UI): >>> from distlib.metadata import Metadata >>> metadata = Metadata() >>> metadata['Name'] = 'my_project' >>> metadata['Version'] = '0.1' >>> response = index.register(metadata) An urllib HTTP response is returned, or HTTPError is raised on error. To upload a distribution: >>> response = index.upload_file(metadata, dist_file_name, ... signer='My GPG Key Name', ... sign_password='my GPG passphrase', ... filetype='sdist', pyversion='source') The signer, sign_password, filetype and pyversion are optional. The latter two default to the values shown. Again, an HTTP response is returned, or HTTPError is raised on error. To upload documentation: >>> response = index.upload_documentation(metadata, doc_dir) The doc_dir should contain the index.html file. The entire directory tree is zipped up and uploaded to the index. an HTTP response is returned, or HTTPError is raised on error. The list of mirrors is available through the index.mirrors property. The Index class takes the place of three command classes in distutils/distutils2: register, upload and upload_doc. I've updated the distlib documentation[2]. Feedback welcome. Regards, Vinay Sajip [1] https://bitbucket.org/vinay.sajip/distlib/ [2] http://distlib.readthedocs.org/ _______________________________________________ Distutils-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/distutils-sig
