推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
black11black
V2EX  ›  Python

Python , Github 上传仓库的代码有办法自动同步到 pypi 吗 ?

  •  
  •   black11black · Feb 6, 2020 · 4197 views
    This topic created in 2315 days ago, the information mentioned may be changed or developed.

    如题,我觉得 pypi 是个挺好的包管理器,每次新换到一台机器上不用安装任何其他工具都能直接拉取想要的代码,都感觉很爽。

    最近遇到一个问题是我更新 repo 肯定是在 github 做的,但代码每次都需要手动再同步到 pypi 一份,非常麻烦,除非我不想保持最新了。请问各位带佬有什么方案能自动让 gh 同步到 pypi 吗 ?感觉上应该是需要一些自动测试服务自动运行一些上传代码?没了解过这方面,求问。

    如果能每次 commit 都自动更新版本号就更好了...

    9 replies    2020-02-09 10:58:43 +08:00
    malusama
        1
    malusama  
       Feb 6, 2020
    actions
    locoz
        2
    locoz  
       Feb 6, 2020 via Android
    各种 cicd 工具了解一下,就是个自动发布的事嘛
    black11black
        3
    black11black  
    OP
       Feb 7, 2020
    @locoz
    感谢,研究了一下 travis 感觉很好用

    顺便,有办法能自动更新版本号吗?
    locoz
        4
    locoz  
       Feb 7, 2020
    @black11black #3 一般会有个自增的环境变量,或者是可以自己写脚本实现自增
    msg7086
        5
    msg7086  
       Feb 7, 2020
    版本号可以通过计算历史提交数来实现。

    参考: https://github.com/msg7086/x265-Yuuki-Asuna/blob/Yuuki/source/version.rb
    tikazyq
        7
    tikazyq  
       Feb 7, 2020
    actions
    ihciah
        8
    ihciah  
       Feb 7, 2020
    版本可以用 git tag 管理。
    yucongo
        9
    yucongo  
       Feb 9, 2020
    - name: Build Python package
    run: |
    pip install wheel twine; python setup.py sdist bdist_wheel
    - name: Twine check
    run: |
    twine check dist/*
    - name: Publish to PyPI
    env:
    TWINE_USERNAME: ${{ secrets.PYPI_USER }}
    TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
    run: |
    twine upload dist/* --skip-existing

    github action workflow 供你参考
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5519 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 06:07 · PVG 14:07 · LAX 23:07 · JFK 02:07
    ♥ Do have faith in what you're doing.