CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-nodeenv

Node.js virtual environment builder for creating isolated Node.js environments

80

1.25x
Overview
Eval results
Files

node-install.mddocs/

Node.js Installation

Node.js version management and installation functionality including downloading prebuilt binaries, building from source code, and copying installations with platform-specific optimizations.

Capabilities

Node.js Installation

Primary function for installing Node.js in a virtual environment, supporting both prebuilt binaries and source compilation.

def install_node(env_dir, src_dir, args):
    """
    Install Node.js in the virtual environment.
    
    Parameters:
    env_dir (str): Environment directory path
    src_dir (str): Source/download directory path  
    args (argparse.Namespace): Configuration arguments
    
    Installs Node.js using the method specified in args:
    - Prebuilt binaries (default, faster)
    - Source compilation (slower, more compatible)
    - System Node.js (symlink to existing installation)
    
    Handles platform-specific installation procedures and
    configures the Node.js installation for the environment.
    """

Wrapped Node.js Installation

Wrapper function for Node.js installation with enhanced error handling and logging.

def install_node_wrapped(env_dir, src_dir, args):
    """
    Install Node.js with enhanced error handling and progress reporting.
    
    Parameters:
    env_dir (str): Environment directory path
    src_dir (str): Source/download directory path
    args (argparse.Namespace): Configuration arguments
    
    Provides a wrapper around install_node with:
    - Enhanced error reporting and recovery
    - Progress indication during installation
    - Cleanup on installation failure
    - Validation of successful installation
    """

Prebuilt Binary Installation

Copies Node.js from prebuilt binary distributions for fast installation.

def copy_node_from_prebuilt(env_dir, src_dir, node_version):
    """
    Copy Node.js from prebuilt binary distribution.
    
    Parameters:
    env_dir (str): Target environment directory
    src_dir (str): Directory containing downloaded binaries
    node_version (str): Node.js version being installed
    
    Extracts and copies prebuilt Node.js binaries to the environment.
    Handles platform-specific binary formats and directory structures.
    Configures executable permissions and creates necessary symlinks.
    """

Source Code Compilation

Builds Node.js from source code with custom compilation options.

def build_node_from_src(env_dir, src_dir, node_src_dir, args):
    """
    Build Node.js from source code.
    
    Parameters:
    env_dir (str): Target environment directory
    src_dir (str): Source download directory  
    node_src_dir (str): Node.js source code directory
    args (argparse.Namespace): Build configuration arguments
    
    Compiles Node.js from source with options:
    - Custom compilation flags
    - SSL support configuration (--without-ssl)
    - Parallel build jobs (--jobs)
    - Platform-specific optimizations
    
    Provides more control and compatibility at the cost of build time.
    """

URL Generation

Utility functions for generating download URLs for Node.js binaries and source code.

def get_node_bin_url(version):
    """
    Get download URL for Node.js prebuilt binary.
    
    Parameters:
    version (str): Node.js version (e.g., '16.20.0')
    
    Returns:
    str: Download URL for platform-appropriate binary
    
    Generates URLs based on:
    - Platform detection (Linux, macOS, Windows)
    - Architecture detection (x64, arm64, etc.)
    - Special handling for musl and RISC-V systems
    """

def get_node_src_url(version):
    """
    Get download URL for Node.js source code.
    
    Parameters:
    version (str): Node.js version
    
    Returns:
    str: Download URL for source tarball
    """

def get_root_url(version_str):
    """
    Get root URL for Node.js downloads based on version.
    
    Parameters:
    version_str (str): Node.js version string
    
    Returns:
    str: Base URL for Node.js downloads
    
    Handles different download sources and mirrors.
    """

def get_root_url(version_str):
    """
    Get root URL for Node.js downloads based on version.
    
    Parameters:
    version_str (str): Node.js version string
    
    Returns:
    str: Base URL for Node.js downloads
    
    Adjusts URL structure based on Node.js version (pre/post 0.5).
    Handles different download sources and mirrors.
    """

def get_node_src_url(version):
    """
    Get download URL for Node.js source code.
    
    Parameters:
    version (str): Node.js version
    
    Returns:
    str: Download URL for source tarball
    
    Constructs complete URL for downloading Node.js source code
    tarball based on version and root URL structure.
    """

Source Download

Downloads Node.js source code or prebuilt binaries from remote repositories.

def download_node_src(node_url, src_dir, args):
    """
    Download Node.js source or binary distribution.
    
    Parameters:
    node_url (str): Download URL
    src_dir (str): Target download directory
    args (argparse.Namespace): Configuration arguments
    
    Downloads and extracts Node.js distributions with:
    - Progress reporting
    - Retry logic for failed downloads
    - Checksum verification (when available)
    - Proxy support
    """

Usage Examples

Install Latest Node.js

import nodeenv
from argparse import Namespace

args = Namespace(
    node='latest',
    source=False,  # Use prebuilt binaries
    without_ssl=False,
    jobs='2'
)

nodeenv.install_node('/path/to/env', '/tmp/nodeenv-src', args)

Build from Source with Custom Options

import nodeenv  
from argparse import Namespace

args = Namespace(
    node='16.20.0',
    source=True,  # Build from source
    without_ssl=True,  # Disable SSL
    jobs='4'  # Use 4 parallel jobs
)

nodeenv.install_node('/path/to/env', '/tmp/nodeenv-src', args)

Install with Tessl CLI

npx tessl i tessl/pypi-nodeenv

docs

cli.md

configuration.md

environment.md

index.md

node-install.md

package-management.md

utilities.md

version-management.md

tile.json