Skip to content

Commit 7c61434

Browse files
committed
adds GitHub workflow for publishing on PyPI
1 parent 0b12608 commit 7c61434

5 files changed

Lines changed: 196 additions & 31 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: "3.x"
16+
- name: Install pypa/build
17+
run: >-
18+
python3 -m
19+
pip install
20+
build
21+
--user
22+
- name: Build a binary wheel and a source tarball
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: >-
32+
Publish Python 🐍 distribution 📦 to PyPI
33+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/PSID # Replace <package-name> with your PyPI project name
40+
permissions:
41+
id-token: write # IMPORTANT: mandatory for trusted publishing
42+
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish distribution 📦 to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
github-release:
53+
name: >-
54+
Sign the Python 🐍 distribution 📦 with Sigstore
55+
and upload them to GitHub Release
56+
needs:
57+
- publish-to-pypi
58+
runs-on: ubuntu-latest
59+
60+
permissions:
61+
contents: write # IMPORTANT: mandatory for making GitHub Releases
62+
id-token: write # IMPORTANT: mandatory for sigstore
63+
64+
steps:
65+
- name: Download all the dists
66+
uses: actions/download-artifact@v3
67+
with:
68+
name: python-package-distributions
69+
path: dist/
70+
- name: Sign the dists with Sigstore
71+
uses: sigstore/gh-action-sigstore-python@v1.2.3
72+
with:
73+
inputs: >-
74+
./dist/*.tar.gz
75+
./dist/*.whl
76+
- name: Create GitHub Release
77+
env:
78+
GITHUB_TOKEN: ${{ github.token }}
79+
run: >-
80+
gh release create
81+
'${{ github.ref_name }}'
82+
--repo '${{ github.repository }}'
83+
--notes ""
84+
- name: Upload artifact signatures to GitHub Release
85+
env:
86+
GITHUB_TOKEN: ${{ github.token }}
87+
# Upload to GitHub Release using the `gh` CLI.
88+
# `dist/` contains the built packages, and the
89+
# sigstore-produced signatures and certificates.
90+
run: >-
91+
gh release upload
92+
'${{ github.ref_name }}' dist/**
93+
--repo '${{ github.repository }}'
94+
95+
publish-to-testpypi:
96+
name: Publish Python 🐍 distribution 📦 to TestPyPI
97+
needs:
98+
- build
99+
runs-on: ubuntu-latest
100+
101+
environment:
102+
name: testpypi
103+
url: https://test.pypi.org/p/PSID
104+
105+
permissions:
106+
id-token: write # IMPORTANT: mandatory for trusted publishing
107+
108+
steps:
109+
- name: Download all the dists
110+
uses: actions/download-artifact@v3
111+
with:
112+
name: python-package-distributions
113+
path: dist/
114+
- name: Publish distribution 📦 to TestPyPI
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
repository-url: https://test.pypi.org/legacy/

pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "PSID"
7+
version = "1.2.2"
8+
authors = [
9+
{name = "Omid Sani", email = "omidsani@gmail.com"},
10+
]
11+
description = "Python implementation for preferential subspace identification (PSID)"
12+
requires-python = ">=3.10"
13+
classifiers = [
14+
"Programming Language :: Python :: 3",
15+
"Operating System :: OS Independent",
16+
]
17+
dependencies = [
18+
"numpy",
19+
"scipy",
20+
"scikit-learn",
21+
"matplotlib",
22+
"h5py"
23+
]
24+
dynamic = ["readme"]
25+
26+
[tool.setuptools.dynamic]
27+
readme = {file = ["README.md"], content-type = "text/markdown"}
28+
29+
[tool.setuptools.packages.find]
30+
where = ["source"] # list of folders that contain the packages (["."] by default)

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
numpy
22
scipy
3-
matplotlib
3+
scikit-learn # sklearn
4+
matplotlib
5+
h5py

setup.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Release tutorial:
2+
# https://packaging.python.org/tutorials/packaging-projects/
3+
# Old version:
4+
# pip install setuptools wheel twine
5+
# python setup.py sdist bdist_wheel
6+
# New version:
7+
# python -m build
8+
# Then run the following to upload to PyPI
9+
# python -m twine upload --repository testpypi dist/*
10+
# pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple PSID --upgrade
11+
# python -m twine upload --repository pypi dist/*
12+
13+
14+
import setuptools, os
15+
16+
# Get the directory of the setup.py file
17+
dir_path = os.path.dirname(os.path.realpath(__file__))
18+
base_dir = os.path.join(dir_path)
19+
20+
# requirements_file_path = os.path.join(base_dir, 'requirements.txt')
21+
# with open(requirements_file_path, "r", encoding="utf-8") as fh:
22+
# requirements = fh.read().split('\n')
23+
24+
readme_file_path = os.path.join(base_dir, 'README.md')
25+
with open(readme_file_path, "r", encoding="utf-8") as fh:
26+
long_description = fh.read()
27+
28+
setuptools.setup(
29+
name="PSID",
30+
version="1.2.4",
31+
author="Omid Sani",
32+
author_email="omidsani@gmail.com",
33+
description="Python implementation for preferential subspace identification (PSID)",
34+
long_description=long_description,
35+
long_description_content_type="text/markdown",
36+
url="https://github.com/ShanechiLab/PyPSID",
37+
packages=setuptools.find_packages(where='source'),
38+
package_dir={"": "source"},
39+
package_data={"PSID": ["*.mat"]},
40+
classifiers=[
41+
"Programming Language :: Python :: 3",
42+
"Operating System :: OS Independent",
43+
],
44+
python_requires='>=3.6',
45+
# install_requires=requirements,
46+
)

source/setup.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)