Skip to content

BLD: Refactor Setup - #4871

Merged
josef-pkt merged 13 commits into
statsmodels:masterfrom
bashtage:simple-setup
Sep 9, 2018
Merged

josef-pkt merged 13 commits into
statsmodels:masterfrom
bashtage:simple-setup

Conversation

@bashtage

Copy link
Copy Markdown
Member

This version builds on #3195 and appears to work as required:

  • correct sdist
  • build with Cython present
  • build without Cython and with C sources
  • error if no Cython and no C
  • work in an empty environment from sdist or wheel

It tries to simplify as much as possible and to let other packages handle tasks they already handle, like letting Cython determine whether to recompile a pyx file.

It adds versioneer since a lot of setup is a bespoke version of what versioneer already does.

@coveralls

coveralls commented Aug 10, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.03%) to 83.903% when pulling 02cd6e3 on bashtage:simple-setup into 8e19500 on statsmodels:master.

Comment thread setup.cfg Outdated
E114
# E114: Indentation is not a multiple of four (comment)

[versioneer]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we adopt a convention of putting two blank lines between blocks? In particular I'm thinking [coverage:run] and [coverage:report] should have 1 blank line, so more-distinct blocks can have one more line.

Obviously, not a big deal.

Comment thread setup.py
# no setuptools installed
from distutils.core import setup, Command
_have_setuptools = False
from setuptools.command.build_ext import build_ext

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still for the "no setuptools installed" case? Is that still possible in this day and age?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are only 2 cases, Cython installed or setuptools installed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, reading comprehension fail on my part, thanks.

Comment thread setup.py
# Key Values that Change Each Release
###############################################################################
SETUP_REQUIREMENTS = {'numpy': '1.11', # released March 2016
'scipy': '0.18', # released July 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 for noting the release dates

Comment thread setup.py Outdated
SETUP_REQUIRES = [k + '>=' + v for k, v in SETUP_REQUIREMENTS.items()]
INSTALL_REQUIRES = [k + '>=' + v for k, v in INSTALL_REQUIREMENTS.items()]

EXTRAS_REQUIRE = {'build': ['cython>=0.24'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the 0.24.0 be written in Exactly One Place and with a release date comment?

Comment thread setup.py Outdated

DISTNAME = 'statsmodels'
DESCRIPTION = 'Statistical computations and models for Python'
README = open(pjoin(os.getcwd(), 'README.rst')).read()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this leave an open file handle behind?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes

Comment thread setup.py
file_stats = os.stat(source_name)
try:
os.utime(pyx_filename, ns=(file_stats.st_atime_ns, file_stats.st_mtime_ns))
except AttributeError:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a py2 vs py3 thing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes

@jbrockmendel

Copy link
Copy Markdown
Contributor

With a few comments, generally +1.

Does the new setup.py pass strict linting? If so, please add it to the lint.sh file.

@jbrockmendel

Copy link
Copy Markdown
Contributor

Does this mean tools/cythonize.py can go? (and possibly cythonize.dat, cythonize_exclusions.dat)?

@bashtage

Copy link
Copy Markdown
Member Author

Does the new setup.py pass strict linting? If so, please add it to the lint.sh file.

Yes

Does this mean tools/cythonize.py can go? (and possibly cythonize.dat, cythonize_exclusions.dat)?

Yes, these are no longer required. It is more-or-less as vanilla as it can get while handling the two important cases -- cython (or not) and deferred numpy.

@codecov-io

codecov-io commented Aug 10, 2018 •

Copy link
Copy Markdown

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4871      +/-   ##
==========================================
+ Coverage   81.42%   81.42%   +<.01%     
==========================================
  Files         581      581              
  Lines       90248    90249       +1     
  Branches    10093    10093              
==========================================
+ Hits        73486    73489       +3     
+ Misses      14476    14474       -2     
  Partials     2286     2286
Impacted Files Coverage Δ
statsmodels/tools/web.py 90.9% <100%> (ø) ⬆️
statsmodels/api.py 91.48% <100%> (+0.37%) ⬆️
statsmodels/__init__.py 54.05% <100%> (+4.05%) ⬆️

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 8e19500...02cd6e3. Read the comment docs.

@josef-pkt

Copy link
Copy Markdown
Member

Can this be made to stop the installation with an error message if numpy and scipy are older than the setup requirements?
That is, I still like to avoid that pip updates numpy and scipy if they are too old, which is the pip default now, AFAIR/AFAIU.

SETUP_REQUIREMENTS = {'numpy': '1.11', # released March 2016
'scipy': '0.18', # released July 2016

@bashtage

Copy link
Copy Markdown
Member Author

While I think it is simpler to leave this up to pip/end users, I have added checks for the SETUP_REQUIREMENTS as minimum versions.

@josef-pkt

Copy link
Copy Markdown
Member

last change looks good to me
I prefer to leave it to the user, but not to pip.
(Personally, I still have python versions on my computer that don't satisfy the minimum scipy requirement, and I don't want pip to touch my scipy if I forget about adding the no-dep)

I'd like to try this locally, and then merge when green, within a few days. That leaves us still some time before the next release to see if there are any problems.
This also fixes the problem that we had in 0.9 that scipy wasn't specified as build dependency, AFAIU.

@josef-pkt josef-pkt added this to the 0.10 milestone Aug 21, 2018
Fix broken lint.sh
Fix lnting errors in setup
Exclude versioneer provided file form coverage
Add codacy configuration
Remove clean command and use git clean -xfd instead
Quick check to avoid upgrading very old NumPy or SciPy that
are already installed
Ensure LICENSE is included in installed package
Remove unicode spaces from setup.cfg
Add all versioneer files to codacy to avoid inspections
Change exit on git clean command
Remove pyproject.toml to avoid confusing pip
Use abspath and __file__ to robustify path detection
Provide better guidance for using git clean
Include setup.cfg in install to pickup pytest settings
SMall improvements to pytest settings
@josef-pkt

Copy link
Copy Markdown
Member

all green, merging

@bashtage Thank you

@josef-pkt
josef-pkt merged commit 5c24107 into statsmodels:master Sep 9, 2018
@jbrockmendel

Copy link
Copy Markdown
Contributor

Way to go fellas, this is a big win.

@bashtage

bashtage commented Sep 9, 2018

Copy link
Copy Markdown
Member Author

Thanks - I'm glad this has gotten in, it will simplify some of the testing in my downstream projects

@bashtage
bashtage deleted the simple-setup branch September 9, 2018 07:34
@Danielhiversen

Copy link
Copy Markdown

Great. Will you make a 0.9.1 release with this?

@josef-pkt

Copy link
Copy Markdown
Member

@Danielhiversen
We are planning on a 0.10 release in Fall instead of a 0.9.1.

jbrockmendel added a commit to jbrockmendel/statsmodels that referenced this pull request Sep 10, 2018
jbrockmendel added a commit to jbrockmendel/statsmodels that referenced this pull request Sep 12, 2018
jbrockmendel added a commit to jbrockmendel/statsmodels that referenced this pull request Sep 19, 2018
jbrockmendel added a commit to jbrockmendel/statsmodels that referenced this pull request Sep 20, 2018
ChadFulton added a commit that referenced this pull request Oct 16, 2018
MAINT: remove cythonize.py made unnecessary by #4871
@rtsio

rtsio commented Nov 8, 2018

Copy link
Copy Markdown

When is this going to be available? Simple installation of statsmodels is failing in our Docker build because it requires numpy to be installed first.

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.

8 participants