Skip to content

Commit

Permalink
WIP FIX(pvlib,setuptools): FULLY revert (3f40b23) (EAT MY DOG FOOD)...
Browse files Browse the repository at this point in the history
for pvlib and and simply import standalone wheel.
+ travis: restore `pip install -e`,  drop --skip-polyversion-check flag.

Rational:
---------
We still use `polyversion` to derive version on runtime from Git tags,
BUT we cannot reliably control `easy_install` cached packages when
*setuptools*'s `setup_requires` keyword gets processed:
See: https://pip.pypa.io/en/stable/reference/pip_install/#controlling-setup-requires
  • Loading branch information
ankostis committed Jun 4, 2018
1 parent 3380b6e commit 56a894c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ script:
## Build WHEELS, install, smoketest. and uninstall.
#
- |
python pvlib/setup.py develop && \
python pvlib/setup.py build bdist_wheel --skip-polyversion-check && \
pip install -e ./pvlib && \
python pvlib/setup.py build bdist_wheel && \
pip uninstall -y polyversion && \
pip install dist/polyversion-*.whl && \
polyversion --help
- |
if [ $TRAVIS_PYTHON_VERSION \> '3.5' ]; then
pip install -r requirements.txt && \
python ./setup.py develop && \
pip install -e . && \
rm -rf build/* && \
python setup.py build bdist_wheel --skip-polyversion-check && \
pip install dist/polyvers-*.whl && \
Expand Down
61 changes: 31 additions & 30 deletions pvlib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import print_function

import re
import sys

from setuptools import setup

Expand All @@ -13,6 +14,32 @@
mydir = osp.dirname(osp.realpath(__file__))


## here we CANNOT FULLY EAT our own dog-food and use *setuptools* plugin:
# We do use `polyversion` to derive version on runtime from Git tags,
# BUT we cannot reliably control `easy_install` cached packages when
# *setuptools*'s `setup_requires` keyword gets processed:
# https://pip.pypa.io/en/stable/reference/pip_install/#controlling-setup-requires
#
# For this reason the following hack is needed to start developing it
# from git-sources: it bootstraps ``pip install -e pvlib[test]``
# when not any *compatible" version of the `polyversion` lib is
# already installed on the system.
#
try:
from polyversion import __version__ as bver, polyversion
if bver <= '0.1.0':
raise ValueError('Expected `polyversion >= 1.0.1a3, got: %s' % bver)
except ImportError:
try:
print("Hack: pre-installing `polyversion` from standalone `pvlib.run` wheel",
file=sys.stderr)
sys.path.append(osp.join(mydir, 'bin', 'pvlib.run'))
from polyversion import polyversion
except Exception as ex:
print("Hack failed :-(", file=sys.stderr)
polyversion = lambda *_, **__: '0.0.0'


def yield_rst_only_markup(lines):
"""
:param file_inp: a `filename` or ``sys.stdin``?
Expand Down Expand Up @@ -102,8 +129,9 @@ def clean_line(line):

setup(
name=PROJECT,
version='0.0.0', # to install in shallow clones
polyversion=True,
## Provide a `default_version` for installing eg. in shallow clones,
# and `pname` or else it would be `__main__`.
version=polyversion(pname=PROJECT, default_version='0.0.0'),
description="Polyvers's lib to derive subproject versions from tags on Git monorepos.",
long_description=long_desc,
author="Kostis Anagnostopoulos",
Expand Down Expand Up @@ -145,11 +173,10 @@ def clean_line(line):
],
test_suite='tests',
#python_requires='>=3.6',
setup_requires=['setuptools', 'wheel', 'polyversion'],
setup_requires=['setuptools', 'wheel'],
tests_require=test_requirements,
extras_require={
'test': test_requirements,
'setuptools': ['polyversion'],
},
entry_points={
'distutils.setup_keywords': [
Expand All @@ -160,29 +187,3 @@ def clean_line(line):
['%(p)s = %(p)s.__main__:main' % {'p': PROJECT}]
},
)


# ## Standalone-wheel Hack:
# # This sub-project eats it's own dog-food, and
# # uses `polyversion` *setuptools* plugin to derive its own version
# # on runtime from Git tags.
# #
# # But if it fails (e.g. when bootstraping and no `polyvers` exists in PyPi or
# # bc the last released version was broken) the following hack will fallback using
# # a standalone wheel.
# try:
# run_setup(
# polyversion=True,
# )
# except Exception as ex:
# import sys
# exmsg = str(ex)
# if 'polyversion' not in exmsg or 'not recognized' not in exmsg:
# raise
#
# print("Hack: pre-installing `polyversion` from standalone `pvlib.run` wheel",
# file=sys.stderr)
# sys.path.insert(0, osp.join(mydir, '..', 'bin', 'pvlib.run'))
# run_setup(
# version='0.0.0'
# )

0 comments on commit 56a894c

Please sign in to comment.