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.
- A PyPI login
my-cool-model
builds and passes all unit tests
- 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
>
- 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/
- Push the initial tag info to github
> git commit -am "Created initial distro"
> git push --tags
- 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
select the Manage button for your project
select Create a token for my-cool-model
label the token github_my-cool-model (or something similar), and my-cool-project
in the Scope window:
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.
Navigate to the settings/secrets tab of the github repository for your project
Select New repository secret.
Name the token "pypi_password", paste the token you copied above into the _Value slot and click Add secret
- Test the newly created token:
Navigate to the home page or your repository and select the tags tab:
__Select Releases and then Draft a new release
Enter the next sequential (or otherwise appropriate) tag version, as "v" followed by the appropiate semantic version
The Actions tab will show you the status of your publish
When the action rolls over to green, your newest version will be in PyPI