Source Code Compilation and Build
Obtain the Transformers source code, build a wheel from the source package, and install the build product.
- Obtain the Transformers 5.4.0 source code.
1 2 3
mkdir -p /tmp/transformers-build/dist python3 -m pip download --no-binary=:all: --no-deps \ --dest /tmp/transformers-build transformers==5.4.0
--no-binary=:all: is used to disable the download of the precompiled wheel and ensure that the source package is obtained and local build is performed.
- Build the wheel from the source package.
1 2 3
python3 -m pip wheel --no-build-isolation --no-binary=:all: --no-deps \ --wheel-dir /tmp/transformers-build/dist \ /tmp/transformers-build/transformers-5.4.0.tar.gz
- Install the running dependencies and local build product.
1 2 3
python3 -m pip install numpy==2.4.6 pyyaml regex requests tokenizers==0.22.2 \ safetensors==0.7.0 tqdm filelock huggingface-hub packaging python3 -m pip install --no-index --find-links /tmp/transformers-build/dist transformers==5.4.0
The following is an example of the build product.
1transformers-5.4.0-py3-none-any.whl
Parent topic: Developer Guide