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

Adopt pep517 + try compile with cython #1709

Merged
merged 14 commits into from
May 26, 2021
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
34 changes: 16 additions & 18 deletions .github/workflows/create-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
# four jobs are defined make-wheel-win-osx, make-wheel-linux, make-source-dist and make-emulated-wheels
# the wheels jobs do the the same steps, but linux wheels need to be build to target manylinux
make-wheel-win-osx:
needs: make-source-dist
Copy link
Member Author

@CaselIT CaselIT May 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a needs, since in the source dist we verify that the version is correct

name: ${{ matrix.python-version }}-${{ matrix.architecture }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -50,14 +51,13 @@ jobs:
architecture: ${{ matrix.architecture }}

- name: Create wheel
# create the wheel using --no-use-pep517 since locally we have pyproject
# this flag should be removed once falcon supports pep517
# `--no-deps` is used to only generate the wheel for the current library. Redundant in falcon since it has no dependencies
# `--no-deps` is used to only generate the wheel for the current library.
# Redundant in falcon since it has no dependencies
run: |
python -m pip install --upgrade pip
pip --version
pip install 'setuptools>=44' 'wheel>=0.34' 'cython>=0.29.21'
pip wheel -w dist --no-use-pep517 -v --no-deps .
pip install 'setuptools>=47' 'wheel>=0.34'
pip wheel -w dist -v --no-deps .

- name: Check created wheel
# - install the created wheel without using the pypi index
Expand Down Expand Up @@ -90,6 +90,7 @@ jobs:
twine upload --skip-existing dist/*

make-wheel-linux:
needs: make-source-dist
# see also comments in the make-wheel-win-osx job for details on the steps
name: ${{ matrix.python-version }}-${{ matrix.architecture }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -142,11 +143,9 @@ jobs:
# this action generates 3 wheels in dist/. linux manylinux1 and manylinux2010
with:
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34 cython>=0.29.21"
# Create the wheel using --no-use-pep517 since locally we have pyproject
# This flag should be removed once falcon supports pep517
build-requirements: "setuptools>=47 wheel>=0.34"
# `--no-deps` is used to only generate the wheel for the current library. Redundant in falcon since it has no dependencies
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
pip-wheel-args: "-w ./dist -v --no-deps"

- name: Create wheel for manylinux 2014
# as previous step but for manylinux2014
Expand All @@ -156,8 +155,8 @@ jobs:
# Remove previous original wheel just to be sure it is recreated. Should not be needed
pre-build-command: "rm ./dist/*-linux*.whl"
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34 cython>=0.29.21"
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
build-requirements: "setuptools>=47 wheel>=0.34"
pip-wheel-args: "-w ./dist -v --no-deps"

- name: Check created wheel
# - install the created wheel without using the pypi index
Expand Down Expand Up @@ -216,12 +215,10 @@ jobs:
architecture: ${{ matrix.architecture }}

- name: Create sdist
# TODO should we generate the c files? Only for pyx files or also for py files?
run: |
python -m pip install --upgrade pip
pip --version
pip install setuptools>=44 wheel>=0.34 cython>=0.29.21
# cythonize -3 falcon/**/*.pyx
pip install setuptools>=47 wheel>=0.34
python setup.py sdist --dist-dir dist
python .github/workflows/scripts/verify_tag.py dist

Expand All @@ -243,6 +240,7 @@ jobs:
twine upload --skip-existing dist/*

make-emulated-wheels:
needs: make-source-dist
# see also comments in the make-wheel-linux job for details on the steps
name: ${{ matrix.python-version }}-${{ matrix.architecture }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -289,8 +287,8 @@ jobs:
# this action generates 2 wheels in dist/. linux manylinux1 and manylinux2010
with:
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34 cython>=0.29.21"
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
build-requirements: "setuptools>=47 wheel>=0.34"
pip-wheel-args: "-w ./dist -v --no-deps"

- name: Check created wheel for arm
if: ${{ matrix.architecture == 'aarch64' }}
Expand All @@ -314,8 +312,8 @@ jobs:
# this action generates 2 wheels in dist/. linux manylinux1 and manylinux2010
with:
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34 cython>=0.29.21"
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
build-requirements: "setuptools>=47 wheel>=0.34"
pip-wheel-args: "-w ./dist -v --no-deps"

- name: Check created wheel for s390x
if: ${{ matrix.architecture == 's390x' }}
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include tox.ini
include README.rst
include LICENSE
include docs/conf.py docs/Makefile
exclude pyproject.toml
graft docs/_static
graft docs/_templates
graft tools
33 changes: 17 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,29 +236,30 @@ Or, to install the latest beta or release candidate, if any:
In order to provide an extra speed boost, Falcon can compile itself with
Cython. Wheels containing pre-compiled binaries are available from PyPI for
several common platforms. However, if a wheel for your platform of choice is not
available, you can choose to stick with the source distribution, or use the
instructions below to cythonize Falcon for your environment.

The following commands tell pip to install Cython, and then to invoke
Falcon's ``setup.py``, which will in turn detect the presence of Cython
and then compile (AKA cythonize) the Falcon framework with the system's
default C compiler.
available, you can install the source distribution, that will automatically
try to cythonize Falcon for your environment, falling back to a normal
pure-Python install in case of issues in the cythonization step:

.. code:: bash

$ pip install cython
$ pip install --no-build-isolation --no-binary :all: falcon

Note that ``--no-build-isolation`` is necessary to override pip's default
PEP 517 behavior that can cause Cython not to be found in the build
environment.
$ pip install --no-binary :all: falcon

If you want to verify that Cython is being invoked, simply
pass `-v` to pip in order to echo the compilation commands:
pass the verbose flag `-v` to pip in order to echo the compilation commands.
You should see an log that informs you if the cython compile was successful
of it the fallback normal install was used:

.. code:: bash

$ pip install -v --no-binary :all: falcon

If for some reason you want to skip Cython compilation step and install
CaselIT marked this conversation as resolved.
Show resolved Hide resolved
the pure-Python version directly you can set the environment variable
``FALCON_DISABLE_CYTHON`` to any value before install:
CaselIT marked this conversation as resolved.
Show resolved Hide resolved

CaselIT marked this conversation as resolved.
Show resolved Hide resolved
.. code:: bash

$ pip install -v --no-build-isolation --no-binary :all: falcon
$ FALCON_DISABLE_CYTHON=Y pip install -v --no-binary :all: falcon

**Installing on OS X**

Expand Down Expand Up @@ -335,7 +336,7 @@ available to your app without having to reinstall the package:
.. code:: bash

$ cd falcon
$ pip install --no-use-pep517 -e .
$ pip install -e .

You can manually test changes to the Falcon framework by switching to the
directory of the cloned repo and then running pytest:
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=47",
"wheel>=0.34",
"cython>=0.29.21; python_implementation == 'CPython'", # Skip cython when using pypy
]

[tool.towncrier]
package = "falcon"
package_dir = ""
Expand Down
67 changes: 67 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
[metadata]
name = falcon
version = attr: falcon.__version__
description = An unladen web framework for building APIs and app backends.
long_description_content_type = text/x-rst
url = https://falconframework.org
author = Kurt Griffiths
author_email = mail@kgriffs.com
license = Apache 2.0
license_file = LICENSE
classifiers =
Development Status :: 5 - Production/Stable
Environment :: Web Environment
Natural Language :: English
Intended Audience :: Developers
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Topic :: Internet :: WWW/HTTP :: WSGI
Topic :: Software Development :: Libraries :: Application Frameworks
Programming Language :: Python
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
CaselIT marked this conversation as resolved.
Show resolved Hide resolved
keywords =
asgi
wsgi
web
api
framework
rest
http
cloud
project_urls =
Documentation=https://falcon.readthedocs.io/en/stable/
Issue Tracker=https://github.com/falconry/falcon

[options]
zip_safe = False
include_package_data = True
packages = find:
python_requires = >=3.5
install_requires =
tests_require =
testtools
requests
pyyaml
pytest
pytest-runner

[options.packages.find]
exclude =
examples
tests

[options.entry_points]
console_scripts =
falcon-bench = falcon.cmd.bench:main
falcon-inspect-app = falcon.cmd.inspect_app:main
falcon-print-routes = falcon.cmd.inspect_app:route_main

[egg_info]
# TODO replace
tag_build = dev1
Expand Down
Loading