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

Require cython when building from git clone only #3189

Merged
merged 16 commits into from
Aug 20, 2018
Merged
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@
if sys.version_info < (3, 5, 3):
raise RuntimeError("aiohttp 3.x requires Python 3.5.3+")

here = pathlib.Path(__file__).parent

try:
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False

if (here / '.git').exists() and not USE_CYTHON:
print("Install cython when building from git clone")
Copy link
Member

Choose a reason for hiding this comment

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

Please use stderr

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch

print("pip install cython")
Copy link
Member

Choose a reason for hiding this comment

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

Add this to pyproject.toml and it'll be autoinstalled for pip 10+ users.

sys.exit(1)


if (here / '.git').exists() and not (here / 'vendor/http-parser/README.md'):
print("Install submodules when building from git clone")
print("git submodule init")
print("git submodule update")
Copy link
Member

Choose a reason for hiding this comment

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

It's simpler to do git submodule update --init.

Copy link
Member

Choose a reason for hiding this comment

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

Also, how about to do that automagically if condition is met? Since we know which commands are need to run. Suddenly, it wouldn't be useful for Cython - setup_requires can't handle wheels /:

Copy link
Member Author

Choose a reason for hiding this comment

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

It is for dev module only.
I prefer don't hide git commands from user here.
There is a rare possibility to have no git command in PATH, better to give a hint only

Copy link
Member

Choose a reason for hiding this comment

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

Ok, that's fine for me.

sys.exit(2)


ext = '.pyx' if USE_CYTHON else '.c'


Expand Down Expand Up @@ -62,7 +76,6 @@ def build_extension(self, ext):
raise BuildFailed()


here = pathlib.Path(__file__).parent

txt = (here / 'aiohttp' / '__init__.py').read_text('utf-8')
try:
Expand Down