Skip to content

Commit 4f9e236

Browse files
Merge pull request #1 from ISISComputingGroup/make_package
Make package
2 parents e4c9967 + 07f5534 commit 4f9e236

30 files changed

+445
-254
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: sphinx
2+
3+
on: [push, pull_request, workflow_call]
4+
5+
jobs:
6+
call_sphinx_builder:
7+
uses: ISISComputingGroup/reusable-workflows/.github/workflows/sphinx.yml@main
8+
secrets: inherit
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
env:
2+
PYTHONUNBUFFERED: "TRUE"
3+
name: test
4+
on: [pull_request, workflow_call]
5+
jobs:
6+
lint:
7+
uses: ISISComputingGroup/reusable-workflows/.github/workflows/linters.yml@main
8+
with:
9+
compare-branch: origin/main
10+
python-ver: '3.11'
11+
unit-tests:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: ["ubuntu-latest", "windows-latest"]
16+
version: ['3.11']
17+
fail-fast: false
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.version }}
23+
- name: Install base requirements
24+
run: pip install -e .
25+
- name: Verify package is importable
26+
run: |
27+
python -c "from genie_python.genie_startup import *"
28+
python -c "from genie_python import genie as g"
29+
- name: Install dev requirements
30+
run: pip install -e .[dev]
31+
- name: Run unit tests
32+
run: python -m pytest
33+
results:
34+
if: ${{ always() }}
35+
runs-on: ubuntu-latest
36+
name: Final Results
37+
needs: [lint, unit-tests]
38+
steps:
39+
- run: exit 1
40+
# see https://stackoverflow.com/a/67532120/4907315
41+
if: >-
42+
${{
43+
contains(needs.*.result, 'failure')
44+
|| contains(needs.*.result, 'cancelled')
45+
}}

.github/workflows/linter.yml

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

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Publish Python distribution to PyPI
2+
on: push
3+
jobs:
4+
lint-and-test:
5+
if: github.ref_type == 'tag'
6+
name: Run lint & tests
7+
uses: ./.github/workflows/lint_and_test.yml
8+
build:
9+
needs: lint-and-test
10+
if: github.ref_type == 'tag'
11+
name: build distribution
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.11"
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--user
26+
- name: Build a binary wheel and a source tarball
27+
run: python3 -m build
28+
- name: Store the distribution packages
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
publish-to-pypi:
34+
name: >-
35+
Publish Python distribution to PyPI
36+
if: github.ref_type == 'tag'
37+
needs: [lint-and-test, build]
38+
runs-on: ubuntu-latest
39+
environment:
40+
name: release
41+
url: https://pypi.org/p/genie_python
42+
permissions:
43+
id-token: write # IMPORTANT: mandatory for trusted publishing
44+
steps:
45+
- name: Download all the dists
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: python-package-distributions
49+
path: dist/
50+
- name: Publish distribution to PyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1
52+
github-release:
53+
name: >-
54+
Sign the Python distribution with Sigstore
55+
and upload them to GitHub Release
56+
needs: [lint-and-test, build, publish-to-pypi]
57+
runs-on: ubuntu-latest
58+
59+
permissions:
60+
contents: write # IMPORTANT: mandatory for making GitHub Releases
61+
id-token: write # IMPORTANT: mandatory for sigstore
62+
63+
steps:
64+
- name: Download all the dists
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: python-package-distributions
68+
path: dist/
69+
- name: Sign the dists with Sigstore
70+
uses: sigstore/[email protected]
71+
with:
72+
inputs: >-
73+
./dist/*.tar.gz
74+
./dist/*.whl
75+
- name: Create GitHub Release
76+
env:
77+
GITHUB_TOKEN: ${{ github.token }}
78+
run: >-
79+
gh release create
80+
'${{ github.ref_name }}'
81+
--repo '${{ github.repository }}'
82+
--notes ""
83+
- name: Upload artifact signatures to GitHub Release
84+
env:
85+
GITHUB_TOKEN: ${{ github.token }}
86+
# Upload to GitHub Release using the `gh` CLI.
87+
# `dist/` contains the built packages, and the
88+
# sigstore-produced signatures and certificates.
89+
run: >-
90+
gh release upload
91+
'${{ github.ref_name }}' dist/**
92+
--repo '${{ github.repository }}'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,5 @@ cython_debug/
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
.idea/
163+
164+
_build/

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024, ISIS Experiment Controls Computing
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File renamed without changes.

docs/conf.py renamed to doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# If extensions (or modules to document with autodoc) are in another directory,
2121
# add these directories to sys.path here. If the directory is relative to the
2222
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
sys.path.insert(0, os.path.abspath("../Lib/site-packages/genie_python/"))
23+
sys.path.insert(0, os.path.abspath("../src/genie_python/"))
2424

2525
# -- General configuration ------------------------------------------------
2626

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)