在 GitHub 上編輯此頁面

如何為 Biopython 建立發佈版本。

透過許多小步驟建立 Biopython!

新發佈管理員的必要設定

以下說明要求您具有對一些伺服器和程式碼儲存庫的存取權。開始時,請務必擁有對以下的寫入權限

  1. OBF WordPress 博客
  2. PyPI 上的 Biopython
  3. 這些儲存庫 (例如透過成為「發佈」團隊的成員,或有人準備合併提取請求)

如果您沒有上述任何權限,請詢問。

我們假設您已將這些儲存庫複製到 ~/repositories/ 下,並且 git origin 是 Biopython 官方的儲存庫副本。

我們假設您正在執行 Linux (但 macOS 應該也可以),並且已安裝下列工具 (加上盡可能多的 Biopython 可選相依性以進行本機測試)

  1. Python 3
  2. git
  3. twine,使用 pip install twine 安裝
  4. LaTeX,包括評論和預印本等各種套件。
  5. hevea,我目前使用 2012-07-04 的 2.32 版本

最終提交

  1. 使用 git 確保我擁有最新的程式碼

    $ cd ~/repositories/biopython
    $ git checkout master
    $ git pull origin master
    
  2. 確保 README.rst 檔案仍為最新

  3. 將任何重要資訊新增至 NEWS.rstDEPRECATED.rst - 您可以像這樣取得最近 git 變更的日誌 (請適當調整日期)

    $ git log --since="2020/05/25" --reverse --pretty="medium"
    
  4. 確保 CONTRIB.rst 仍為最新

  5. 確保 setup.pyMANIFEST.in 仍為最新

    • 是否有任何新的模組/檔案應該被安裝?
  6. 更新版本號碼並設定發佈資料

    • Biopython 版本 - 編輯 Bio/__init__.py
    • Biopython NEWS.rst - 填寫發佈日期
    • 請務必將修改過的檔案提交到 github,例如
    $ git commit Bio/__init__.py NEWS.rst -m "Call this Biopython 1.78"
    
  7. 進行最後檢查以確保已簽入內容

    $ rm -r build
    $ rm Tests/*.pyc
    $ make clean -C Doc
    $ git status
    
  8. 建立 Biopython 並執行最後的回歸測試

    drevil:~biopython> python setup.py build
    drevil:~biopython> python setup.py test
    

    同時執行測試 (例如使用不同版本的 Python) 是有風險的,因為兩個執行緒都可能嘗試讀取/寫入相同的臨時檔案。

  9. 將此推送至 github,如果一切順利,此提交將被標記為發佈版本 (除非在建置文件時或在測試 tar 包時發現問題)

   $ git push origin master

建立並測試 tar 包

  1. 在其他地方檢查乾淨的版本

    drevil:~tmp1/> git clone https://github.com/biopython/biopython.git
    drevil:~tmp1/> cd biopython
    
  2. 在 Doc 中建立文件 PDF (我們已自動化線上 HTML 版本;需要安裝 latexmk 等)

    drevil:~tmp1/biopython/> pip install -r .circleci/requirements-sphinx.txt
    drevil:~tmp1/biopython/> make -C Doc latexpdf
    drevil:~tmp1/biopython/> cp Doc/_build/latex/Biopython_doc.pdf Doc/
    drevil:~tmp1/biopython/> make clean -C Doc
    
  3. 建立原始碼發佈版本

    drevil:~tmp1/biopython> python setup.py sdist --formats=gztar,zip
    
  4. 在其他地方解壓縮檔案

    drevil:~tmp1/biopython/> cd ..
    drevil:~tmp1/> tar -xzvf biopython/dist/biopython-1.78.tar.gz
    drevil:~tmp1/> cd biopython-1.78
    

    檢查以確保它包含 Doc 底下的文件 PDF 檔案

  5. 確保我可以建立 (不會安裝和使用此版本) 並測試它 (使用 tar 包測試檔案)

    drevil:~tmp1/biopython-1.78/> python -m pip install .  --prefix /tmp/test-install
    drevil:~tmp1/biopython-1.78/> cd Tests && python run_tests.py
    

    此處 (在測試中) 失敗的常見原因之一是原始碼發佈版本中缺少範例檔案:將它們新增至 MANIFEST.in

檢查編譯的文件

  1. 自 Biopython 1.74 以來,Sphinx 已透過持續整合處理 API 文件,但您仍然必須更新「最新」符號連結。

    $ cd ~/repositories/docs/
    $ git fetch origin
    $ git checkout gh-pages  # should only be this one branch
    $ git rebase origin/gh-pages  # get any changes
    $ rm latest
    $ ln -s 1.78 latest
    $ git commit latest -m "Update 'latest' symlink to point at 1.78"
    $ git push origin gh-pages
    
  2. 手動更新網站上的教學課程和 PDB FAQ。

    • 更新教學課程和 PDB FAQ
      $ cd ~/repositories/DIST/docs/tutorial/
      $ git fetch origin
      $ git checkout gh-pages  # should only be this one branch
      $ git rebase origin/gh-pages  # get any changes
      $ cp ../../../biopython/Doc/biopdb_faq.pdf .
      $ cp ../../../biopython/Doc/Tutorial.html Tutorial-1.80.html
      $ cp ../../../biopython/Doc/Tutorial.pdf Tutorial-1.80.pdf
      $ rm Tutorial.html Tutorial.pdf
      $ ln -s Tutorial-1.80.html Tutorial.html
      $ ln -s Tutorial-1.80.pdf Tutorial.pdf
      $ git add Tutorial-1.80.html Tutorial-1.80.pdf
      $ git commit Tutorial-1.80.html Tutorial-1.80.pdf Tutorial.html Tutorial.pdf biopdb_faq.pdf -m "Tutorial and FAQ for Biopython 1.80"
    
    • 將此推送至 GitHub Pages 以更新網站
      $ git push origin gh-pages
    

建立 Wheel

  1. 現在我們使用 https://github.com/biopython/biopython-wheels 來建置 Wheel,方法是將 .github/workflows/cibuildwheel.yml 中的 git checkout 行更新為新發佈版本的提交雜湊 (如果一切順利,將會取得 git 標籤)。

    $ cd ~/repositories
    $ git clone git@github.com:biopython/biopython-wheels.git
    $ cd biopython-wheels/
    $ git submodule update --init
    $ emacs .github/workflows/cibuildwheel.yml  # update git checkout line
    $ git commit .github/workflows/cibuildwheel.yml -m "Build Biopython 1.xx"
    $ git push origin master
    

    檢查 Wheel 是否在 GitHub Actions 執行上建置。

    您似乎不需要更新 biopython git 子模組,但如果您需要,這似乎可以運作。

    $ git submodule foreach git pull origin master
    $ git commit -a -m "Update submodules"
    $ git push origin master
    
  2. 成功的 Wheel 將會在 GitHub Actions 執行的頁尾中,透過 artifact.zip 檔案提供。將此檔案下載並解壓縮到您的 ~/repository/biopython/DIST/ 資料夾。我們稍後將使用 Twine 將這些檔案上傳到 PyPI。

  3. 如果您有 Windows 電腦,請移除任何先前的 Biopython 安裝,並確認 Windows Wheel 檔案是否運作。

標記發佈版本並上傳

  1. 回到主要儲存庫,標記發佈版本

    $ cd  .../tmp1/biopython/
    $ git tag biopython-178
    $ git push origin master --tags
    
  2. 透過 GitHub Pages DIST 儲存庫將新的發佈 tar 包和 zip 上傳到網站。

    $ cp dist/biopython-1.78.* ~/repositories/DIST/
    $ cd ~/repositories/DIST/
    $ git add biopython-1.78.*
    $ git commit biopython-1.78.* -m "Downloads for Biopython 1.78"
    $ shasum -a 256 biopython-1.78.*
    $ md5sum biopython-1.78.*
    $ git commit --amend # paste checksums into comment
    $ git push origin gh-pages
    
  3. 上傳到 python 套件索引 (beta/alpha 等級版本除外)

    $ cd  ~/repositories/biopython/
    $ pip install twine
    $ twine upload dist/biopython-1.78.tar.gz
    $ twine upload dist/biopython-1.78-*.whl
    
  4. 更新網站

    • 如果您尚未執行此操作,請複製 biopython.github.io 儲存庫,(否則請確保您的副本為最新)
    $ cd ~/repositories
    $ git clone git@github.com:biopython/biopython.github.io.git
    
    $ cd ~/repositories/biopython.github.io
    $ emacs _config.yml
    $ emacs wiki/Biopython.md
    $ emacs wiki/Download.md
    $ git commit _config.yml wiki/Biopython.md wiki/Download.md -m "Biopython 1.78 released"
    
    • 在您宣佈發佈版本之前,請務必將您的公告文字傳送至 Biopython 郵件列表以進行校對/最終更正。
    • 確保下載連結可運作。
  5. 公告

    • www.open-bio.org 博客上發佈公告 (請務必使用 Biopython 類別,這將透過新聞摘要更新新聞頁面)
    • 傳送電子郵件至 biopython-announce@biopython.org (請參閱 郵件列表)
    • 將電子郵件轉寄給 Linux 封裝人員,例如 debian-med@lists.debian.org
  6. 一旦 Conda-Forge 出現在 PyPI 上,它應該會自動開啟提取請求以更新套件。請在 github.com/conda-forge/biopython-feedstock 上檢查是否有新的提取請求,一旦合併,它會將新版本上傳到 anaconda.org/conda-forge/biopython

發佈後版本更新

  1. 再次更新版本號碼

    • 更新 Bio/__init__.py 版本
    • NEWS.rst 中開始下一個版本的條目
    • 請務必將修改過的檔案提交到 github。

    加入後綴 .dev0 表示這是開發版本,例如,如果您有 __version__ = "1.78",請將其變更為 1.79.dev0