Skip to main content
Latest version released on PyPi MIT License Test coverage Build status of master branch
SonarCloud Rating SonarCloud Rating SonarCloud Rating

VPK is Valve’s file format for storing game assets. Pythonic access to VPK files and their contents together with a cli tool.

Works on: python2.7, python3.4+, pypy, and pypy3

Install

You can grab the latest release from https://pypi.python.org/pypi/vpk or via pip

pip install vpk

Quick start

The VPK instance is iterable in the standard ways and produces paths to files

import vpk

pak1 = vpk.open("/d/Steam/steamapps/common/dota 2 beta/dota/pak01_dir.vpk")

for filepath in pak1:
    print filepath

Reading a specifc file is done by passing the file path to get_file() method, which returns a VPKFile instance, which acts as a regular file instance. Writting is not possible.

pakfile = pak1.get_file("scripts/emoticons.txt")
pakfile = pak1["scripts/emoticons.txt"]
print pakfile.read().decode('utf-16le')
-------------------------------------------------
"emoticons"
{
    // An ID of zero is invalid

    "1"
    {
        "image_name" "wink.png"
        "ms_per_frame" "100"
...

Saving a file is just as easy.

pakfile.save("./emoticons.txt")

The module supports creating basic VPKs. Multi archive paks are not yet supported.

newpak = vpk.new("./some/directory")
newpak.save("file.vpk")

pak = newpak.save_and_open("file.vpk")

CLI tool

A command line utility is also included

usage: vpk [-h] [--version] [-l] [-la] [-x OUT_LOCATION] [-nd] [-t] [-c DIR]
           [-p] [-f WILDCARD | -re REGEX | -name WILDCARD] [-v]
           file

Manage Valve Pak files

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

Main:
  file                  Input VPK file
  -l, --list            List file paths
  -la                   List file paths, crc, size
  -x OUT_LOCATION, --extract OUT_LOCATION
                        Extract files to directory
  -nd, --no-directories
                        Don't create directries during extraction
  -t, --test            Verify contents
  -c DIR, --create DIR  Create VPK file from directory
  -p, --pipe            Write file contents to stdout

Filters:
  -f WILDCARD, --filter WILDCARD
                        Wildcard filter for file paths
  -re REGEX, --regex REGEX
                        Regular expression filter for file paths
  -name WILDCARD        Filename wildcard filter
  -v, --invert-match    Use filters for exclusion

Looking to decompile Valve custom asset formats?

Check out https://github.com/SteamDatabase/ValveResourceFormat/

Metadata

Release files for vpk 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vpk 1.4.0
File Size Uploaded
vpk-1.4.0.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vpk 1.4.0
File Interpreter ABI Platform
vpk-1.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 22.7 kB

Release files / vpk-1.4.0.tar.gz

Download URL vpk-1.4.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
32ce0a2ca74f29e6b6614dc6e56b7724181c7b011f4de6040a138d4d8fe97040
BLAKE2b-256 checksum
How to use checksums
70d4567a1c46a4c1efc646454868cfffa81e87760663cfddcc28dc9d273fb5ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

Release files / vpk-1.4.0-py2.py3-none-any.whl

Download URL vpk-1.4.0-py2.py3-none-any.whl
Size 11.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
021a40fa28eece9909dfce6f2b55abfd39fff22ac4a4a18ddf7a10afa4c1232f
BLAKE2b-256 checksum
How to use checksums
39b9b87009a8ad0db87d1b14bb0b2b474254b18ba740057f4ba8bae7cc790e5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.12

2 release files

0.11

2 release files

0.10

2 release files

0.9

2 release files

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page