Skip to main content

This tool helps administrator to download python packages from a requirements.txt. The downloaded package can be import to an air-capped server

Project description

build-pyenv

The build-pyenv tool is a high-performance CLI tool designed to prepare Python environments for air-gapped or restricted-network servers. It automates the process of downloading, building (if necessary), and caching Python packages files(.whl) and their dependencies.

โœจ Key Features

  • Smart Caching: Tracks successfully downloaded packages in a .cache_pkg file to skip redundant work.
  • Automatic Build: If the required package does not provide a .whl file, it will build them from source locally and generate the .whl file.
  • Detailed Logging: Separate output.log for full process history and error.log for quick troubleshooting.
  • Modern CLI: Built with Typer for a polished terminal experience and shell auto-completion.
  • Air-Gap Ready: Resolves and bundles all sub-dependencies, ensuring your offline installation is complete.

๐Ÿš€ Quick Start

This tool is released as a python package and executable. You need to have python and pip to install it.

Build your local environment

As we mentioned before, this tool may build locally the .whl files. So if the OS, CPU architecture or python version of your build environment are not compatible with the target machine, the downloaded or generated .whl will not be compatible in the target machine. The python version which you use to run the tool will define the downloaded installed

Before build your local environment, check the below things:

  • What is the OS of your target machine? (e.g. Windows, Linux, MacOS)
  • What is the CPU architecture of your target machine? (e.g. x86, ARM, etc.)
  • What is the python version of your target python environment (e.g. 3.11, 3.12, etc.)

For example if you target environment is a Windows Server 2019 with x86 CPU and python 3.11. Your local environment should also be Windows, x86, and python 3.11.

We recommend you to use a virtual environment to run the tool. Your local environment must have internet access.

For example, you can create a virtual environment for python 3.11 with conda.

conda create --name my_test python=3.11

Installation

Here we suppose you already have the required python, pip and virtual environment.

pip install build-pyenv

Basic Usage

After installation, you can view all available options of the tool with build-pyenv.exe --help

> build-pyenv.exe --help                  
                                                                                                                                                                                                                                                                                                                    
 Usage: build-pyenv [OPTIONS]                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                    
 Main command to download and cache python packages.                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                    
โ•ญโ”€ Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ *  --requirements        -r      FILE       Path to the requirements.txt file. [required]                                                                                                                                                                                                                        โ”‚
โ”‚    --output              -o      DIRECTORY  Directory to store downloaded wheels. [default: ./target]                                                                                                                                                                                                            โ”‚
โ”‚    --logs                -l      PATH       Directory to store log files. [default: ./logs]                                                                                                                                                                                                                      โ”‚
โ”‚    --install-completion                     Install completion for the current shell.                                                                                                                                                                                                                            โ”‚
โ”‚    --show-completion                        Show completion for the current shell, to copy it or customize the installation.                                                                                                                                                                                     โ”‚
โ”‚    --help                                   Show this message and exit.                                                                                                                                                                                                                                          โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

The only required option is -r, user must provide a requirements.txt file which specifies all the required python packages. The syntax of the requirements.txt is the standard syntax rules defined by PEP 508.

For example, if you have a requirements.txt like

pandas
numpy

When you run the tool, you should see the below outputs

(my_test) C:\Users\toto\Documents\tmp>build-pyenv.exe -r requirements.txt
INFO: Logging initialized. Errors -> error.log, All -> output.log
๐Ÿš€ Starting build process...
INFO: Starting download packages to: C:\Users\toto\Documents\tmp\target
INFO: Processing: pandas...
INFO: [OK] pandas is ready in C:\Users\toto\Documents\tmp\target
INFO: Processing: numpy...
INFO: [OK] numpy is ready in C:\Users\toto\Documents\tmp\target
INFO: Cache updated at C:/Users/toto/Documents/tmp/target/.cache_pkg (Total: 2 packages)
INFO: Wheel files are stored in: C:/Users/toto/Documents/tmp/target/pkgs
INFO: --- All done! ---
โœจ Success! Wheels are in C:\Users\toto\Documents\tmp\target

If you don't specify the output dir and log path, the tool will create a default output dir target, and a default log dir logs in the current directory.

๐Ÿ›  Workflow for using the output packages

To use the output packages in an Air-Gapped Server:

  1. Copy the folder pkgs to the target server.
  2. In the target server, activate your python virtual environment
  3. run pip install --no-index --find-links ./pkgs -r requirements.txt

Project details


Download files

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

Source Distribution

build_pyenv-0.2.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

build_pyenv-0.2.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file build_pyenv-0.2.0.tar.gz.

File metadata

  • Download URL: build_pyenv-0.2.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for build_pyenv-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f67a2eceab38be344f5d329116fc1e5b000a6b680e6ca0ce97e34b907b5d5e05
MD5 37455d8cc9722ae6af55782b8ff7df45
BLAKE2b-256 958e8d81772c6c0b865ddf3e46f67ea70d672f025236d0d1488b0d4264f97067

See more details on using hashes here.

File details

Details for the file build_pyenv-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: build_pyenv-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for build_pyenv-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82877f223718f420e68921e6bb227d2aa67a2a72f88b4a8bdb66bd822fb9da2d
MD5 2c3efa17edc4767ece9ab1ca0e8c437e
BLAKE2b-256 2821177b36b906564866b67737567b0ee66c8c960601b758e35c177db668d865

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