Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated pypi release support #196

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need support from Linux, MacOS, and Windows systems.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to test on multiple versions of each OS or testing on the latest version of each OS will be sufficient?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing on the latest version for each OS would be sufficient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While uploading to pypi do we need to upload wheels of all possible combinations of python versions with OS, or just 1 Source distribution(tar.gz) and 1 Built distribution (.whl)?
And, which python versions are we testing on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FanwangM if we want wheels for all the 3 OS, then we would have to change the setup.py file to output the wheels with dynamic naming

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please help change setup.py? Thanks. @kunikachandra

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure! I will start working on it once my exams are over in 2-3 days


steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get update
# scipy dependencies
sudo apt-get install -y libopenblas-dev
python -m pip install --upgrade pip
pip install build
Comment on lines +31 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to make this work for Windows and MacOs systems.

- name: Build package
run: python -m build
- name: Publish package
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

[project]
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
name = "selector"
name = "qc-selector"
version = "0.0.1"
description = "Molecule selection with maximum diversity."
readme = "README.md"
Expand All @@ -49,7 +49,7 @@ keywords = [
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"License :: OSI Approved :: GNU (Version 3)",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
FanwangM marked this conversation as resolved.
Show resolved Hide resolved
"Natural Language :: English",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
Expand Down
23 changes: 18 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from setuptools import setup

short_description = "Subset selection with maximized diversity".split("\n")[0]
short_description = "Molecule selection with maximum diversity".split("\n")[0]

# from https://github.com/pytest-dev/pytest-runner#conditional-requirement
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
Expand All @@ -37,16 +37,15 @@
except ValueError:
long_description = short_description


setup(
name="selector",
package_metadata = dict(
name="qc-selector",
author="QC-Devs Community",
author_email="[email protected]",
description=short_description,
long_description=long_description,
long_description_content_type="text/markdown",
version="0.0.1",
license="GNU (Version 3)",
license="GNU General Public License v3 (GPLv3)",
package_dir={"selector": "selector"},
packages=["selector", "selector.methods", "selector.tests", "selector.methods.tests"],
# Optional include package data to ship with your package
Expand Down Expand Up @@ -82,3 +81,17 @@
# zip_safe=False,
# todo: add classifiers
)

# Naming format of the pypi wheel
wheel_name_format = "{name}-{version}-{py_version}-none-any.whl"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FanwangM currently I am using naming conventions that will generate packages like this qc_selector-0.0.1-py3-none-any.whl. I used streamlit's naming conventions as a reference. If you want some other format, let me know, I will update it!


# Modify wheel file name based on the platform and Python version
distname = wheel_name_format.format(
name=package_metadata["name"],
version=package_metadata["version"],
py_version="py" + "".join(map(str, sys.version_info[:2])),
)

package_metadata["distname"] = distname

setup(**package_metadata)
Loading