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

disable buidling/deployment of python wheels #583

Merged
merged 13 commits into from
Aug 23, 2017

Conversation

anthrotype
Copy link
Member

Since this is now done in a separate https://github.com/google/brotli-wheels, it makes sense remove that from the upstream brotli's Travis and Appveyor setup.
We still run python setup.py test on both 2.7 and 3.6 on linux and windows, as well as on the system's python on macOS.

@anthrotype
Copy link
Member Author

I noticed that we were re-building the extension module three times before actually running the tests...

It turns out

  1. the code that checks if the extension module was newer than its source files was not there in our implementation of build_ext.build_extension method (I just copied it from cpython's distutils)

  2. there was a typo in the list of headers (a missing comma) which made it so that two headers' paths were combined into one, but the latter did not exist and thus distutils/setuptools would think the extension module was not up-to-date (as one of the dependencies was showing as missing), and would always run the built_ext command over and over.

if we run 'python setup.py built test', the setuptools 'test' command will
forcibly re-run the build_ext subcommand because it wants to pass the --inplace
option (it ignores whether it's up to date, just re-runs it all the time).

with this we go from running built_ext twice, to running it only once per build
@anthrotype
Copy link
Member Author

ok.. We went from running build_ext three times down to running it twice...
That's because running the test command will automatically run build_ext as a dependent subcommand, so we don't need build and test in a single setup.py invocation.

With the last commit we call the compiler only once (384f8b6), by simply doing python setup.py test.

@anthrotype
Copy link
Member Author

linux python 2.7 build went down from 3m 40s to 2m 12s. nice

…target

The 'develop' command is like 'install' in the sense that it
modifies the user's python environment.
The default make target should be less intrusive, i.e. just building
the extension module in-place without modify anything in the user's
environment.

We don't need to tell make about the dependency between 'test' and
'build' target as that is baked in the `python setup.py test` command.
setup.py Outdated
@@ -53,6 +55,21 @@ def get_source_files(self):
return filenames

def build_extension(self, ext):
if ext.sources is None or not isinstance(ext.sources, (list, tuple)):
from distutils.errors import DistutilsSetupError
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's okay to move this import to the top

setup.py Outdated
@@ -15,6 +15,8 @@
from distutils.core import Extension
from distutils.core import setup
from distutils.command.build_ext import build_ext
from distutils.dep_util import newer_group
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to import packages/modules instead of functions:
https://google.github.io/styleguide/pyguide.html#Imports

setup.py Outdated

ext_path = self.get_ext_fullpath(ext.name)
depends = ext.sources + ext.depends
if not (self.force or newer_group(depends, ext_path, 'newer')):
Copy link
Contributor

Choose a reason for hiding this comment

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

What are your thoughts on "newer" vs the default "error"?

Copy link
Member Author

Choose a reason for hiding this comment

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

don't know.. I just copied from the default distutils build_ext module. I thought it'd be better to keep the default behavior. But I see that with "error" we could have avoided issues like the missing comma..

python/README.md Outdated
@@ -24,7 +24,7 @@ able to edit the source files.

For convenience, you may run the following commands from this directory:

$ make # Deploy the module in "development mode"
$ make # Build the module in-place
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe leave something about "development mode" here since it's described in the paragraph right before this?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh I see now, sorry.. I can actually add an additional make develop, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that sounds good to me, though perhaps we should remove the references to "development mode" in the README if the in-place build is the default.

@anthrotype
Copy link
Member Author

@nicksay FYI I have modified the Makefile in 44b5e66 so that the default make target does not call the develop command, which is I believe is too intrusive for a simple default build target.
It's good for developers who want to actually modify the code, but for the sake of testing the build it's better to not modify the user's python environment (e.g. say one does not have admin rights, develop command will fail, just like install).

Also, we don't need to tell make about the dependency between 'test' and 'build' targets as that is baked in the python setup.py test command as I explained above.

This will work even if setuptools is not installed, which is unlikely
nowadays but still our `setup.py` works with plain distutils, so
we may well have our tests work without setuptools.
@anthrotype
Copy link
Member Author

@nicksay I added the make develop target and reworked the python/README.md so that the reference to setuptools development mode is still there but no longer at the top of the section.

I noticed also that the test command is setuptools only, and the brotli setup.py still works with plain distutils (setuptools is widely available in modern python distributions but is not strictly part of the standard library). So I decided to revert the make test command to calling python -m unittest discover... as it was before, for backward compatiblity's sake.

Copy link
Contributor

@nicksay nicksay left a comment

Choose a reason for hiding this comment

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

Can you add the new "develop" make target as .PHONY at the top of the file? Otherwise, LGTM

We don't need to install custom python versions, we are
using the pre-installed ones on Appveyor.
@anthrotype
Copy link
Member Author

anthrotype commented Aug 9, 2017

The last Travis failure is just random and unrelated, this is good to go now.

@nicksay
Copy link
Contributor

nicksay commented Aug 9, 2017

Still LGTM 👍

@eustas eustas merged commit 4f455ca into google:master Aug 23, 2017
@anthrotype anthrotype mentioned this pull request Sep 4, 2017
juj pushed a commit to Unity-Technologies/brotli that referenced this pull request May 13, 2023
* [appveyor] remove 'deploy' stage; only test python 2.7 and 3.6

all the other python versions are being built and tested on
https://github.com/google/brotli-wheels/blob/d571d63/appveyor.yml

* remove terrify submodule as not needed any more

* [travis] just test py2.7 and 3.6 on linux; remove extra osx python builds

All the other python versions for OSX are being built/tested on:
https://github.com/google/brotli-wheels/blob/d571d63/.travis.yml

Also, there's no need to build and deploy wheels here, as that's done
in the separate repository.

* [setup.py] only rebuild if dependency are newer; fix typo in list of 'depends'

https://github.com/python/cpython/blob/v3.6.2/Lib/distutils/command/build_ext.py#L485-L500

* [ci] only run 'python setup.py test'

if we run 'python setup.py built test', the setuptools 'test' command will
forcibly re-run the build_ext subcommand because it wants to pass the --inplace
option (it ignores whether it's up to date, just re-runs it all the time).

with this we go from running built_ext twice, to running it only once per build

* [Makefile] run 'build_ext --inplace' instead of 'develop' as default target

The 'develop' command is like 'install' in the sense that it
modifies the user's python environment.
The default make target should be less intrusive, i.e. just building
the extension module in-place without modify anything in the user's
environment.

We don't need to tell make about the dependency between 'test' and
'build' target as that is baked in the `python setup.py test` command.

* [Makefile] add 'develop' target; remove unnecessary 'tests' target

`make test` is good enough

* [Makefile] `setup.py test` requires setuptools; run `python -m unittest`

This will work even if setuptools is not installed, which is unlikely
nowadays but still our `setup.py` works with plain distutils, so
we may well have our tests work without setuptools.

* [python/README.md] add ref to 'develop' target; remove 'tests', just 'make test'

* [setup.py] import modules as per nicksay's comment

google#583 (comment)

* [Makefile] add 'develop' to .PHONY targets

remove 'tests' from .PHONY

* [appveyor] remove unused setup scripts

We don't need to install custom python versions, we are
using the pre-installed ones on Appveyor.

* [appveyor] remove unneeded setup code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants