### Setup and Activate Twine Development Environment Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Clones the Twine repository and sets up a local development virtual environment using tox. This environment isolates Twine and its dependencies, allowing for easy testing of local changes. ```bash cd /path/to/your/local/twine tox -e dev ``` -------------------------------- ### Install tox for Development Environment Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Installs the tox tool, which is used to manage development environments, run tests, and build documentation for Twine. This is a prerequisite for most other development tasks. ```bash python3 -m pip install tox ``` -------------------------------- ### Install Twine Source: https://github.com/pypa/twine/blob/main/docs/index.rst Installs the Twine package using pip. This is a prerequisite for using Twine to upload Python packages. ```bash pip install twine ``` -------------------------------- ### Push Git Tag to Start Release (Bash) Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst This command pushes the newly created Git tag to the `upstream` remote repository. Pushing the tag typically triggers release automation processes, such as building and deploying the package to PyPI. The output indicates monitoring the release process via GitHub Actions. ```bash git push upstream $VERSION ``` -------------------------------- ### Install Twine on Older Python Versions Source: https://github.com/pypa/twine/blob/main/docs/changelog.rst Instructions for installing Twine on Python versions older than 3.6. It specifies using pip 9 or pinning to a version of Twine less than 2. This is a workaround for version compatibility issues. ```shell pip install "twine<2" ``` -------------------------------- ### Run Twine Tests for Specific Python Version Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Runs the Twine test suite against a specific Python version (e.g., Python 3.8) using tox. This requires the specified Python version to be installed locally. ```bash tox -e py38 ``` -------------------------------- ### Twine Upload Command Help Source: https://github.com/pypa/twine/blob/main/docs/index.rst Displays help information for the 'twine upload' command, detailing its options and usage for uploading distribution packages. ```bash twine upload -h ``` -------------------------------- ### Preview Documentation Changes Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Builds and serves the Twine documentation locally, allowing developers to preview their changes in a web browser. It watches for file changes and automatically reloads the server. ```bash tox -e watch-docs ``` -------------------------------- ### Lint and Build Documentation Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Performs a final linting and builds the static HTML documentation for Twine. This should be run before submitting a pull request to ensure documentation quality and correctness. ```bash tox -e docs ``` -------------------------------- ### Twine Check Command Help Source: https://github.com/pypa/twine/blob/main/docs/index.rst Displays help information for the 'twine check' command, which is used to verify if the long description of a distribution package will render correctly on PyPI. ```bash twine check -h ``` -------------------------------- ### Twine Register Command Help Source: https://github.com/pypa/twine/blob/main/docs/index.rst Displays help information for the 'twine register' command. This command is used to pre-register a package name with a repository, though it's not supported on PyPI itself. ```bash twine register -h ``` -------------------------------- ### Run All Twine Development Tasks with tox Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Executes a comprehensive set of development tasks using tox, including running tests against all supported Python versions, checking code style, and building the documentation. This is a good command to run before submitting changes. ```bash tox ``` -------------------------------- ### Create Git Tag for Release (Bash) Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst This command sequence is used to prepare for creating a new release tag. It switches to the `main` branch, pulls the latest changes with `--ff-only` to ensure a fast-forward merge, and then creates a new Git tag with a descriptive message including the version number. This tag marks the specific point in the commit history for the release. ```bash git switch main git pull --ff-only upstream main git tag -m "Release v$VERSION" $VERSION ``` -------------------------------- ### Run Twine Tests with pytest Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Executes the test suite for Twine using `pytest`. This command runs all tests within the activated virtual environment. ```bash tox -e py ``` -------------------------------- ### Run Integration Tests for Twine Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Executes the integration tests for Twine, which typically involve uploading to real package indexes. This is part of the comprehensive testing strategy. ```bash tox -e integration ``` -------------------------------- ### Create Git Branch for Release (Bash) Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst This snippet demonstrates how to create a new Git branch for a new release. It utilizes a variable for the version number and the `git switch -c` command to create and switch to the new branch. This is a standard practice for managing release versions in Git. ```bash VERSION=3.4.2 git switch -c release-$VERSION ``` -------------------------------- ### Upload Distributions to TestPyPI Source: https://github.com/pypa/twine/blob/main/docs/index.rst Uploads distribution files (e.g., from the 'dist' directory) to the TestPyPI repository. This allows testing the upload process and package visibility before publishing to the main PyPI. ```bash twine upload -r testpypi dist/* ``` -------------------------------- ### Activate Virtual Environment Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Activates the previously created virtual environment for Twine. Once activated, commands like `tox` will operate within this isolated environment. ```bash source venv/bin/activate ``` -------------------------------- ### Set PyPI API Token using Keyring (Bash) Source: https://github.com/pypa/twine/blob/main/docs/index.rst This command configures Twine to use a keyring to store authentication credentials, specifically an API token for PyPI. It prompts the user to paste their API key, avoiding repeated manual entry during uploads. This enhances security and convenience. ```bash keyring set https://upload.pypi.org/legacy/ __token__ ``` -------------------------------- ### Format Code with isort and black Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Automatically reformats Python code in the Twine project using `isort` for import sorting and `black` for code style. This ensures consistent code formatting across the project. ```bash tox -e format ``` -------------------------------- ### Upload Distributions to PyPI Source: https://github.com/pypa/twine/blob/main/docs/index.rst Uploads distribution files (e.g., from the 'dist' directory) to the main PyPI repository. This command is used for the final release of a Python package. ```bash twine upload dist/* ``` -------------------------------- ### Update Changelog using Tox (Bash) Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst This command uses `tox` with the `changelog` environment to automatically update the changelog file. It is followed by a `git commit` command to stage and commit the changes, including the updated changelog and the specified version number. This ensures the changelog is consistent with the new release version. ```bash tox -e changelog -- --version $VERSION git commit -am "Update changelog for $VERSION" ``` -------------------------------- ### Check Code Style with flake8 Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Runs `flake8` to detect code smells and style violations in the Twine codebase. Any detected errors must be fixed manually. ```bash tox -e lint ``` -------------------------------- ### Configure HTTPS Proxy for Twine Uploads (Bash) Source: https://github.com/pypa/twine/blob/main/docs/index.rst This snippet demonstrates how to configure Twine to use a SOCKS5 proxy for uploading packages. It sets the HTTPS_PROXY environment variable specifically for the 'twine upload' command, ensuring other tools are not affected. This is useful for environments requiring proxy access. ```bash HTTPS_PROXY=socks5://user:pass@host:port twine upload dist/* ``` -------------------------------- ### Perform Type Checking with mypy Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Executes `mypy` for strict static type checking on the Twine codebase. Type errors detected by `mypy` must be corrected manually. ```bash tox -e types ``` -------------------------------- ### Run Specific pytest Test in Twine Source: https://github.com/pypa/twine/blob/main/docs/contributing.rst Runs a specific test file or test case within the Twine test suite using `pytest` via tox. This is useful for targeted testing during development. ```bash tox -e py -- tests/test_upload.py::test_exception_for_http_status ``` -------------------------------- ### Disable Keyring for Twine (Bash) Source: https://github.com/pypa/twine/blob/main/docs/index.rst This command disables the keyring integration for Twine. It's useful in scenarios where keyring causes unexpected prompts or issues. Disabling it allows Twine to fall back to interactive password prompts if credentials are not otherwise provided. ```bash keyring --disable ``` -------------------------------- ### Python Version Requirement for Twine Source: https://github.com/pypa/twine/blob/main/docs/changelog.rst Specifies the minimum Python version required for Twine. This highlights the dependency on modern Python features and ensures compatibility with the latest language constructs. ```python python_requires='>=3.6' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.