Skip to content

Commit

Permalink
Merge pull request #685 from lindsay-stevens/pyxform-dev-deps-update
Browse files Browse the repository at this point in the history
dev: update dependencies, testing, packaging, and linting/formatting
  • Loading branch information
lindsay-stevens authored Feb 14, 2024
2 parents 8f75605 + 64903fd commit a7027ea
Show file tree
Hide file tree
Showing 131 changed files with 1,214 additions and 1,956 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,31 @@ jobs:
python: ['3.8']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

# Install dependencies.
- uses: actions/cache@v2
- uses: actions/cache@v3
name: Python cache with dependencies.
id: python-cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev_requirements.pip') }}
key: ${{ env.pythonLocation }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies.
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.pip
pip install -e .
pip list
# Build.
- name: Build sdist and wheel.
run: |
pip install wheel
python clean_for_build.py
python setup.py sdist bdist_wheel
# Publish.
- name: Publish release to PyPI with twine
# Build and publish.
- name: Publish release to PyPI
if: success()
run: |
pip install twine
twine upload dist/pyxform-*-py3-none-any.whl dist/pyxform-*.tar.gz
pip install flit==3.9.0
flit --debug publish --no-use-vcs
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
38 changes: 18 additions & 20 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,28 @@ jobs:
python: ['3.8']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

# Install dependencies.
- uses: actions/cache@v2
- uses: actions/cache@v3
name: Python cache with dependencies.
id: python-cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev_requirements.pip') }}
key: ${{ env.pythonLocation }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies.
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.pip
pip install -e .[dev]
pip list
# Linters.
- run: black pyxform tests --check --diff
- run: isort pyxform tests --check-only --diff
- run: flake8 pyxform tests
- run: pycodestyle pyxform tests
# Linter.
- run: ruff check pyxform tests --no-fix
- run: ruff format pyxform tests --diff

test:
runs-on: ${{ matrix.os }}
Expand All @@ -47,38 +45,38 @@ jobs:
- os: windows-latest
windows_nose_args: --traverse-namespace ./tests
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

# Install dependencies.
- uses: actions/cache@v2
- uses: actions/cache@v3
name: Python cache with dependencies.
id: python-cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev_requirements.pip') }}
key: ${{ env.pythonLocation }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies.
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.pip
pip install -e .[dev]
pip list
# Tests.
- name: Run tests
run: nosetests -v -v ${{ matrix.windows_nose_args }}
run: python -m unittest --verbose

# Build and Upload.
- name: Build sdist and wheel.
if: success()
run: |
pip install wheel
python clean_for_build.py
python setup.py sdist bdist_wheel
pip install flit==3.9.0
flit --debug build --no-use-vcs
- name: Upload sdist and wheel.
if: success()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pyxform--on-${{ matrix.os }}--py${{ matrix.python }}
path: ${{ github.workspace }}/dist/pyxform*
43 changes: 18 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ From the command line, complete the following. These steps use a `virtualenv <ht

# Install the pyxform and it's production dependencies.
(venv)$ cd repo
# If this doesn't work, upgrade pip ``pip install --upgrade pip`` and retry.
(venv)$ pip install -e .
(venv)$ python pyxform/xls2xform.py --help
(venv)$ xls2xform --help # same effect as previous line
Expand All @@ -76,25 +77,20 @@ You can then run xls2xform from the commandline::

Development
===========
To set up for development / contributing, first complete the above steps for "Running pyxform from local source", then complete the below.::
To set up for development / contributing, first complete the above steps for "Running pyxform from local source". Then repeat the command used to install pyxform, but with ``[dev]`` appended to the end, e.g.::

pip install -r dev_requirements.pip
pip install -e .[dev]

You can run tests with::

nosetests
python -m unittest

On Windows, use::
Before committing, make sure to format and lint the code using ``ruff``::

nosetests -v -v --traverse-namespace ./tests
ruff format pyxform tests
ruff check pyxform tests

Before committing, make sure to format the code using ``black``::

black pyxform tests

If you are using a copy of black outside your virtualenv, make sure it is the same version as listed in requirements_dev.pip.

In case the pre-commit.sh hooks don't run, also run the code through ``isort`` (sorts imports) and ``flake8`` (misc code quality suggestions). The syntax is the same as above for ``black``.
If you are using a copy of ``ruff`` outside your virtualenv, make sure it is the same version as listed in ``pyproject.toml``. Use the project configuration for ``ruff` in ``pyproject.toml``, which occurs automatically if ``ruff`` is run from the project root (where ``pyproject.toml`` is).

Writing tests
-------------
Expand All @@ -106,11 +102,12 @@ When writing new ``PyxformTestCase`` tests that make content assertions, it is s

Documentation
=============
To check out the documentation for pyxform do the following::
For developers, ``pyxform`` uses docstrings, type annotations, and test cases. Most modern IDEs can display docstrings and type annotations in a easily navigable format, so no additional docs are compiled (e.g. sphinx). In addition to the user documentation, developers should be familiar with the `ODK XForms Specification https://getodk.github.io/xforms-spec/`.

pip install Sphinx==1.0.7
cd your-virtual-env-dir/src/pyxform/docs
make html
For users, ``pyxform`` has documentation at the following locations:
* `XLSForm docs https://xlsform.org/`
* `XLSForm template https://docs.google.com/spreadsheets/d/1v9Bumt3R0vCOGEKQI6ExUf2-8T72-XXp_CbKKTACuko/edit#gid=1052905058`
* `ODK Docs https://docs.getodk.org/`

Change Log
==========
Expand All @@ -127,7 +124,7 @@ Releasing pyxform
3. Draft a new GitHub release with the list of merged PRs. Follow the title and description pattern of the previous release.
4. Checkout a release branch from latest upstream master.
5. Update ``CHANGES.txt`` with the text of the draft release.
6. Update ``setup.py``, ``pyxform/__init__.py`` with the new release version number.
6. Update ``pyproject.toml``, ``pyxform/__init__.py`` with the new release version number.
7. Commit, push the branch, and initiate a pull request. Wait for tests to pass, then merge the PR.
8. Tag the release and it will automatically be published

Expand All @@ -144,18 +141,14 @@ Releases are now automatic. These instructions are provided for forks or for a f
3. Install the production and packaging requirements::

pip install -e .
pip install wheel twine
pip install flit==3.9.0

4. Clean up build and dist folders::

rm -rf build dist pyxform.egg-info

5. Prepare ``sdist`` and ``bdist_wheel`` distributions::

python setup.py sdist bdist_wheel

6. Publish release to PyPI with ``twine``::
5. Prepare ``sdist`` and ``bdist_wheel`` distributions, and publish to PyPI::

twine upload dist/pyxform-*-py3-none-any.whl dist/pyxform-*.tar.gz
flit --debug publish --no-use-vcs

7. Tag the GitHub release and publish it.
6. Tag the GitHub release and publish it.
13 changes: 0 additions & 13 deletions dev_requirements.in

This file was deleted.

42 changes: 0 additions & 42 deletions dev_requirements.pip

This file was deleted.

Loading

0 comments on commit a7027ea

Please sign in to comment.