Skip to content

To demonstrate automatic release and publish the package.

Notifications You must be signed in to change notification settings

zcemycl/pypack-guide

Repository files navigation

pypack-guide

Setup

  1. Git clone the repository.
    git clone https://github.com/zcemycl/pypack-guide.git
    
  2. Add multiple remote repositories.
    git remote set-url origin --push --add https://github.com/zcemycl/pypack-guide.git
    git remote set-url origin --push --add https://[email protected]/leoleung0900/pypack-guide/_git/pypack-guide
    git remote set-url origin --push --add https://[email protected]/leoleung0900/dummy/_git/dummy
    
  3. Install testing env.
    pip install -e '.[testing]'
    
  4. Set up precommit hook.
    pip install pre-commit
    pre-commit install
    pre-commit run
    pre-commit run --all-files
    
  5. Start contributing!!
    git add .
    git commit -m 'message'
    git push
    

Push package

  1. Build the package.
    python setup.py sdist bdist_wheel
    
  2. Upload to pypi website.
    python -m twine upload dist/*
    twine upload dist/* -u** -p**
    
  3. Upload to azure devops.
    python -m twine upload -r leoleung0900 --config-file .pyazrc dist/*
    twine upload -r pypack-guide --config-file .pyazrc dist/*
    

Install package

  1. Install from public pypi package.
    pip install pypack-guide
    
  2. Install from private azure package.
    pip install pypack-guide==0.1.dev23 \
        --index-url https://<your-feed-name>:<pat-key>@pkgs.dev.azure.com/leoleung0900/_packaging/leoleung0900/pypi/simple
    # or
    pip install pypack-guide --extra-index-url=https://<your-feed-name>:<pat-key>@pkgs.dev.azure.com/leoleung0900/pypack-guide/_packaging/leoleung0900/pypi/simple/
    

Release and Publish Package

  1. Create new release.
    git tag v0.0.0
    git push origin v0.0.0
    
  2. Update the release with specific tag.
    git checkout v0.0.0
    # make changes
    git commit -am 'commit messages'
    git tag -f v0.0.0
    git push origin --delete v0.0.0
    git push origin v0.0.0
    

Notes

  1. Twine upload to azure devops step can be used in github action too.
  2. Need requirement.txt and conda.yml testings for installation.
  3. Azure Devops check in branches can be ignored.

References

  1. Twine Documentation
  2. Get started with Python packages in Azure Artifacts
  3. Automate PyPi releases with Github Actions
  4. “tag already exists in the remote" error after recreating the git tag
  5. GitHub Action Automatic Releases
  6. How to Publish a Python Package from GitHub Actions
  7. Git tag
  8. Publish Python packages with Azure Pipelines
  9. Publish and download pipeline Artifacts