Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pythonIoc pip installable #5

Merged
merged 19 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/_version_git.py export-subst
9 changes: 9 additions & 0 deletions .github/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to master branch</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./master/index.html">
<link rel="canonical" href="master/index.html">
</head>
</html>
121 changes: 121 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Code CI

on:
push:
pull_request:

jobs:
lint:
runs-on: "ubuntu-latest"
steps:
- name: Checkout Source
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: Install Python Dependencies
run: pip install flake8

- name: Lint
run: flake8

build:
name: ${{ matrix.os }}/${{ matrix.python }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [cp27, cp37, cp38, cp39]

exclude:
- os: windows-latest
# No cothread or asyncio so doesn't work
python: cp27

include:
- os: ubuntu-latest
# Put coverage in the output dir mounted in docker
cov_file: /output/coverage.xml
test_requires: cothread pytest-asyncio aioca

- os: windows-latest
cov_file: '{project}/dist/coverage.xml'
# cothread doesn't work on windows
test_requires: pytest-asyncio aioca

- os: macos-latest
cov_file: '{project}/dist/coverage.xml'
test_requires: cothread pytest-asyncio aioca

- os: ubuntu-latest
python: cp27
# asyncio doesn't work on Python2.7
test_requires: cothread

- os: macos-latest
python: cp27
# asyncio doesn't work on Python2.7
test_requires: cothread


steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
submodules: true

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: Install Python Dependencies
run: pip install twine build cibuildwheel

- name: Build Sdist
run: python -m build --sdist .

- name: Build Wheel
run: cibuildwheel --output-dir dist
env:
CIBW_BUILD: ${{ matrix.python }}*64
CIBW_TEST_REQUIRES: pytest-cov ${{ matrix.test_requires }}
CIBW_TEST_COMMAND: pytest --cov=softioc {project}/tests --cov-report xml:${{ matrix.cov_file }}
# Disable auditwheel as it isn't compatible with setuptools_dso approach
# https://github.com/mdavidsaver/setuptools_dso/issues/17
CIBW_REPAIR_WHEEL_COMMAND: ''

- name: Upload Wheel and Sdist
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/softioc*

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
name: ${{ matrix.os }}/${{ matrix.python }}
directory: dist

upload_pypi:
needs: [build]
runs-on: ubuntu-latest
# upload to PyPI on every tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v2
with:
name: dist
path: dist

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: twine upload dist/*

70 changes: 70 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

name: Docs CI

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
# require all of history to see all tagged versions' docs
fetch-depth: 0
submodules: true

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install Packages
# Can delete this if you don't use graphviz in your docs
run: sudo apt-get install graphviz

- name: Install Python Dependencies
run: |
pip install pipenv
pipenv install --dev --deploy --python $(which python) && pipenv graph

- name: Deploy index
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true

- name: Checkout gh-pages
# As we already did a deploy of gh-pages above, it is guaranteed to be there
# so check it out so we can selectively build docs below
uses: actions/checkout@v2
with:
ref: gh-pages
path: build/html

- name: Maybe use sphinx-multiversion
# If we are building master or a tag we will publish
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
# So use the args we normally pass to sphinx-build, but run sphinx-multiversion
run: mv $(pipenv --venv)/bin/sphinx-multiversion $(pipenv --venv)/bin/sphinx-build

- name: Build Docs
run: pipenv run docs

- name: Publish Docs to gh-pages
# Only master and tags are published
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/html
keep_files: true

67 changes: 59 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,67 @@
/bin
/dbd
/lib
/db
/docs/html
/pythonIoc
*.pyc
O.*
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.mypy_cache
*.pytest_cache
cov.xml

# DLS build dir and virtual environment
/prefix/
/venv/
/lightweight-venv/
/installed.files

# Docs output
/docs/papers/*/*.aux
/docs/papers/*/*.pdf
/docs/papers/*/*.nav
/docs/papers/*/*.out
/docs/papers/*/*.snm
/docs/papers/*/*.toc
/docs/papers/*/*.vrb

# setup.py develop (via pipenv install) places this link here
# so editable installs work. Related:
# https://github.com/mdavidsaver/setuptools_dso/issues/11
/epicscorelibs
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "iocStats"]
path = iocStats
url = https://github.com/epics-modules/iocStats.git
72 changes: 72 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Contributing
============

Contributions and issues are most welcome! All issues and pull requests are
handled through github on the `dls_controls repository`_. Also, please check for
any existing issues before filing a new one. If you have a great idea but it
involves big changes, please file a ticket before making a pull request! We
want to make sure you don't spend your time coding something that might not fit
the scope of the project.

.. _dls_controls repository: https://github.com/dls-controls/pythonIoc/issues

Running the tests
-----------------

To get the source source code and run the unit tests, run::

$ git clone git://github.com/dls-controls/pythonIoc.git
$ cd pythonIoc
$ pipenv install --dev
$ pipenv run tests

While 100% code coverage does not make a library bug-free, it significantly
reduces the number of easily caught bugs! Please make sure coverage remains the
same or is improved by a pull request!

Code Styling
------------

The code in this repository conforms to standards set by the following tools:

- flake8_ for style checks

.. _flake8: http://flake8.pycqa.org/en/latest/

These tests will be run on code when running ``pipenv run tests`` and also
automatically at check in. Please read the tool documentation for details
on how to fix the errors it reports.

Documentation
-------------

Documentation is contained in the ``docs`` directory and extracted from
docstrings of the API.

Docs follow the underlining convention::

Headling 1 (page title)
=======================

Heading 2
---------

Heading 3
~~~~~~~~~


You can build the docs from the project directory by running::

$ pipenv run docs
$ firefox build/html/index.html


Release Checklist
-----------------

Before a new release, please go through the following checklist:

- Choose a new PEP440 compliant release number
- Git tag the version with a message summarizing the changes
- Push to github and the actions will make a release on pypi
- Push to internal gitlab and do a dls-release.py of the tag
Loading