【问题标题】:How to upload and install Python Library using Github repository如何使用 Github 存储库上传和安装 Python 库
【发布时间】:2021-11-13 23:36:13
【问题描述】:

我需要将我的 python 库上传到 Github 存储库并尝试使用安装它

pip 安装我的存储库名称

我该怎么做?

注意:我将 setup.py、Licence.txt 和 Manifest.in 文件添加到

它只安装信息文件,这是存储库: https://github.com/zieadshabkalieh/oauth2clientz

【问题讨论】:

标签: python github pip pypi


【解决方案1】:

通过这种方式,您可以从Github 存储库安装python 包:

pip install "git+https://github.com/your_repository_name"

【讨论】:

  • 它只安装信息文件而不是库@hmn Falahi
  • 这可能意味着您的setup.py 有缺陷。
  • @tripleee 也许这就是问题所在,但我制作 setup.py 就像我从文档中了解到的那样有什么问题这是我的 setup.py 文件:github.com/zieadshabkalieh/oauth2clientz/blob/main/setup.py
  • 您导入了find_packages,但从不将其用于任何事情。但不要在评论线程中提出新问题;相反,如果您无法弄清楚,请提出一个新问题。
【解决方案2】:

您需要设置 GitHub 操作。 Here are some docs.

特别是你可能想要看起来像这样的东西:

name: Python application

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.9
      uses: actions/setup-python@v2
      with:
        python-version: 3.9
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

如果你想上传到 PyPi(即让你的包pip package-name install-able,那就有点复杂了:

  • 设置 PyPi 帐户。
  • pip install wheel twine,
  • 在项目的根目录运行python setup.py sdist bdist_wheel
  • python -m twine upload "dist/*"
  • 进行身份验证,您就完成了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 2022-12-04
    • 2020-09-19
    • 2021-01-17
    • 2021-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多