8000 BLD lazy import of tempita to avoid cython dependency by jeremiedbb · Pull Request #15313 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

BLD lazy import of tempita to avoid cython dependency #15313

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

Merged
merged 7 commits into from
Oct 25, 2019

Conversation

jeremiedbb
Copy link
Member

Fixes #15298

Same fix as #13980.
There are no other occurrence.

@@ -58,6 +57,7 @@ def configuration(parent_package='', top_path=None):

with open(pyxfiles, "r") as f:
tmpl = f.read()
from Cython import Tempita # noqa
Copy link
Member

Choose a reason for hiding this comment

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

Could this be a function in sklearn/_build_utils/__init__.py. Something along these lines:

def tempita_sub(*args, **kwargs):
    """Helper function.
    This does lazy import of Cython to make sure that we do not depend on Cython when building from a  release sdist (since it contains the .c files already)
    """
    from Cython import Tempita
    Tempita.sub(*args, **kwargs)

Copy link
Member

Choose a reason for hiding this comment

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

Or adding a comment above the import about it.

Copy link
Member
@rth rth left a comment

Choose a reason for hiding this comment

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

LGTM, aside for the comment below.

@@ -58,6 +57,7 @@ def configuration(parent_package='', top_path=None):

with open(pyxfiles, "r") as f:
tmpl = f.read()
from Cython import Tempita # noqa
Copy link
Member

Choose a reason for hiding this comment

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

Or adding a comment above the import about it.

@jeremiedbb
Copy link
Member Author

I went for the utility fonction

import numpy

from sklearn._build_utils import gen_from_templates
Copy link
Member Author

Choose a reason for hiding this comment

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

out of curiosity, can you explain me why an absolute import is required here ?

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't work if we use a relative import?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, they also did it for the deprecated modules in sklearn/setup.py
Maybe @thomasjpfan knows better about that ?

@jeremiedbb jeremiedbb added this to the 0.22 milestone Oct 22, 2019
Copy link
Member
@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

A few comments but looks good

Copy link
Member
@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @jeremiedbb , I think it's clear now.

LGTM, though I'm still curious about the need for the absolute import

@jeremiedbb
Copy link
Member Author

@lesteve @rth I think it's ready to merge

Copy link
Member
@rth rth left a comment

Choose a reason for hiding this comment

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

Nice!

@rth rth changed the title [MRG] lazy import of tempita to avoid cython dependency when building from c files BLD lazy import of tempita to avoid cython dependency Oct 25, 2019
@rth rth merged commit c2115b1 into scikit-learn:master Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undeclared build dependency on cython
4 participants
0