Skip to content

Commit

Permalink
Add hosting of built wheel at PyPI - main (#297)
Browse files Browse the repository at this point in the history
* Lower NumPy and SciPy version for install

* Create pypi_test.yaml

for automated CDCI with pipit

* change name of package

* mayavi direct dependency removed

refer to github PR for reason direct dependency is added - tested to not be necessary as of now, and removed since that blocks pypi artifact upload

#280 (comment)

https://stackoverflow.com/questions/54887301/how-can-i-use-git-repos-as-dependencies-for-my-pypi-package

* Create pypi_build.yaml

* Update and rename pypi_test.yaml to pypi_build_test.yaml

* Update readme.md for pypi

* Update readme.md

* Update installation.md for PyPI

* Update installation.md

* Update pypi_build_test.yaml

* Addressed and incorporated suggestions from review

* Deleted as now incorporated into pypi_build

* Renamed job to distinguish actions

* Name update for readability

* Update readme.md for removing pypi_test

* include also tarball to pypi

* update upload/download-artifact to v4

* use older gcc version to improve compatibility

* update gcc action to 4.8

* Update pypi_build.yaml

* ubuntu bionic runner deprecated

* renaming pypi repo to be consistent with documentation

https://ic-sharpy.readthedocs.io/

* pypi rename to ic-sharpy

* pypi rename to ic-sharpy

* pypi rename to ic-sharpy

---------

Co-authored-by: Ben Preston <[email protected]>
Co-authored-by: Rafa Palacios <[email protected]>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent e231805 commit 60d9df4
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 6 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/pypi_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Create and publish pypi image

on:
# only runs when there are pushes to develop and main for publishing
# and for testing, pull requests to develop and main
# and if there are changes to the build process and github action
push:
branches:
- develop
- main
paths:
- 'setup.py'
- '.github/workflows/pypi*'
pull_request:
branches:
- main
- develop
- 'rc*'

jobs:
create-pypi-image:
name: >-
Create .whl 🛞 from SHARPy distribution
runs-on: ubuntu-20.04
env:
python-version-chosen: "3.10.8"
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.python-version-chosen }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version-chosen }}
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 7
platform: x64
- name: Pre-Install dependencies
run: |
export QT_QPA_PLATFORM='offscreen'
sudo apt install libeigen3-dev
git submodule init
git submodule update
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Install wheel
run: python3 -m pip install wheel --user
- name: Build a source tarball
run: python setup.py sdist
- name: Build a binary wheel
run: python3 setup.py bdist_wheel
- name: Find the wheel created during pip install
run:
python3 -m pip cache dir
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on tag pushes
needs:
- create-pypi-image
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/ic_sharpy # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# with:
# path: dist/*
11 changes: 9 additions & 2 deletions .github/workflows/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SHARPy GitHub Workflows

There are 4 automated workflows for SHARPy's CI/CD.
There are 4(+1 experimental) automated workflows for SHARPy's CI/CD.

## SHARPy Tests

Expand All @@ -19,5 +19,12 @@ Python code, hence allowing the merge.
Two nearly identical workflows, the only difference is that one pushes the Docker
image to the SHARPy packages. Therefore:

* `docker_build.yaml`: Builds the Docker image but does not push. Runs on changes to the `docker*` workflows, changes to the `utils/` directory (environments) and changes to the `Dockerfile`. Required test for PRs to merge to `develop` and `main`.
* `docker_build_test.yaml`: Builds the Docker image but does not push. Runs on changes to the `docker*` workflows, changes to the `utils/` directory (environments) and changes to the `Dockerfile`. Required test for PRs to merge to `develop` and `main`.
* `docker_build.yaml`: Builds and pushes the Docker image. Runs on pushes to `develop`, `main` and annotated tags.

## Pypi (experimental!)

One workflow with two jobs, the first creates and the second pushes the wheel
artifact to ic-sharpy @ pypi. Therefore:

* `pypi_build.yaml`: Builds and pushes the pypi wheel according to conditions. Runs on changes to the `pypi*` workflow, changes to the `setup.py`, and PRs and pushes to main and develop. Required test for PRs to merge to `develop` and `main`. Publishes on annotated tags.
14 changes: 14 additions & 0 deletions docs/source/content/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ python -m unittest

**Enjoy!**

## Obtain SHARPy from PyPI (experimental!)

You can obtain a built version of SHARPy, ic-sharpy, from PyPI [here](https://pypi.org/project/ic-sharpy/).

To install at default directory use
```
python3 -m pip install ic-sharpy
```
To install at current directory use
```
python3 -m pip install --prefix . ic-sharpy
```
The source code can be found at `/lib/python3.10/site-packages/sharpy` and the executable at `/bin/sharpy`.

## Running SHARPy

### Automated tests
Expand Down
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def run(self):
long_description = f.read()
run()
setup(
name="sharpy",
name="ic_sharpy", # due to the name sharpy being taken on pypi
version=__version__,
description="""SHARPy is a nonlinear aeroelastic analysis package developed
at the Department of Aeronautics, Imperial College London. It can be used
Expand Down Expand Up @@ -139,7 +139,7 @@ def run(self):
"colorama",
"dill",
"jupyterlab",
"mayavi @ git+https://github.com/enthought/mayavi.git", #Used for TVTK. Bug in pip install, hence git clone
"mayavi", # github direct dependency removed since pip version is fixed, and also not compatible with pypi
"pandas",
"control",
"openpyxl>=3.0.10",
Expand All @@ -162,8 +162,11 @@ def run(self):
],
},
classifiers=[
"Operating System :: Linux, Mac OS",
"Programming Language :: Python, C++",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.10",
"Programming Language :: Fortran",
"Programming Language :: C++"
],

entry_points={
Expand Down

0 comments on commit 60d9df4

Please sign in to comment.