Skip to content

Upload to pypi

rachmadani haryono edited this page Jul 1, 2022 · 3 revisions

Buku 3.8 or newer with readme.md

  1. register to pypi and test.pypi
  2. upgrade setuptools. setuptools>=38.6.0 is required to produce a distribution with the new metadata
  3. make a source distribution. command: python setup.py sdist. in this example it will produce dist/buku-3.8.tar.gz
  4. try install it with pipx pipx install dist/buku-3.8.tar.gz and run buku --version to check the installed buku version
  5. install twine>=1.11.0.
  6. upload first to test.pypi. command: twine upload --repository-url https://test.pypi.org/legacy/ dist/buku-3.8.tar.gz
  7. if upload success but result is not as intended, change the version with postn-suffix format. fix the program and go to number 5.
  8. if upload sucsess and result is as intended:
    1. check the program version. maybe rolled it back to original if possible
    2. upload it to pypi. command: twine upload --repository-url https://upload.pypi.org/legacy/ dist/buku-3.8.tar.gz

this guideline is based on this guide https://dustingram.com/articles/2018/03/16/markdown-descriptions-on-pypi

file tree example from buku 4.7 / 4.7.1

$ tar -tf buku-4.7.1.tar.gz | tree --fromfile .
.
└── buku-4.7.1
    ├── auto-completion
    │   ├── bash
    │   │   └── buku-completion.bash
    │   ├── fish
    │   │   └── buku.fish
    │   └── zsh
    │       └── _buku
    ├── buku.1
    ├── buku.egg-info
    │   ├── dependency_links.txt
    │   ├── entry_points.txt
    │   ├── PKG-INFO
    │   ├── requires.txt
    │   ├── SOURCES.txt
    │   └── top_level.txt
    ├── buku.py
    ├── bukuserver
    │   ├── filters.py
    │   ├── forms.py
    │   ├── __init__.py
    │   ├── __main__.py
    │   ├── response.py
    │   ├── server.py
    │   ├── static
    │   │   └── bukuserver
    │   │       └── js
    │   │           ├── bookmark.js
    │   │           └── Chart.js
    │   ├── templates
    │   │   └── bukuserver
    │   │       ├── base.html
    │   │       ├── bookmark_create.html
    │   │       ├── bookmark_create_modal.html
    │   │       ├── bookmark_edit.html
    │   │       ├── bookmark_edit_modal.html
    │   │       ├── bookmarks.html
    │   │       ├── home.html
    │   │       ├── index.html
    │   │       ├── statistic.html
    │   │       └── tags.html
    │   └── views.py
    ├── CHANGELOG
    ├── LICENSE
    ├── MANIFEST.in
    ├── PKG-INFO
    ├── README.md
    ├── requirements.txt
    ├── setup.cfg
    ├── setup.py
    └── tests
        ├── __init__.py
        ├── test_BukuCrypt.py
        ├── test_bukuDb
        │   ├── 25491522_res_nopt.yaml
        │   ├── 25491522_res.yaml
        │   ├── Bookmarks
        │   ├── firefox_res_nopt.yaml
        │   └── firefox_res.yaml
        ├── test_bukuDb.py
        ├── test_buku.py
        ├── test_ExtendedArgumentParser.py
        ├── test_import_firefox_json.py
        ├── test_server.py
        ├── test_setup.py
        └── test_views.py

14 directories, 52 files

Buku 3.7 or older with readme.rst

  1. register to pypi and test.pypi
  2. create ~/.pypirc and fill it with your config (example below)
  3. remove readme.rst if exist
  4. generate readme.rst
  5. applied following fix:
    1. check any text that maybe recognized as enumerated list
    2. newline between example section
  6. upload first to test.pypi. command: python3 setup.py sdist upload -r pypitest
  7. if upload success but result is not as intended, change the version with postn-suffix format. fix the program and go to number 6.
  8. if upload sucsess and result is as intended:
    1. check the program version. maybe rolled it back to original if possible
    2. upload it to pypi. command: python3 setup.py sdist upload -r pypi

code to generate readme.rst, require pypandoc from pip and pandoc e.g. from ubuntu repo (note that everytime setup.py executed it will generate readme.rst if not exist)

import pypandoc
long_description = pypandoc.convert_file('README.md', 'rst')
with open("README.rst", "w") as f:
    f.write(long_description)

Example pypirc

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository=https://pypi.python.org/pypi
username=RachmadaniHaryono
password=<password>

[pypitest]
repository=https://test.pypi.org/legacy/
username=rachmadaniHaryono
password=<password>