V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
find456789
V2EX  ›  问与答

Python 如何在管理常用的公共库呢?

  •  
  •   find456789 · Nov 22, 2018 · 2003 views
    This topic created in 2719 days ago, the information mentioned may be changed or developed.

    mac,

    python3,

    经常写代码, 会有一些重复代码在不同项目中,

    每次使用都要复制文件到对应项目,感觉很费神,

    有什么自动化,或者更聪明的办法吗

    谢谢

    5 replies    2018-11-22 20:16:47 +08:00
    ipwx
        1
    ipwx  
       Nov 22, 2018   ❤️ 1
    添加 setup.py
    然后用上 requirements.txt
    find456789
        2
    find456789  
    OP
       Nov 22, 2018
    @ipwx
    谢谢, 感觉好像更复杂了, 这些代码片段是我自己写的, 没有发布到 pypi
    noobsheldon
        3
    noobsheldon  
       Nov 22, 2018 via Android
    git submodule
    andylsr
        4
    andylsr  
       Nov 22, 2018 via Android
    自己打包~
    ipwx
        5
    ipwx  
       Nov 22, 2018
    @find456789 pip 可以直接安装某个目录,或者某个 git repo。

    比如 pip install git+https://github.com/haowen-xu/tfsnippet.git
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2587 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 12:30 · PVG 20:30 · LAX 05:30 · JFK 08:30
    ♥ Do have faith in what you're doing.