diff --git a/src/Makefile.win32 b/src/Makefile.win32 index fca7d0d0..3c82a949 100644 --- a/src/Makefile.win32 +++ b/src/Makefile.win32 @@ -61,8 +61,8 @@ pacparser.dll: pacparser.o spidermonkey/js.lib pacparser.lib: pacparser.dll pacparser.def lib /machine:i386 /def:pacparser.def -pactester: pactester.c pacparser.h pacparser.dll - $(CC) pactester.c -o pactester -lpacparser -L. -I. +pactester: pactester.c pacparser.h pacparser.o + $(CC) pactester.c pacparser.o -o pactester -ljs -Lspidermonkey -lws2_32 dist: pacparser.dll pactester pacparser.lib if exist dist rmdir /s /q dist @@ -83,21 +83,12 @@ pymod: pacparser.h pacparser.dll pacparser.o js.lib cd pymod && $(PYTHON) setup.py build --compiler=mingw32 cd .. && $(PYTHON) tests/runtests.py -pymod37: pacparser.h pacparser.dll - cd pymod && py -3.7 setup.py build --compiler=mingw32 - cd .. && py -3.7 tests\runtests.py +pymod-%: pacparser.h pacparser.dll pacparser.o js.lib + cd pymod && py -$* setup.py build --compiler=mingw32 + cd .. && py -$* tests\runtests.py -pymod38: pacparser.h pacparser.dll - cd pymod && py -3.8 setup.py build --compiler=mingw32 - cd .. && py -3.8 tests\runtests.py - -pymod39: pacparser.h pacparser.dll - cd pymod && py -3.9 setup.py build --compiler=mingw32 - cd .. && py -3.9 tests\runtests.py - -pymod310: pacparser.h pacparser.dll - cd pymod && py -3.10 setup.py build --compiler=mingw32 - cd .. && py -3.10 tests\runtests.py +pymod-dist-%: + cd pymod && py -$* setup.py dist clean: $(RM) pacparser.dll *.lib pacparser.def pacparser.exp pacparser.o pactester.exe libpacparser.a diff --git a/src/pymod/setup.py b/src/pymod/setup.py index 859b5237..01d9fbe0 100644 --- a/src/pymod/setup.py +++ b/src/pymod/setup.py @@ -25,13 +25,48 @@ identifying python setup and setting up some environment variables needed by Makefiles. """ -import sys +import glob import os +import platform +import shutil +import sys from unittest.mock import patch import distutils from setuptools import setup, Extension +import distutils.cmd + +class DistCmd(distutils.cmd.Command): + """Build pacparser python distribution.""" + + description = 'Build pacparser python distribution.' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + setup_dir = os.path.dirname(os.path.join(os.getcwd(), sys.argv[0])) + py_ver = '.'.join([str(x) for x in sys.version_info[0:2]]) + pp_ver = os.environ.get('PACPARSER_VERSION', '1.0.0') + + pacparser_module_path = glob.glob( + os.path.join(setup_dir, 'build', 'lib*%s' % py_ver))[0] + sys.path.insert(0, pacparser_module_path) + import pacparser + pp_ver = pacparser.version() + + dist = 'pacparser-python%s-%s-%s-%s' % ( + py_ver.replace('.',''), pp_ver, platform.system(), platform.machine()) + dist = dist.lower() + os.mkdir(dist) + shutil.copytree(os.path.join(pacparser_module_path, 'pacparser'), dist+'/pacparser') + + @patch('distutils.cygwinccompiler.get_msvcr') def main(patched_func): pacparser_version = os.environ.get('PACPARSER_VERSION', '1.0.0') @@ -53,7 +88,11 @@ def main(patched_func): libraries = libraries, extra_link_args = extra_link_args, extra_objects = extra_objects) - setup (name = 'pacparser', + setup ( + cmdclass={ + 'dist': DistCmd, + }, + name = 'pacparser', version = pacparser_version, description = 'Pacparser package', author = 'Manu Garg',