Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Latest commit

 

History

History
128 lines (97 loc) · 4.11 KB

PYPI_SETUP.md

File metadata and controls

128 lines (97 loc) · 4.11 KB

Setting up a new PyPI repository

This document contains some notes on how to set up a new linkml derived model in the Python Package Index (PyPI)

For the purposes of this example, we will pretend that you have created a new LinkML model, my-cool-model in your repository.

Prerequisites

  1. A PyPI login
  2. my-cool-model builds and passes all unit tests

Process

  1. Commit all changes
> git commit -am "Ready for testing..."
> git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
>
  1. Create the initial PyPI distro
> git tag v0.0.1
> rm -f dist/*
> python setup.py sdist bdist_wheel
...
creating 'dist/my-cool-model-0.0.1-py3-none-any.whl' and adding 'build/bdist.macosx-10.9-x86_64/wheel' to it
adding 'my-cool-model-0.0.1.dist-info/AUTHORS'
adding 'my-cool-model-0.0.1.dist-info/METADATA'
adding 'my-cool-model-0.0.1.dist-info/WHEEL'
adding 'my-cool-model-0.0.1.dist-info/pbr.json'
adding 'my-cool-model-0.0.1.dist-info/top_level.txt'
adding 'my-cool-model-0.0.1.dist-info/RECORD'
removing build/bdist.macosx-10.9-x86_64/wheel
> list dist
my-cool-model-1.0.1-py3-none-any.whl my-cool-model-1.0.1.tar.gz
>

If the tags above show up with a dev1 suffix on them, something has changed since the tag. If this occurs, you can go ahead and find what got missed in the commit, fix and commit it and grab the next tag (v0.0.2 in this example) and redo the setup. 3) Upload the commit to PyPI:

> twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: <pypi user name>
Uploading my-cool-model-0.0.1-py3-none-any.whl
100%|██████████████████████████████████████| 10.4k/10.4k [00:02<00:00, 4.93kB/s]
Uploading my-cool-model-0.0.1.tar.gz
100%|██████████████████████████████████████| 96.0k/96.0k [00:01<00:00, 58.7kB/s]

View at:
https://pypi.org/project/my-cool-model/0.0.1/
  1. Push the initial tag info to github
> git commit -am "Created initial distro"
> git push --tags
  1. Create an OAUTH2 token from the PyPI site

Note: the examples below show this process using a real project, jsonasobj2. You will be using my-cool-model in its stead:

log in to PyPI

img.png

select the Manage button for your project img_1.png img_2.png

select Settings img_3.png

select Create a token for my-cool-model img_4.png

label the token github_my-cool-model (or something similar), and my-cool-project in the Scope window: img_6.png

Copy the token to the clipboard Note that this is the only time you will see this token -- once you leave this web page, the token cannot be retrieved. img_7.png

Navigate to the settings/secrets tab of the github repository for your project img_8.png img_9.png

Select New repository secret.

Name the token "pypi_password", paste the token you copied above into the _Value slot and click Add secret img_10.png img_11.png

  1. Test the newly created token:

Navigate to the home page or your repository and select the tags tab: img_12.png

__Select Releases and then Draft a new release img_13.png img_14.png

Enter the next sequential (or otherwise appropriate) tag version, as "v" followed by the appropiate semantic version img_15.png

Select Publish release img_16.png

The Actions tab will show you the status of your publish img_17.png

When the action rolls over to green, your newest version will be in PyPI img_18.png

And the new release will be available for download and use img_19.png