Skip to content

Commit

Permalink
Merge pull request #485 from nucleic/pep621
Browse files Browse the repository at this point in the history
Use pyproject.toml based install and latest cppy features
  • Loading branch information
MatthieuDartiailh committed Mar 31, 2022
2 parents d482957 + 46ff89d commit c70d3b5
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 198 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libx11-xcb-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-x11-dev libxcb-xtest0-dev libegl1-mesa xvfb fluxbox --fix-missing
- name: Checkout branch
uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python
uses: actions/setup-python@v2
- name: Install dependencies
Expand Down
73 changes: 23 additions & 50 deletions docs/source/get_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ Python
~~~~~~

Enaml is a Python framework and requires a supported Python runtime. Enaml
currently supports **Python 3.7**, **Python 3.8**, **Python 3.9** and
**Python 3.10**.
currently supports **Python 3.8**, **Python 3.9** and **Python 3.10**.

.. note::

Expand All @@ -63,29 +62,24 @@ Toolkit Rendering Library
~~~~~~~~~~~~~~~~~~~~~~~~~

Enaml's declarative widgets provide a layer of abstraction on top of the
widgets of a toolkit rendering library. Enaml ships with a backend based on Qt5
widgets of a toolkit rendering library. Enaml ships with a backend based on Qt5/6
and third-party projects such as `enaml-web`_ and `enaml-native`_ provides
alternative backends.

Enaml uses the `QtPy`_ library as compatibility layer to support transparently both
PyQt and PySide. PyQt has been supported for a longer time and has been more
heavily tested.
Qt 5 and Qt 6 through either PyQt or PySide. PyQt5 has been supported for a longer
time and has been more heavily tested.

On 32 and 64-bit Windows, 64-bit OS X and 64-bit Linux, with Python
versions >=3.6, it can be installed via pip::
Starting with Enaml 0.13.0, you can specify a rendering library using extra_requires,
ie::

$ pip install qtpy pyqt5
$ pip install enaml[qt5-pyqt]

.. note::
There is no pyqt5 wheel available for 32-bit Linux.
Currently, you can use either [qt5-pyqt] to use PyQt5, [qt5-pyside] to
use Pyside2, or [qt6-pyqt] and [qt6-pyside] if you want to use Qt6.

.. note::
On Enaml >= 0.13 you can specify a rendering library using extra_requires, ie::

$ pip install enaml[qt5-pyqt]

Currently, you can use either [qt5-pyqt] to use PyQt5 or [qt5-pyside] to
use Pyside2.
There is no pyqt5 wheel available for 32-bit Linux.

.. _enaml-web: https://github.com/codelv/enaml-web
.. _enaml-native: https://github.com/codelv/enaml-native
Expand All @@ -100,22 +94,14 @@ the `Git`_ command line tools installed and available on the system path.

.. _Git: http://git-scm.com

`Setuptools`_ and `Pip`_
~~~~~~~~~~~~~~~~~~~~~~~~

Setuptools is a Python package which makes installing other Python packages a
breeze. Pip is the default package manager for Python. The installation
instructions below assume that Setuptools and Pip have been installed in the
target Python environment. Follow the relevant `Setuptools Install`_
instructions for adding the package to your system.
`Pip`_
~~~~~~

.. note::
Recent versions of Python (Python 2 >=2.7.9 or Python 3 >=3.4) installed
from the official binaries install come with those tools installed.
Pip is the default package manager for Python. The installation instructions
below assume that Pip has been installed in the target Python environment
(see `Pip install`_).

.. _Setuptools: http://pythonhosted.org/setuptools
.. _Pip: https://pip.pypa.io/en/stable/
.. _Setuptools Install: https://pypi.python.org/pypi/setuptools/1.1.6
.. _Pip Install: https://pip.pypa.io/en/stable/installing/

`Ply`_
Expand All @@ -133,19 +119,6 @@ Ply can be installed with the ``pip install`` command of `Pip`_::

.. _Ply: http://www.dabeaz.com/ply

`Cppy`_
~~~~~~~

Enaml also uses Cppy, a small C++ header library, to build some pre-compiled
`Python extensions`_.

Cppy can be installed with the ``pip install`` command of `Pip`_::

$ pip install cppy

.. _Cppy: https://github.com/nucleic/cppy
.. _Python extensions: https://docs.python.org/3/extending/extending.html

`QtPy`_
~~~~~~~

Expand All @@ -156,14 +129,14 @@ QtPy can be installed with the ``pip install`` command of `Pip`_::

$ pip install QtPy

.. _PyQt: http://www.riverbankcomputing.com/software/pyqt/intro
.. _PyQt5: https://pypi.org/project/PyQt5/
And you also need a toolkit rendering library either `PyQt5`_, `PyQt6`_, `Pyside2`_,
or `PySide6`_ which all be installed through pip.

.. _QtPy: https://pypi.python.org/pypi/QtPy/
.. _Qt: http://qt-project.org
.. _PyQt Downloads: http://www.riverbankcomputing.com/software/pyqt/download
.. _Homebrew: http://brew.sh
.. _PySide: http://qt-project.org/wiki/PySide
.. _PyQt5: https://pypi.org/project/PyQt5/
.. _PyQt6: https://pypi.org/project/PyQt6/
.. _Pyside2: http://wiki.qt.io/Qt_for_Python
.. _PySide6: https://doc.qt.io/qtforpython/contents.html

`Kiwisolver`_
~~~~~~~~~~~~~
Expand Down Expand Up @@ -209,7 +182,7 @@ Alternatively, cloning and building the latest (unstable dev) version of Atom fr

$ git clone https://github.com/nucleic/atom.git
$ cd atom
$ python setup.py install
$ pip install .

.. _Atom: https://github.com/nucleic/atom
.. _Observer Pattern: http://en.wikipedia.org/wiki/Observer_pattern
Expand All @@ -222,7 +195,7 @@ can be installed with just a few commands::

$ git clone https://github.com/nucleic/enaml.git
$ cd enaml
$ python setup.py install
$ pip install .

.. _Enaml: https://github.com/nucleic/enaml

Expand Down
8 changes: 3 additions & 5 deletions enaml/qt/docking/dock_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ def paintEvent(self, event):
self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)


class DockOverlay(Atom):
# PySide requires weakrefs for using bound methods as slots.
# PyQt doesn't, but executes unsafe code if not using weakrefs.
class DockOverlay(Atom, enable_weakrefs=True):
""" An object which manages the overlays for dock widgets.
This manager handles the state transitions for the overlays. The
transitions are performed on a slightly-delayed timer to provide
a more fluid user interaction experience.
"""
# PySide requires weakrefs for using bound methods as slots.
# PyQt doesn't, but executes unsafe code if not using weakrefs.
__slots__ = '__weakref__'

#: The size of the rubber band when docking on the border, in px.
border_size = Int(60)

Expand Down
8 changes: 3 additions & 5 deletions enaml/qt/qt_toolkit_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
from .QtCore import QObject


class QtToolkitObject(ProxyToolkitObject):
# PySide requires weakrefs for using bound methods as slots.
# PyQt doesn't, but executes unsafe code if not using weakrefs.
class QtToolkitObject(ProxyToolkitObject, enable_weakrefs=True):
""" A Qt implementation of an Enaml ProxyToolkitObject.
"""
# PySide requires weakrefs for using bound methods as slots.
# PyQt doesn't, but executes unsafe code if not using weakrefs.
__slots__ = '__weakref__'

#: A reference to the toolkit widget created by the proxy.
widget = Typed(QObject)

Expand Down
37 changes: 0 additions & 37 deletions enaml/version.py

This file was deleted.

6 changes: 5 additions & 1 deletion enaml/widgets/raw_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class RawWidget(Control):
When using the Qt backend, note that PySide requires weakrefs for using
bound methods as slots. PyQt doesn't, but executes unsafe code if not using
weakrefs. So you should add the following line to your class.
__slots__ = ('__weakref__',)
__slots__ = ('__weakref__',) or pass the keyword argument
enable_weakrefs=True to the metaclass::
class MyWidget(RawWidget, enable_weakref=True):
pass
"""
#: A reference to the proxy Control object.
Expand Down
100 changes: 100 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# --------------------------------------------------------------------------------------
# Copyright (c) 2013-2022, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# --------------------------------------------------------------------------------------

[project]
name = "enaml"
description = "Declarative DSL for building rich user interfaces in Python"
readme = "README.rst"
requires-python = ">=3.8"
license = {file = "LICENSE"}
authors = [
{name = "The Nucleic Development Team", email = "sccolbert@gmail.com"}
]
maintainers = [
{name = "Matthieu C. Dartiailh", email = "m.dartiailh@gmail.com"}
]
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = [
"ply",
"atom>=0.8.0",
"kiwisolver>=1.2.0",
"bytecode>=0.13.0",
]
dynamic=["version"]

[project.optional-dependencies]
qt5-pyqt = ["qtpy", "pyqt5"]
qt5-pyside = ["qtpy", "pyside2"]
qt6-pyqt = ["qtpy>=2.0.1", "pyqt6>=6.2"]
qt6-pyside = ["qtpy>=2.0.1", "pyside6>=6.2.3"]

[project.urls]
homepage = "https://github.com/nucleic/enaml"
documentation = "https://enaml.readthedocs.io/en/latest/"
repository = "https://github.com/nucleic/enaml"
changelog = "https://github.com/nucleic/enaml/blob/main/releasenotes.rst"

[project.scripts]
enaml-run = "enaml.runner:main"
enaml-compileall = "enaml.compile_all:main"

[build-system]
requires = ["setuptools>=61.2", "wheel", "setuptools_scm[toml]>=3.4.3", "cppy>=1.2.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = false
[tools.setuptools.package-data]
"enaml.applib" = ['*.enaml']
"enaml.stdlib" = ['*.enaml']
"enaml.workbench.core" = ['*.enaml']
"enaml.workbench.ui" = ['*.enaml']
"enaml.qt.docking" = [
'dock_images/*.png',
'dock_images/*.py',
'enaml_dock_resources.qrc'
]

[tool.setuptools_scm]
write_to = "enaml/version.py"
write_to_template = """
# --------------------------------------------------------------------------------------
# Copyright (c) 2013-2022, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# --------------------------------------------------------------------------------------
# This file is auto-generated by setuptools-scm do NOT edit it.
from collections import namedtuple
#: A namedtuple of the version info for the current release.
_version_info = namedtuple("_version_info", "major minor micro status")
parts = "{version}".split(".", 3)
version_info = _version_info(
int(parts[0]),
int(parts[1]),
int(parts[2]),
parts[3] if len(parts) == 4 else "",
)
# Remove everything but the 'version_info' from this module.
del namedtuple, _version_info, parts
__version__ = "{version}"
"""
1 change: 1 addition & 0 deletions releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Dates are written as DD/MM/YYYY

0.15.0 - unreleased
-------------------
- make install PEP 517 compliant and use a PEP 621 compliant pyproject.toml PR #485
- add support for PyQt6 and Pyside6 PR #475
- fix last occurrences of passing float instead of int to PyQt PR #481
- add new declarative @observe which ignores 'create' and 'container' events by default PR #479
Expand Down

0 comments on commit c70d3b5

Please sign in to comment.