Skip to content

Commit

Permalink
Fix python build
Browse files Browse the repository at this point in the history
 - '3.7' is gone now. Don't build it.
 - 'distutils' has been removed from 3.12
 - replace distutils by setuptools and install setuptools ourselves.
  • Loading branch information
manugarg committed Nov 17, 2023
1 parent 59a35bd commit f4a5c4d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
strategy:
matrix:
os: [ubuntu, windows, macos]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}-latest

steps:
Expand All @@ -107,6 +107,11 @@ jobs:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Set up setuptools
run: |
python --version
python -mpip install setuptools
- name: make non-windows
if: ${{ matrix.os != 'windows' }}
run: make -C src pymod-dist
Expand Down Expand Up @@ -166,6 +171,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3

- name: Set up setuptools
run: |
python --version
python -mpip install setuptools
- name: make
run: make -C src pymod

Expand Down
19 changes: 9 additions & 10 deletions src/pymod/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
import os
import platform
import re
import setuptools
import shutil
import subprocess
import sys

from unittest.mock import patch
import distutils
from setuptools import setup, Extension

import distutils.cmd


def setup_dir():
Expand Down Expand Up @@ -88,7 +85,7 @@ def pacparser_version():
return sanitize_version(os.environ.get("PACPARSER_VERSION", "1.0.0"))


class DistCmd(distutils.cmd.Command):
class DistCmd(setuptools.Command):
"""Build pacparser python distribution."""

description = "Build pacparser python distribution."
Expand Down Expand Up @@ -126,7 +123,7 @@ def run(self):
)


@patch("distutils.cygwinccompiler.get_msvcr")
@patch("setuptools._distutils.cygwinccompiler.get_msvcr")
def main(patched_func):
python_home = os.path.dirname(sys.executable)

Expand All @@ -143,22 +140,24 @@ def main(patched_func):

libraries = []
extra_link_args = []

if sys.platform == "win32":
import distutils.cygwinccompiler

distutils.cygwinccompiler.get_msvcr = lambda: ["vcruntime140"]
extra_objects = ["../pacparser.o", "../spidermonkey/js.lib"]
libraries = ["ws2_32"]
# python_home has vcruntime140.dll
patched_func.return_value = ["vcruntime140"]
extra_link_args = ["-static-libgcc", "-L" + python_home]

pacparser_module = Extension(
pacparser_module = setuptools.Extension(
"_pacparser",
include_dirs=[".."],
sources=["pacparser_py.c"],
libraries=libraries,
extra_link_args=extra_link_args,
extra_objects=extra_objects,
)
setup(
setuptools.setup(
cmdclass={
"dist": DistCmd,
},
Expand Down

0 comments on commit f4a5c4d

Please sign in to comment.