Commit b59076e9 authored by xoviat's avatar xoviat

pep517: add module

Add a module that implements the PEP 517 specification.
parent 1b192005
...@@ -30,6 +30,14 @@ __import__('pkg_resources.extern.packaging.specifiers') ...@@ -30,6 +30,14 @@ __import__('pkg_resources.extern.packaging.specifiers')
__import__('pkg_resources.extern.packaging.version') __import__('pkg_resources.extern.packaging.version')
skip_install_eggs = False
class SetupRequirementsError(BaseException):
def __init__(self, specifiers):
self.specifiers = specifiers
def _get_unpatched(cls): def _get_unpatched(cls):
warnings.warn("Do not call this function", DeprecationWarning) warnings.warn("Do not call this function", DeprecationWarning)
return get_unpatched(cls) return get_unpatched(cls)
...@@ -332,6 +340,9 @@ class Distribution(Distribution_parse_config_files, _Distribution): ...@@ -332,6 +340,9 @@ class Distribution(Distribution_parse_config_files, _Distribution):
self.dependency_links = attrs.pop('dependency_links', []) self.dependency_links = attrs.pop('dependency_links', [])
assert_string_list(self, 'dependency_links', self.dependency_links) assert_string_list(self, 'dependency_links', self.dependency_links)
if attrs and 'setup_requires' in attrs: if attrs and 'setup_requires' in attrs:
if skip_install_eggs:
raise SetupRequirementsError(attrs['setup_requires'])
else:
self.fetch_build_eggs(attrs['setup_requires']) self.fetch_build_eggs(attrs['setup_requires'])
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'): for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
vars(self).setdefault(ep.name, None) vars(self).setdefault(ep.name, None)
......
import os
import sys
import subprocess
import tokenize
import shutil
import tempfile
from setuptools import dist
from setuptools.dist import SetupRequirementsError
SETUPTOOLS_IMPLEMENTATION_REVISION = 0.1
def _run_setup(setup_script='setup.py'): #
# Note that we can reuse our build directory between calls
# Correctness comes first, then optimization later
__file__=setup_script
f=getattr(tokenize, 'open', open)(__file__)
code=f.read().replace('\\r\\n', '\\n')
f.close()
exec(compile(code, __file__, 'exec'))
def get_build_requires(config_settings):
requirements = ['setuptools', 'wheel']
dist.skip_install_eggs = True
sys.argv = sys.argv[:1] + ['egg_info'] + \
config_settings["--global-option"]
try:
_run_setup()
except SetupRequirementsError as e:
requirements += e.specifiers
dist.skip_install_eggs = False
return requirements
def get_requires_for_build_wheel(config_settings=None):
return get_build_requires(config_settings)
def get_requires_for_build_sdist(config_settings=None):
return get_build_requires(config_settings)
def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
sys.argv = sys.argv[:1] + ['dist_info', '--egg-base', metadata_directory]
_run_setup()
def build_wheel(wheel_directory, config_settings=None,
metadata_directory=None):
wheel_directory = os.path.abspath(wheel_directory)
sys.argv = sys.argv[:1] + ['bdist_wheel'] + \
config_settings["--global-option"]
_run_setup()
if wheel_directory != 'dist':
shutil.rmtree(wheel_directory)
shutil.copytree('dist', wheel_directory)
def build_sdist(sdist_directory, config_settings=None):
sdist_directory = os.path.abspath(sdist_directory)
sys.argv = sys.argv[:1] + ['sdist'] + \
config_settings["--global-option"]
_run_setup()
if sdist_directory != 'dist':
shutil.rmtree(sdist_directory)
shutil.copytree('dist', sdist_directory)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment