Skip to content
Permalink
Browse files

Python distributions (#1928)

* Fix the ability to create python distributions

* Make python tox tests work

* clean up cmake arguments in setup.py

* fix build script

* remove erroneous chdir in build script

* Move python dependencies into setup.py, per convention

* Revert "Move python dependencies into setup.py, per convention"

This reverts commit 67e2d40.
  • Loading branch information...
peterychang authored and JohnLangford committed Jun 21, 2019
1 parent 7381b05 commit 2ee2bcf1feb1744d73620ce08d0527a83d7b5ef9
Showing with 29 additions and 17 deletions.
  1. +13 −0 MANIFEST.in
  2. +1 −3 build-linux.sh
  3. +0 −6 python/MANIFEST.in
  4. 0 {python → }/requirements.txt
  5. +11 −6 {python → }/setup.py
  6. +4 −2 {python → }/tox.ini
@@ -0,0 +1,13 @@
include *.txt *.in CMakeSettings.json
include python/README.rst python/*.txt python/*.bat
recursive-include python *
recursive-include python/vowpalwabbit *
recursive-include cluster *
recursive-include library *
recursive-include rapidjson *
recursive-include vowpalwabbit *
recursive-include explore *
recursive-include python/bin python/*.dll
recursive-include python/windows* python/packages.config python/*.vcxproj*
global-exclude *.o *.exe *.pyc
recursive-exclude vowpalwabbit/.nuget *
@@ -34,14 +34,12 @@ cd ..
mvn verify -f java/pom.xml

# Run python build and tests
cd python
source activate test-python27
pip install pytest readme_renderer pandas
python setup.py check -mrs
python setup.py install
py.test tests
py.test python/tests
source deactivate
cd ..

# Clear out build directory then build using GCov and run one set of tests again
rm -rf build

This file was deleted.

File renamed without changes.
@@ -17,6 +17,7 @@
system = platform.system()
version_info = sys.version_info
here = os.path.abspath(os.path.dirname(__file__))
pkg_path = os.path.join(here, 'python')

class Distribution(_distribution):
if system == 'Windows':
@@ -75,13 +76,17 @@ def build_cmake(self, ext):

# example of cmake args
config = 'Debug' if self.debug else 'Release'

cmake_args = [
'-DCMAKE_BUILD_TYPE=' + config,
'-DPY_VERSION=' + '{v[0]}.{v[1]}'.format(v=version_info),
'-DBUILD_PYTHON=On',
'-DBUILD_TESTS=Off',
'-DWARNINGS=Off'
]
if 'CONDA_PREFIX' in os.environ and not 'BOOST_ROOT' in os.environ:
cmake_args.append('-DBOOST_ROOT={}'.format(os.environ['CONDA_PREFIX']))

# example of build args
build_args = [
'--config', config
@@ -118,9 +123,8 @@ def build_cmake(self, ext):
"pylibvw"
]

cmake_directory = os.path.join(here, '..')
os.chdir(str(self.build_temp))
self.spawn(['cmake', str(cmake_directory)] + cmake_args)
self.spawn(['cmake'] + cmake_args + [str(here)])
if not self.dry_run:
self.spawn(['cmake', '--build', '.'] + build_args)
os.chdir(str(here))
@@ -173,11 +177,11 @@ def run_tests(self):


# Get the long description from the README file
with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(os.path.join(pkg_path, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()

# Get the current version for the python package from the configure.ac file
config_path = os.path.join(here, '..', 'version.txt')
config_path = os.path.join(here, 'version.txt')
with open(config_path, encoding='utf-8') as f:
version = f.readline().strip()

@@ -203,7 +207,8 @@ def run_tests(self):
'Programming Language :: Python :: 3.6',
],
keywords='fast machine learning online classification regression',
packages=find_packages(),
package_dir={'' : os.path.relpath(pkg_path)},
packages=find_packages(where=pkg_path),
platforms='any',
zip_safe=False,
include_package_data=True,
@@ -1,14 +1,16 @@
[tox]
envlist = py{27,35,36}
envlist = py{27,35,36,37}

[testenv]
basepython =
py27: python2.7
py35: python3.5
py36: python3.6
py37: python3.7
deps =
pytest
pandas
-r{toxinidir}/requirements.txt
commands =
python setup.py install
py.test tests
py.test python/tests

0 comments on commit 2ee2bcf

Please sign in to comment.
You can’t perform that action at this time.