【问题标题】:What is the Best Practice or most efficient way to update custom python modules in pythonanywhere?在 pythonanywhere 中更新自定义 python 模块的最佳实践或最有效的方法是什么?
【发布时间】:2013-12-03 09:42:38
【问题描述】:

对于 PythonAnywhere:

我目前正在构建一个项目,我必须经常更改我已安装的包之一(因为我在构建项目时添加到包中)。每次我在本地进行更改时,在 BASH 控制台中不断更新软件包并重新安装软件包是非常手动和费力的。有没有更好的流程?

【问题讨论】:

  • 澄清一下:您是在自己的 PC 上开发包,而不是在 PythonAnywhere 上?然后将其推送到 PyPI 或 github(哪个?),然后将其拉到 PythonAnywhere? (通过 pip 或 git?)
  • 所以我想你回答了我的问题。我可以在 PA 和 github 之间建立连接吗?所以这个过程可能看起来像这样:在本地对包进行更改,然后在 github 上更新它。然后 Github 会将包更新推送到 pythonanywhere。这行得通吗?
  • 您当然可以从 PA 上的 github 上下载代码,但不能以自动方式(或至少不直接)。更好的选择可能是将 PA 用作 git repo。会回答的。

标签: python module pythonanywhere


【解决方案1】:

听起来您希望能够使用本地计算机上的单个命令来将一些更改推送到 PythonAnywhere,一种方法是将 PythonAnywere 用作 git 远程。 this post 中有一些细节,但是,概括地说:

username@PythonAnywhere:~$ mkdir my_repo.git
username@PythonAnywhere:~$ cd my_repo.git
username@PythonAnywhere:~$ git init --bare

然后,在您的 PC 上:

git remote add pythonanywhere username@ssh.pythonanywhere.com:my_repo.git

然后你应该能够从你的机器上推送到 PA 上的裸仓库

git push pythonanywhere master

然后,您可以使用Git post-receive hook 以您喜欢的任何方式在 PythonAnywhere 上更新包。一种可能是让您的包在 PythonAnywhere 上签出:

username@PythonAnywhere:~$ git clone my_package ./my_repo.git

然后 post-receive 钩子可以很简单

cd ~/my_package && git pull

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    • 2015-11-22
    相关资源
    最近更新 更多