Skip to content

Commit

Permalink
Add hosting of built wheel at PyPI - develop (#298)
Browse files Browse the repository at this point in the history
* Update CHANGELOG.md for version 2.3

* Change version in installation guide

* Updated docs to address issue with conda install failing

* 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

* 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

* Add rewritten aeroforcescalculator.py using flow angle rotation

* Fixed FoR issue with aero forces

* Removed commented code in AeroForcesCalculator

* 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]>
Co-authored-by: Ben Preston <[email protected]>
  • Loading branch information
4 people authored Oct 9, 2024
1 parent 7a1ac6a commit b1ea255
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 169 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.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# Changelog

## [2.3](https://github.com/imperialcollegelondon/sharpy/tree/2.3) (2024-05-10)

[Full Changelog](https://github.com/imperialcollegelondon/sharpy/compare/2.2...2.3)

**Implemented enhancements:**

- Version 2.3 update [\#289](https://github.com/ImperialCollegeLondon/sharpy/pull/289) ([ben-l-p](https://github.com/ben-l-p))
- Update develop branch with main [\#284](https://github.com/ImperialCollegeLondon/sharpy/pull/284) ([ben-l-p](https://github.com/ben-l-p))
- Added pip install \(with docs\) [\#280](https://github.com/ImperialCollegeLondon/sharpy/pull/280) ([ben-l-p](https://github.com/ben-l-p))
- Update beamplot.py to have stride option, consistent with aerogridplot.py [\#279](https://github.com/ImperialCollegeLondon/sharpy/pull/279) ([kccwing](https://github.com/kccwing))

**Fixed bugs:**

- Fix Github Runner Docker build failing [\#285](https://github.com/ImperialCollegeLondon/sharpy/pull/285) ([ben-l-p](https://github.com/ben-l-p))
- Add scipy version info to env yml [\#277](https://github.com/ImperialCollegeLondon/sharpy/pull/277) ([SJ-Innovation](https://github.com/SJ-Innovation))

**Closed issues:**

- Scipy 1.12.0 Incompatible [\#276](https://github.com/ImperialCollegeLondon/sharpy/issues/276)
- BeamLoader postprocessor squishing answers [\#270](https://github.com/ImperialCollegeLondon/sharpy/issues/270)
- Solving Environment gets killed. [\#268](https://github.com/ImperialCollegeLondon/sharpy/issues/268)
- Error when running sharpy unittest: module scipy.sparse.\_sputils not found [\#227](https://github.com/ImperialCollegeLondon/sharpy/issues/227)
- Potential bug in /sharpy/structure/utils/modalutils.py [\#208](https://github.com/ImperialCollegeLondon/sharpy/issues/208)

**Merged pull requests:**

- Added ability to turn aligned grid off [\#288](https://github.com/ImperialCollegeLondon/sharpy/pull/288) ([ben-l-p](https://github.com/ben-l-p))
- Update with main for mamba fixes [\#286](https://github.com/ImperialCollegeLondon/sharpy/pull/286) ([ben-l-p](https://github.com/ben-l-p))
- Correct typos caught by Divya Sanghi [\#283](https://github.com/ImperialCollegeLondon/sharpy/pull/283) ([bbahiam](https://github.com/bbahiam))
- Develop: Update environment.yml to fix scipy version issue [\#282](https://github.com/ImperialCollegeLondon/sharpy/pull/282) ([kccwing](https://github.com/kccwing))
- Update noaero.py for consistency in function input [\#275](https://github.com/ImperialCollegeLondon/sharpy/pull/275) ([kccwing](https://github.com/kccwing))
- A few minor bug fixes [\#273](https://github.com/ImperialCollegeLondon/sharpy/pull/273) ([sduess](https://github.com/sduess))
- Update XBeam version to include compiler optimisation [\#272](https://github.com/ImperialCollegeLondon/sharpy/pull/272) ([ben-l-p](https://github.com/ben-l-p))
- Update XBeam version to include compiler optimisation [\#271](https://github.com/ImperialCollegeLondon/sharpy/pull/271) ([ben-l-p](https://github.com/ben-l-p))
- Improve docs and code of newmark\_ss [\#267](https://github.com/ImperialCollegeLondon/sharpy/pull/267) ([bbahiam](https://github.com/bbahiam))
- Changed Github runner from Conda to Mamba [\#266](https://github.com/ImperialCollegeLondon/sharpy/pull/266) ([ben-l-p](https://github.com/ben-l-p))
- Changed Github runner from Conda to Mamba [\#265](https://github.com/ImperialCollegeLondon/sharpy/pull/265) ([ben-l-p](https://github.com/ben-l-p))
- Hotfix for documentation search [\#264](https://github.com/ImperialCollegeLondon/sharpy/pull/264) ([kccwing](https://github.com/kccwing))
- Hotfix for documentation - develop [\#263](https://github.com/ImperialCollegeLondon/sharpy/pull/263) ([kccwing](https://github.com/kccwing))
- Hotfix for documentation - main [\#262](https://github.com/ImperialCollegeLondon/sharpy/pull/262) ([kccwing](https://github.com/kccwing))
- Merging v2.2 into develop [\#261](https://github.com/ImperialCollegeLondon/sharpy/pull/261) ([kccwing](https://github.com/kccwing))


## [2.2](https://github.com/imperialcollegelondon/sharpy/tree/2.2) (2023-10-18)

[Full Changelog](https://github.com/imperialcollegelondon/sharpy/compare/2.1...2.2)
Expand Down
32 changes: 28 additions & 4 deletions docs/source/content/installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SHARPy v2.2 Installation Guide
__Last revision 26 February 2024__
# SHARPy v2.3 Installation Guide
__Last revision 10 June 2024__

The following step by step tutorial will guide you through the installation process of SHARPy. This is the updated process valid from v2.2.
The following step by step tutorial will guide you through the installation process of SHARPy. This is the updated process valid from v2.3.

## Requirements

Expand Down Expand Up @@ -113,7 +113,17 @@ These are specified in an Anaconda environment that shall be activated prior to
```
This should take approximately 5 minutes to complete (Tested on Ubuntu 22.04.1). For installation on Apple Silicon, use ```environment_arm64.yml```; this requires GCC and GFortran to be installed prior.

5. Activate the `sharpy` conda environment:
Installation using Conda can be memory intensive, and will give the message ```Collecting package metadata (repodata.json): - Killed``` if all the available RAM is filled. From testing, 16GB of total system RAM is reliable for Conda install, whereas 8GB may have issues. Three solutions are available:
* Increase available RAM (if running on a compute cluster etc)
* Use [Mamba](https://mamba.readthedocs.io/en/latest/), a more efficient drop-in replacement for Conda
* Create a blank conda environment and install the required packages:
```bash
conda create --name sharpy python=3.10
conda config –add channels conda-forge
conda install eigen libopenblas libblas libcblas liblapack libgfortran libgcc libgfortran-ng
```

6. Activate the `sharpy` conda environment:
```bash
conda activate sharpy
```
Expand Down Expand Up @@ -293,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
Loading

0 comments on commit b1ea255

Please sign in to comment.