Skip to main content

Lightweight Microsoft Visual C++ build tools for Python

Project description

MSVCLib

PyPI version Python Support License

English | 中文


中文

背景

在安装某些 Python 第三方包时,如果仓库中只有源码包且包含 C 语言代码,可能会遇到以下错误:

error: microsoft visual c++ 14.0 or greater is required. get it with "microsoft c++ build tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

按照提示安装完整的 Visual Studio 会占用至少 6GB 的磁盘空间,这对于仅需要编译工具的用户来说过于臃肿。

解决方案

MSVCLib 基于 PortableBuildTools 项目,提供了一个轻量级的解决方案。它将必要的 Microsoft Visual C++ 构建工具打包成 Python wheel,可通过 pip 轻松安装。

安装

使用 pip 安装

pip install msvclib

推荐:全局安装或使用 uv

uv tool install msvclib

使用方法

当遇到 Microsoft Visual C++ 14.0 相关错误时,只需运行初始化命令:

msvcinit

初始化完成后,即可正常编译需要 C++ 构建工具的 Python 包。

优势

  • 轻量级:相比完整的 Visual Studio 安装,占用空间极小
  • 便携性:无需管理员权限,可在任何环境中使用
  • 简单易用:一条命令即可解决编译问题

English

Background

When installing certain Python third-party packages that contain only source code with C language components, you might encounter this error:

error: microsoft visual c++ 14.0 or greater is required. get it with "microsoft c++ build tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

Installing the full Visual Studio as suggested would consume at least 6GB of disk space, which is excessive for users who only need the build tools.

Solution

MSVCLib is based on the PortableBuildTools project and provides a lightweight solution. It packages the necessary Microsoft Visual C++ build tools into a Python wheel that can be easily installed via pip.

Installation

Install with pip

pip install msvclib

Recommended: Global installation or using uv

uv tool install msvclib

Usage

When encountering Microsoft Visual C++ 14.0 related errors, simply run the initialization command:

msvcinit

After initialization, you can compile Python packages that require C++ build tools without issues.

Advantages

  • Lightweight: Minimal disk space usage compared to full Visual Studio installation
  • Portable: No administrator privileges required, works in any environment
  • Easy to use: One command solves compilation issues

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

msvclib-0.2.1-py3-none-any.whl (326.0 MB view details)

Uploaded Python 3

File details

Details for the file msvclib-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: msvclib-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 326.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for msvclib-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38afb322275b7a1fbff7dd0036f1112acd2719f69e0e2cd25f45f84dd4130e8e
MD5 91c28327f79e744461ea3fe005b7032b
BLAKE2b-256 efb390a12b5aa227f6f2885e3fde67347d87ea595274184621e7bd162be7b20b

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