8000 Switch to importlib in setup.py by s-t-e-v-e-n-k · Pull Request #101 · benoitc/http-parser · GitHub
[go: up one dir, main page]

Skip to content

Switch to importlib in setup.py #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from distutils.command.build_ext import build_ext
from distutils.command.sdist import sdist as _sdist
import glob
from imp import load_source
import importlib.machinery
import importlib.util
import io
import os
import shutil
Expand All @@ -28,6 +29,16 @@
# find the compiler
ext_errors += (IOError,)


def load_source(modname, filename):
loader = importlib.machinery.SourceFileLoader(modname, filename)
spec = importlib.util.spec_from_file_location(
modname, filename, loader=loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
return module


http_parser = load_source("http_parser", os.path.join("http_parser",
"__init__.py"))

Expand Down
0