Skip to content

Commit

Permalink
Added PyPI Mutiple Wheels Packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
WillianFuks committed May 22, 2020
1 parent 6adcc24 commit 4b17a9b
Show file tree
Hide file tree
Showing 6 changed files with 596 additions and 194 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,7 @@ dmypy.json

# Cython annotations
pyClickModels/*.html

# json-c building folders
json-c-build/
json-c/
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: flake8 coverage coverage-html test
.PHONY: flake8 coverage coverage-html test publish

flake8:
pip install -U flake8
Expand All @@ -21,3 +21,13 @@ coverage-html:

test:
python setup.py test

publish:
pip install -U setuptools
pip install -U wheel
pip install 'twine>=1.5.0'
pip install auditwheel
sh ./scripts/build_wheels.sh
#twine upload --repository testpypi dist/*
twine upload dist/*
rm -fr build dist .egg *.egg-info
3 changes: 3 additions & 0 deletions pyClickModels/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VERSION = (0, 0, 0)

__version__ = '.'.join([str(e) for e in VERSION])
18 changes: 18 additions & 0 deletions scripts/build_wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
docker run -v $(pwd):/pyClickModels quay.io/pypa/manylinux1_x86_64 sh -c '''
yum install -y json-c-devel
cd /pyClickModels
for PYVER in /opt/python/*/bin/; do
if [[ $PYVER != *"27"* ]]; then
"${PYVER}/pip" install -U setuptools
"${PYVER}/pip" install -r requirements.txt
"${PYVER}/python" setup.py sdist bdist_wheel
fi
done
for whl in dist/*.whl; do
auditwheel repair "$whl" --plat "manylinux2010_x86_64" -w dist/
rm $whl
done
'''
52 changes: 49 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
from __future__ import absolute_import

import os
import sys
import Cython.Compiler.Options
from codecs import open
from Cython.Distutils import build_ext
from setuptools import setup
from Cython.Build import cythonize
from distutils.extension import Extension
from setuptools.command.test import test as TestCommand


here = os.path.abspath(os.path.dirname(__file__))
Cython.Compiler.Options.annotate = True

_version = {}
_version_path = os.path.join(here, 'pyClickModels', '__version__.py')

with open(_version_path, 'r', 'utf-8') as f:
exec(f.read(), _version)

with open('README.md', 'r', 'utf-8') as f:
readme = f.read()


if sys.argv[-1] == 'publish':
"""
Deploy to PyPI is still somewhat manual. It runs locally on Docker instead of relying
on Travis.
"""
os.system('./scripts/build_wheels.sh')
os.system('python setup.py sdist bdist_wheel')
os.system('twine upload -r pypitest dist/*')
sys.exit()


def build_define_macros():
"""
Expand Down Expand Up @@ -115,12 +140,17 @@ def run_tests(self):

setup(
name='pyClickModels',
version='0.0.0',
version=_version['__version__'],
author='Willian Fuks',
author_email='willian.fuks@gmail.com',
description='ClickModels for Search Engines Implemented on top of Cython.',
packages=packages,
include_package_data=True,
package_data={'pyClickModels': ['*.pxd']},
package_data={
'pyClickModels': ['*.pxd']
},
long_description=readme,
long_description_content_type='text/markdown',
install_requires=install_requires,
tests_require=tests_require,
setup_requires=setup_requires,
Expand All @@ -133,5 +163,21 @@ def run_tests(self):
'build_ext': build_ext,
'test': PyTest
},
zip_safe=False
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Cython',
'Topic :: Scientific/Engineering',
],
)

0 comments on commit 4b17a9b

Please sign in to comment.