diff --git a/.github/workflows/pypi_build.yaml b/.github/workflows/pypi_build.yaml new file mode 100644 index 000000000..c39115d99 --- /dev/null +++ b/.github/workflows/pypi_build.yaml @@ -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 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/* diff --git a/.github/workflows/readme.md b/.github/workflows/readme.md index 3124c604b..f8762f531 100644 --- a/.github/workflows/readme.md +++ b/.github/workflows/readme.md @@ -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 @@ -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. diff --git a/docs/source/content/installation.md b/docs/source/content/installation.md index 3a8341be0..f3223f168 100644 --- a/docs/source/content/installation.md +++ b/docs/source/content/installation.md @@ -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 diff --git a/setup.py b/setup.py index ebc708e7f..500fb1bad 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -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", @@ -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={