You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为私有仓库集成PyInstaller与PyUpdater更新功能?

Can PyUpdater Integrate with Private BitBucket Repositories?

Absolutely! PyUpdater does support private BitBucket repositories—you just need to fix a few configuration and code issues. Let’s walk through the solutions step by step, starting with the problems in your current setup, then the correct implementation.

First, Let’s Fix Your Existing Issues

Looking at your config and code, here are the key blockers:

  1. Your PUBLIC_KEY is set to 'None'—PyUpdater requires a valid public key (generated during your PyUpdater packaging workflow) to verify update signatures.
  2. You’re re-initializing the Client multiple times, overwriting your SSH config each time.
  3. Your SSH key handling is broken (you pasted raw key content incorrectly instead of loading it properly).
  4. ASSET_NAME and ASSET_VERSION are undefined, which will throw errors when checking for updates.
  5. Your UPDATE_URLS path is invalid—BitBucket private repos use standard Git URLs, not a custom /download path.

Step 1: Set Up BitBucket SSH Key

You already generated an SSH key with ssh-keygen -t rsa -C "youremail@example.com"—now:

  • Copy your public key (~/.ssh/id_rsa.pub content)
  • Add it to your BitBucket account: Go to BitBucket Settings → SSH keys → Add key
  • Ensure your private key (id_rsa) is unencrypted, or set up ssh-agent to auto-unlock it if it has a passphrase.

Step 2: Update Your Client Config

Modify client_config.py to specify Git as the provider and your BitBucket repo SSH URL:

class ClientConfig(object):
    # Replace with your actual PyUpdater public key (not 'None')
    PUBLIC_KEY = 'your-generated-pyupdater-public-key'
    APP_NAME = 'dad123'
    COMPANY_NAME = 'dad123'
    # Tell PyUpdater to use Git as the update source
    PROVIDER = 'git'
    # Your BitBucket repo SSH URL (replace with your actual repo path)
    UPDATE_URLS = ['git@bitbucket.org:Tysondogerz/your-repo-name.git']
    MAX_DOWNLOAD_RETRIES = 3

Step 3: Fix Your Main Script

Clean up the redundant Client initializations and properly load your SSH key:

#!/usr/bin/env python3
from __future__ import print_function
import os
import sys
import logging
from selenium import webdriver
from client_config import ClientConfig
from pyupdater.client import Client

# Configure logging
logging.basicConfig(level=logging.DEBUG)

def load_ssh_key(key_path):
    """Load SSH private key from file"""
    with open(key_path, 'r') as f:
        return f.read()

def print_status_info(info):
    """Show download progress"""
    total = info.get('total')
    downloaded = info.get('downloaded')
    status = info.get('status')
    print(f"{downloaded}/{total} - {status}")

def main():
    # Load your SSH private key (adjust path if needed)
    ssh_key_path = os.path.expanduser('~/.ssh/id_rsa')
    ssh_config = {
        'ssh_key': load_ssh_key(ssh_key_path),
        # Uncomment below if your key has a passphrase
        # 'passphrase': 'your-key-passphrase'
    }

    # Initialize Client ONCE with SSH config
    client = Client(
        ClientConfig(),
        ssh=ssh_config,
        refresh=True,
        progress_hooks=[print_status_info]
    )

    # Check for updates (replace with your app name and current version)
    ASSET_NAME = 'dad123'
    ASSET_VERSION = '1.0.0'
    app_update = client.update_check(ASSET_NAME, ASSET_VERSION)
    # Use this line instead to check beta channel updates:
    # app_update = client.update_check(ASSET_NAME, ASSET_VERSION, channel='beta')

    if app_update is not None:
        print("Update found! Starting download...")
        app_update.download()
        print("Download complete. Installing update...")
        app_update.install()
        print("Update installed. Restarting app...")
        sys.exit(0)
    else:
        print("You're already on the latest version.")

    # Your existing app logic
    driver = webdriver.Firefox()
    driver.get('http://stackoverflow.com')

if __name__ == "__main__":
    main()

Solution 2: HTTPS with BitBucket App Password (Simpler)

If SSH feels too complex, use a BitBucket App Password:

  1. Go to BitBucket Settings → App passwords → Create app password
  2. Grant the Repository read permission, then save the generated password.
  3. Update your ClientConfig with the HTTPS URL containing your credentials:
    class ClientConfig(object):
        PUBLIC_KEY = 'your-generated-pyupdater-public-key'
        APP_NAME = 'dad123'
        COMPANY_NAME = 'dad123'
        PROVIDER = 'git'
        # Format: https://{username}:{app-password}@bitbucket.org/{username}/{repo-name}.git
        UPDATE_URLS = ['https://your-bitbucket-username:your-app-password@bitbucket.org/Tysondogerz/your-repo-name.git']
        MAX_DOWNLOAD_RETRIES = 3
    
  4. In your main script, you don’t need SSH config—just initialize the Client normally:
    client = Client(ClientConfig(), refresh=True, progress_hooks=[print_status_info])
    

Final Testing Steps

  1. Make sure your BitBucket repo contains the PyUpdater-generated update files (like updates.json, dad123-1.0.1.tar.gz, etc.).
  2. Repackage your app with the fixed config and code.
  3. Run the packaged app—you should see it successfully check for and download updates from your private BitBucket repo.

内容的提问来源于stack exchange,提问作者user9155788

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:50:25