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

Modernise Python packaging #79

Merged
merged 10 commits into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
82 changes: 82 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build wheels

# By default this action does not push to test or production PyPI. The wheels
# are available as an artifact that can be downloaded and tested locally.

on:
workflow_dispatch:
inputs:
ufl_ref:
description: "UFL git ref to checkout"
default: "main"
type: string
test_pypi_publish:
description: "Publish to Test PyPi (true | false)"
default: false
type: boolean
pypi_publish:
description: "Publish to PyPi (true | false)"
default: false
type: boolean

workflow_call:
inputs:
ufl_ref:
description: "UFL git ref to checkout"
default: "main"
type: string
test_pypi_publish:
description: "Publish to Test PyPi (true | false)"
default: false
type: boolean
pypi_publish:
description: "Publish to PyPi (true | false))"
default: false
type: boolean

jobs:
build:
name: Build wheels and source distributions
runs-on: ubuntu-latest
steps:
- name: Checkout UFL
uses: actions/checkout@v2
with:
ref: ${{ inputs.ufl_ref }}

- name: Upgrade pip and setuptools
run: python -m pip install setuptools pip --upgrade

- name: Build wheel
run: python setup.py bdist_wheel

- name: Build sdist
run: python setup.py sdist --formats=bztar,gztar

- uses: actions/upload-artifact@v2
with:
path: dist/*

upload_pypi:
name: Upload to PyPI (optional)
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
if: ${{ inputs.test_pypi_publish }}
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
repository_url: https://pypi.org/legacy/

- uses: pypa/gh-action-pypi-publish@v1.4.2
if: ${{ inputs.pypi_publish }}
with:
user: __token__
password: ${{ secrets.PYPI_TEST_TOKEN }}
repository_url: https://test.pypi.org/legacy/
9 changes: 4 additions & 5 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
pip install flake8
python -m pip install flake8
flake8 --statistics .
- name: Check documentation style
run: |
pip install pydocstyle
python -m pip install pydocstyle
python -m pydocstyle .
- name: Install UFL
run: pip install .
run: python -m pip install .[ci]
- name: Run unit tests
run: |
pip install coveralls coverage pytest pytest-cov pytest-xdist
pytest -n auto --cov=ufl/ --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml test/
python -m pytest -n auto --cov=ufl/ --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml test/
- name: Upload to Coveralls
if: ${{ github.repository == 'FEniCS/ufl' && github.head_ref == '' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
env:
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include AUTHORS
include COPYING
include COPYING.LESSER
include ChangeLog
include ChangeLog.rst
recursive-include demo *
recursive-include doc *
recursive-include test *
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build-system]
requires = ["setuptools>=58", "wheel"]

build-backend = "setuptools.build_meta"
8 changes: 0 additions & 8 deletions release.conf

This file was deleted.

63 changes: 61 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
[metadata]
name = fenics-ufl
version = 2019.2.0.dev0
jhale marked this conversation as resolved.
Show resolved Hide resolved
author = FEniCS Project Contributors
email = fenics-dev@googlegroups.com
maintainer = FEniCS Project Steering Council
description = Unified Form Language
url = https://github.com/FEniCS/ufl
project_urls =
Homepage = https://fenicsproject.org
Documentation = https://fenics.readthedocs.io/projects/ufl
Issues = https://github.com/FEniCS/ufl/issues
Funding = https://numfocus.org/donate
long_description = file: README.rst
long_description_content_type = text/rst
license=LGPL-3.0-or-later
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Operating System :: POSIX
Operating System :: POSIX :: Linux
Operating System :: MacOS :: MacOS X
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Scientific/Engineering :: Mathematics
Topic :: Software Development :: Libraries :: Python Modules

[options]
packages = find:
include_package_data = True
zip_safe = False
python_requires = >= 3.7
setup_requires =
setuptools >= 58
wheel
install_requires =
numpy

[options.extras_require]
docs = sphinx; sphinx_rtd_theme
lint = flake8; pydocstyle[toml]
test = pytest
ci =
coverage
coveralls
pytest-cov
pytest-xdist
fenics-ufl[docs]
fenics-ufl[lint]
fenics-ufl[test]

[flake8]
ignore = E501, W504,
E741 # ambiguous variable name
Expand All @@ -10,6 +66,9 @@ ignore = D100,D101,D102,D103,D104,D105,D107,
D200,D202,
D203, # this error should be disabled
D204,D205,D208,D209,D210,D212,D213,
D300,D301,
D300,D301,
D400,D401,D402,D404,D415,D416
# convention = numpy
E741 # Variable names l, O, I, ...

# Setuptools does not yet support modern pyproject.toml but will do so in the
# future
54 changes: 6 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,9 @@
# -*- coding: utf-8 -*-
import setuptools

from setuptools import setup
# Can be removed when pip editable user installs are fixed
# https://github.com/pypa/pip/issues/7953
import site
import sys
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]

if sys.version_info < (3, 6):
print("Python 3.6 or higher required, please upgrade.")
sys.exit(1)

version = "2021.1.0"

url = "https://github.com/FEniCS/ufl"

CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Operating System :: POSIX
Operating System :: POSIX :: Linux
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Scientific/Engineering :: Mathematics
Topic :: Software Development :: Libraries :: Python Modules
"""

setup(
name="fenics-ufl",
version=version,
description="Unified Form Language",
author="FEniCS Project Team",
author_email="fenics-dev@googlegroups.com",
url=url,
classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
packages=[
"ufl",
"ufl.utils",
"ufl.finiteelement",
"ufl.core",
"ufl.corealg",
"ufl.algorithms",
"ufl.formatting",
],
package_dir={"ufl": "ufl"},
install_requires=["numpy"])
setuptools.setup()