Skip to content

[CLN] resolve circular Period dependency, prepare setup.py #21854

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 4 commits into from
Jul 12, 2018

Conversation

jbrockmendel
Copy link
Member

For a long time there has been a comment in _libs.__init__ saying it would be nice to import Period directly but that is not possible due to circular imports. This resolves that issue.

Also does some cleanup in setup.py, motivated by the goals of a) using cythonize and b) implementing test coverage for cython files. I've gotten those working locally, but they involve big diffs, so this gets some of the easy stuff out of the way.

# lazy import to prevent circularity
# TODO: Avoid non-cython dependency
from pandas.core.algorithms import unique

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm now leaning towards actually moving _FrequencyInferer back out of cython (it came from tseries.frequencies previously). The only place it is used is in frequencies.infer_freq, which itself is only used from DatetimelikeArrayMixin. i.e. it could reasonably be considered out-of-scope for tslibs, which is largely scalar-centric.

Moving it out would allow us to get rid of the unsightly khash dependency, which is the last non-src pandas dependency for tslibs.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure that would be ok

Copy link
Member Author

Choose a reason for hiding this comment

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

great, will do this in follow up

@@ -103,27 +97,30 @@ def is_platform_mac():


class build_ext(_build_ext):
def build_extensions(self):
@classmethod
def render_templates(cls, pxifiles):
Copy link
Member Author

Choose a reason for hiding this comment

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

I needed to be able to call this method separately to get cythonize working.

@@ -53,24 +45,26 @@ def is_platform_mac():
}
Copy link
Member Author

Choose a reason for hiding this comment

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

If there are no objections, I'd like to move this dictionary up above the min_cython_version = '0.28.2 line

Copy link
Contributor

Choose a reason for hiding this comment

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

sure

@codecov
Copy link

codecov bot commented Jul 11, 2018

Codecov Report

Merging #21854 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #21854      +/-   ##
==========================================
+ Coverage   91.91%   91.91%   +<.01%     
==========================================
  Files         164      164              
  Lines       49987    49988       +1     
==========================================
+ Hits        45947    45948       +1     
  Misses       4040     4040
Flag Coverage Δ
#multiple 90.3% <100%> (ø) ⬆️
#single 42.16% <100%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/_libs/tslibs/__init__.py 100% <100%> (ø) ⬆️
pandas/_libs/__init__.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d94a95...4222187. Read the comment docs.

# lazy import to prevent circularity
# TODO: Avoid non-cython dependency
from pandas.core.algorithms import unique

Copy link
Contributor

Choose a reason for hiding this comment

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

sure that would be ok

@@ -53,24 +45,26 @@ def is_platform_mac():
}
Copy link
Contributor

Choose a reason for hiding this comment

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

sure

setup.py Outdated
@@ -53,24 +45,26 @@ def is_platform_mac():
}


# The import of Extension must be after the import of Cython, otherwise
# we do not get the appropriately patched class.
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems odd?

Copy link
Member Author

Choose a reason for hiding this comment

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

Found the appropriate reference in the cython docs:

Note that when using setuptools, you should import it before Cython as setuptools may replace the Extension class in distutils. Otherwise, both might disagree about the class to use here.

Copy link
Contributor

Choose a reason for hiding this comment

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

that is so weird, but ok

setup.py Outdated

try:
if not _CYTHON_INSTALLED:
raise ImportError('No supported version of Cython installed.')
try:
from Cython.Distutils.old_build_ext import old_build_ext as _build_ext # noqa:F811,E501
from Cython.Distutils.old_build_ext import old_build_ext as _build_ext
except ImportError:
Copy link
Contributor

Choose a reason for hiding this comment

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

yes I think that is ok to remove

@@ -471,8 +468,6 @@ def pxd(name):

tseries_depends = np_datetime_headers + ['pandas/_libs/tslibs/np_datetime.pxd']

# some linux distros require it
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm do we need 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.

Apparently not. It has apparently sat there unused for a while.

@jreback jreback added the Build Library building on various platforms label Jul 12, 2018
@jreback jreback added this to the 0.24.0 milestone Jul 12, 2018
@jreback jreback merged commit 49c130e into pandas-dev:master Jul 12, 2018
@jreback
Copy link
Contributor

jreback commented Jul 12, 2018

thanks! happy to take these cleaning PRs!

Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
@jbrockmendel jbrockmendel deleted the reso branch April 5, 2020 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants