Skip to main content

A CLI tool to automate uploading packages to PyPI

Project description

PyUploader

A CLI tool to automate uploading Python packages to PyPI.

Features

  • Build and upload Python packages to PyPI or TestPyPI with a single command
  • Support for API tokens and username/password authentication
  • Option to clean build directories before building
  • Option to skip existing distributions when uploading
  • Simple and intuitive command-line interface

Installation

You can install PyUploader using pip:

pip install pyuploader

Or, if you're installing from source:

pip install .

Usage

PyUploader provides several commands to help you manage your package uploading workflow:

Available Commands

Commands:
  upload     Build and upload a Python package (default command)
  init       Initialize PyUploader configuration
  edit       Edit package information in pyproject.toml
  fix        Fix format errors in pyproject.toml
  pypirc_config  Automatically configure ~/.pypirc file

Default Command (upload)

The default command (when no specific command is provided) builds and uploads a package to PyPI:

pyuploader

Command-line Options

Options:
  -d, --package-dir TEXT     Directory of the package to upload  [default: .]
  -r, --repository TEXT      PyPI repository to upload to (pypi or testpypi)
                             [default: pypi]
  -u, --username TEXT        Username for PyPI authentication
  -p, --password TEXT        Password or API token for PyPI authentication
  --dist-dir TEXT            Directory containing the distribution files
                             [default: dist]
  --build / --no-build       Whether to build the package before uploading
                             [default: build]
  --clean / --no-clean       Whether to clean the build directories before
                             building  [default: clean]
  --skip-existing            Skip uploading if the distribution already exists
  --help                     Show this message and exit.

Examples

Upload to TestPyPI:

pyuploader --repository testpypi

Upload with authentication:

pyuploader --username __token__ --password YOUR_API_TOKEN_HERE

Skip building (upload existing distributions):

pyuploader --no-build

Authentication

For PyPI authentication, you can:

  1. Provide your username and password/API token directly via command-line options
  2. Use a ~/.pypirc configuration file
  3. Let Twine prompt you for credentials during upload

Using a .pypirc Configuration File

The ~/.pypirc file allows you to store your PyPI credentials so you don't have to enter them every time you upload a package.

You can either create this file manually or use the pypirc_config command to automatically configure it.

Using the pypirc_config Command

The pypirc_config command provides an interactive interface to automatically configure your ~/.pypirc file:

pyuploader pypirc_config

This command will:

  1. guide you through setting up credentials for PyPI, TestPyPI, and pyuploader repositories
  2. Set appropriate file permissions (600) to keep your credentials secure
  3. Create all necessary configuration sections

Options:

  • --force, -f: Force overwrite of an existing .pypirc file

Basic Configuration Format

[distutils]
index-servers =
    pypi
    testpypi
    pypiuploader

[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = your-pypi-api-token-here

[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = your-testpypi-api-token-here

[pypiuploader]
repository = https://upload.pypi.org/legacy/
username = __token__
password = your-pypi-api-token-here

Important Notes:

  • For API tokens, use __token__ as the username
  • Set appropriate file permissions: chmod 600 ~/.pypirc to keep your credentials secure
  • The pyuploader section is specifically for this tool's default repository name

Using API Tokens

API tokens are the recommended authentication method for PyPI. When using an API token:

  • Use __token__ as the username
  • Use the entire token string (including the pypi- prefix) as the password

Troubleshooting

Common Errors

Missing 'pypiuploader' section from ~/.pypirc

If you see an error like:

ERROR    InvalidConfiguration: Missing 'pypiuploader' section from ~/.pypirc.

This means your ~/.pypirc file does not have a configuration section named 'pyuploader'. To fix this:

  1. Create or edit your ~/.pypirc file
  2. Add the 'pyuploader' section as shown in the configuration example above
  3. Set appropriate permissions with chmod 600 ~/.pypirc

An example configuration file is provided in this repository as .pypirc.uploader.example.

Requirements

  • Python 3.7 or higher
  • Twine 4.0.0 or higher
  • Click 8.0.0 or higher

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyuploader_cx-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyuploader_cx-0.1.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pyuploader_cx-0.1.0.tar.gz.

File metadata

  • Download URL: pyuploader_cx-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for pyuploader_cx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f99b31f936cd492936f2b964f68ca63adbd743375a3b30159dfc34396925a48
MD5 ab3acd58b4b413d7b3ef715b77111fb2
BLAKE2b-256 854451115396d00c72569c18847ff657d4bb2ff5d2fa66bf0194c3a450bb2d1e

See more details on using hashes here.

File details

Details for the file pyuploader_cx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyuploader_cx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for pyuploader_cx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b1424883291b9b7ba3377c39d3ca2a66a6739471d8b1001bfa60ad7e3f809d6
MD5 02187b2cbb63c27a243567a2e7fbdaaa
BLAKE2b-256 0d6ba7d6034990be1fa6f12736c3eaa19b428ff2e806bd73c98557a19fa8396a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page