Linux command
twine 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Upload package to PyPI
twine upload dist/*
Upload to TestPyPI
twine upload --repository testpypi dist/*
Upload with credentials
twine upload -u [username] -p [password] dist/*
Check package before upload
twine check dist/*
Upload specific files
twine upload [dist/package-1.0.tar.gz]
Upload with verbose output
twine upload --verbose dist/*
说明
twine uploads Python packages to PyPI and other package indexes. It's the recommended tool for publishing Python packages. Package files (.tar.gz and .whl) in the dist directory are uploaded. These are created by build tools like build or setuptools. Check mode validates package metadata before upload. It catches common issues that would cause upload failure. TestPyPI allows testing the upload process without affecting the real PyPI. Packages can be installed from TestPyPI to verify. Authentication uses username/password, API tokens, or keyring integration. API tokens are recommended for security. HTTPS is always used for uploads. Previous tools allowed insecure uploads, which twine explicitly prevents.
参数
- upload _FILES_
- Upload packages.
- check _FILES_
- Check package metadata.
- -r _REPO_, --repository _REPO_
- Target repository (pypi, testpypi, or URL).
- --repository-url _URL_
- Repository URL.
- -u _USER_, --username _USER_
- Username.
- -p _PASS_, --password _PASS_
- Password.
- --non-interactive
- Don't prompt for credentials.
- -s, --sign
- Sign files with GPG.
- -c _FILE_, --config-file _FILE_
- Config file.
- --skip-existing
- Skip already-uploaded files.
- --verbose
- Verbose output.
FAQ
What is the twine command used for?
twine uploads Python packages to PyPI and other package indexes. It's the recommended tool for publishing Python packages. Package files (.tar.gz and .whl) in the dist directory are uploaded. These are created by build tools like build or setuptools. Check mode validates package metadata before upload. It catches common issues that would cause upload failure. TestPyPI allows testing the upload process without affecting the real PyPI. Packages can be installed from TestPyPI to verify. Authentication uses username/password, API tokens, or keyring integration. API tokens are recommended for security. HTTPS is always used for uploads. Previous tools allowed insecure uploads, which twine explicitly prevents.
How do I run a basic twine example?
Run `twine upload dist/*` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does upload _FILES_ do in twine?
Upload packages.