Skip to content

Commit

Permalink
update package format to wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Toepfer authored and Christian Toepfer committed Jun 15, 2021
1 parent 94285bc commit 8fbbd6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions pyrobuf/compile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import argparse
import atexit
import glob
import os
import sys
from setuptools import setup
from setuptools.command.install import install
from setuptools.dist import Distribution
from datetime import datetime

from Cython.Build import cythonize
Expand All @@ -23,6 +26,14 @@
VERSION = f'''{THE_TIME.year}.{THE_TIME.month}.{THE_TIME.day}'''\
f'''{THE_TIME.hour*3600+THE_TIME.minute*60+THE_TIME.second}'''

def _post_install(*args):
bdist_wheel_cmd = args[0].get_command_obj('bdist_wheel')
tag = '-'.join(bdist_wheel_cmd.get_tag())
os.system(f'python -m pip install --force-reinstall ./dist/{bdist_wheel_cmd.wheel_dist_name}-{tag}.whl')
class new_install(install):
def __init__(self, *args, **kwargs):
super(new_install, self).__init__(*args, **kwargs)
atexit.register(_post_install, *args)
class BasePackagePatch_BuildExt(build_ext):
""" Create __init__.py for base package, after build
"""
Expand Down Expand Up @@ -91,10 +102,11 @@ def parse_cli_args(cls):
clean=args.clean)

def compile(self):
script_args = ['build', '--build-base={0}'.format(self.build)]
script_args = ['build', '--build-base={0}'.format(self.build), 'bdist_wheel']

cmds = dict(build_ext=BasePackagePatch_BuildExt)
if self.install:
script_args.append('install')
cmds['install'] = new_install

if self.force:
script_args.append('--force')
Expand All @@ -108,7 +120,7 @@ def compile(self):
version=VERSION,
ext_modules=cythonize(self._pyx_files,
include_path=self.include_path),
cmdclass= dict(build_ext=BasePackagePatch_BuildExt),
cmdclass=cmds,
script_args=script_args)

def extend(self, dist):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys


VERSION = "0.9.3.9"
VERSION = "0.9.3.10"
HERE = os.path.dirname(os.path.abspath(__file__))
PYROBUF_DEFS_PXI = "pyrobuf_defs.pxi"
PYROBUF_LIST_PXD = "pyrobuf_list.pxd"
Expand Down

0 comments on commit 8fbbd6a

Please sign in to comment.