Skip to main content

Helper to build and upload a project that used poetry to PyPi, with prechecks

Project description

about poetry-publish

Helper to build and upload a project that used poetry to PyPi, with prechecks:

  • User must confirm:

    • If __version__ contains ‘dev’ or ‘rc’

    • If git repository is not on master

  • Abort publish if git repository contains changes

  • Abort if git repository is not up-to-date

  • Abort if poetry check fails

  • Abort if git version tag already exists

After a successfull upload to PyPi:

  • create a git version tag

  • git push tag to remote server

Compatible Python Versions (see tox.ini or .travis.yml):

  • 3.8, 3.7, 3.6

  • PyPy3

Build Status on github

github.com/jedie/poetry-publish/actions

Build Status on travis-ci.org

travis-ci.org/jedie/poetry-publish

Coverage Status on codecov.io

codecov.io/gh/jedie/poetry-publish

Status on landscape.io

landscape.io/github/jedie/poetry-publish/master

PyPi version

pypi.org/project/poetry-publish/

example

~/repos/python-creole$ poetry run publish

Check if we are on "master" branch:
    Call: 'git branch --no-color'
OK

Set version in "pyproject.toml" to: v1.4.3
    Call: 'poetry version 1.4.3'

Bumping version from 1.4.3 to 1.4.3

check if if git repro is clean:
    Call: 'git status --porcelain'
OK

Run "poetry check":
OK

check if pull is needed
    Call: 'git fetch --all'

Fordere an von origin
    Call: 'git log HEAD..origin/master --oneline'
OK
    Call: 'git push'

Everything up-to-date

Cleanup old builds:
    remove tree: /home/jens/repos/python-creole/dist

build but do not upload...
    Call: 'poetry build'
Build log file is here: 'publish.log'

check git tag
OK

Upload to PyPi via poetry:
    Call: 'poetry publish'


Publishing python-creole (1.4.3) to PyPI
 - Uploading python-creole-1.4.3.tar.gz 100%
 - Uploading python_creole-1.4.3-py3-none-any.whl 100%

git tag version
    Call: 'git tag v1.4.3'


git push tag to server
    Call: 'git push --tags'

Total 0 (delta 0), reused 0 (delta 0)
To github.com:jedie/python-creole.git
 * [new tag]         v1.4.3 -> v1.4.3

setup usage in projects

Create a publish hook in you project, e.g. create your_project/publish.py with:

from pathlib import Path

import your_project
from poetry_publish.publish import poetry_publish


def publish():
    poetry_publish(
        package_root=Path(your_project.__file__).parent.parent,
        version=your_project.__version__,
    )

Add this to your poetry pyproject.toml, e.g.:

[tool.poetry.scripts]
publish = 'your_project:publish'

To publish do this:

~$ cd your_project
~/your_project$ poetry run publish

Note: Don’t miss the run ! It’s not the same as poetry publish

based on: https://github.com/jedie/python-code-snippets/blob/master/CodeSnippets/setup_publish.py

unittests

# clone repository (or use your fork):
~$ git clone https://github.com/jedie/poetry-publish.git
~$ cd poetry-publish

# install or update poetry:
~/poetry-publish$ make install-poetry

# install poetry-publish via poetry:
~/poetry-publish$ make install

# Run pytest:
~/poetry-publish$ make pytest

# Run pytest via tox with all environments:
~/poetry-publish$ make tox

# Run pytest via tox with one Python version:
~/poetry-publish$ make tox-py38
~/poetry-publish$ make tox-py37
~/poetry-publish$ make tox-py36

make targets

To see all make targets, just call make:

~/poetry-publish$ make
help                 List all commands
install-poetry       install or update poetry
install              install poetry-publish via poetry
lint                 Run code formatters and linter
fix-code-style       Fix code formatting
tox-listenvs         List all tox test environments
tox                  Run pytest via tox with all environments
tox-py36             Run pytest via tox with *python v3.6*
tox-py37             Run pytest via tox with *python v3.7*
tox-py38             Run pytest via tox with *python v3.8*
pytest               Run pytest
update-rst-readme    update README.rst from README.creole
publish              Release new version to PyPi

history

first source code was written 27.11.2008: Forum thread (de)

donation


Note: this file is generated from README.creole 2020-02-02 16:51:57 with "python-creole"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry-publish-0.3.0rc1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

poetry_publish-0.3.0rc1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file poetry-publish-0.3.0rc1.tar.gz.

File metadata

  • Download URL: poetry-publish-0.3.0rc1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for poetry-publish-0.3.0rc1.tar.gz
Algorithm Hash digest
SHA256 5b30538406ea9b9f29ff878f5457dcee655f98551ab10ea949314026075661a3
MD5 753018df5e3d1f11fbf2f66c457fb244
BLAKE2b-256 ac322f9b0337d4fef829c78d18a216d1c0067a5e65f426907a345fe8ce2b4497

See more details on using hashes here.

Provenance

File details

Details for the file poetry_publish-0.3.0rc1-py3-none-any.whl.

File metadata

  • Download URL: poetry_publish-0.3.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for poetry_publish-0.3.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a9516259f77f463e501da8ddc3d7bb6df91edd9b711e1e976ef8d6c65cc6491
MD5 25297cf6a3e7df16c8969be39b4a81f5
BLAKE2b-256 3edc51698d1f8f15967972e6a8166a11fd89c62a155642fcf20f5c0a2032dee8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page