Merge pull request #3649 from jaraco/goodbye-distutils

Remove distutils fallback.
This commit is contained in:
Anthony Scopatz 2020-08-01 10:59:51 -05:00 committed by GitHub
commit 1391aa7721
Failed to generate hash of commit
3 changed files with 74 additions and 62 deletions

View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* Xonsh now relies exclusively on Setuptools for install.
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -1,3 +1,6 @@
[build-system]
requires = ["setuptools", "wheel"]
[tool.black] [tool.black]
# better to keep default line-length than to match flake8 # better to keep default line-length than to match flake8
exclude = ''' exclude = '''

110
setup.py
View file

@ -3,7 +3,6 @@
"""The xonsh installer.""" """The xonsh installer."""
# Note: Do not embed any non-ASCII characters in this file until pip has been # Note: Do not embed any non-ASCII characters in this file until pip has been
# fixed. See https://github.com/xonsh/xonsh/issues/487. # fixed. See https://github.com/xonsh/xonsh/issues/487.
from __future__ import print_function, unicode_literals
import os import os
import sys import sys
import json import json
@ -14,21 +13,11 @@ try:
except ImportError: except ImportError:
pass pass
try: from setuptools import setup
from setuptools import setup from setuptools.command.sdist import sdist
from setuptools.command.sdist import sdist from setuptools.command.install import install
from setuptools.command.install import install from setuptools.command.develop import develop
from setuptools.command.develop import develop from setuptools.command.install_scripts import install_scripts
from setuptools.command.install_scripts import install_scripts
HAVE_SETUPTOOLS = True
except ImportError:
from distutils.core import setup
from distutils.command.sdist import sdist as sdist
from distutils.command.install import install as install
from distutils.command.install_scripts import install_scripts
HAVE_SETUPTOOLS = False
try: try:
from jupyter_client.kernelspec import KernelSpecManager from jupyter_client.kernelspec import KernelSpecManager
@ -301,26 +290,24 @@ else:
} }
if HAVE_SETUPTOOLS: class xdevelop(develop):
"""Xonsh specialization of setuptools develop class."""
class xdevelop(develop): def run(self):
"""Xonsh specialization of setuptools develop class.""" clean_tables()
build_tables()
dirty = dirty_version()
develop.run(self)
if dirty:
restore_version()
def run(self): def install_script(self, dist, script_name, script_text, dev_path=None):
clean_tables() if script_name == "xon.sh":
build_tables() # change default python3 to the concrete python binary used to install/develop inside xon.sh script
dirty = dirty_version() script_text = script_text.replace(
develop.run(self) " python3 ", ' "{}" '.format(sys.executable)
if dirty: )
restore_version() super().install_script(dist, script_name, script_text, dev_path)
def install_script(self, dist, script_name, script_text, dev_path=None):
if script_name == "xon.sh":
# change default python3 to the concrete python binary used to install/develop inside xon.sh script
script_text = script_text.replace(
" python3 ", ' "{}" '.format(sys.executable)
)
super().install_script(dist, script_name, script_text, dev_path)
def main(): def main():
@ -388,34 +375,33 @@ def main():
cmdclass=cmdclass, cmdclass=cmdclass,
scripts=scripts, scripts=scripts,
) )
if HAVE_SETUPTOOLS: # WARNING!!! Do not use setuptools 'console_scripts'
# WARNING!!! Do not use setuptools 'console_scripts' # It validates the dependencies (of which we have none) every time the
# It validates the dependencies (of which we have none) every time the # 'xonsh' command is run. This validation adds ~0.2 sec. to the startup
# 'xonsh' command is run. This validation adds ~0.2 sec. to the startup # time of xonsh - for every single xonsh run. This prevents us from
# time of xonsh - for every single xonsh run. This prevents us from # reaching the goal of a startup time of < 0.1 sec. So never ever write
# reaching the goal of a startup time of < 0.1 sec. So never ever write # the following:
# the following: #
# # 'console_scripts': ['xonsh = xonsh.main:main'],
# 'console_scripts': ['xonsh = xonsh.main:main'], #
# # END WARNING
# END WARNING skw["entry_points"] = {
skw["entry_points"] = { "pygments.lexers": [
"pygments.lexers": [ "xonsh = xonsh.pyghooks:XonshLexer",
"xonsh = xonsh.pyghooks:XonshLexer", "xonshcon = xonsh.pyghooks:XonshConsoleLexer",
"xonshcon = xonsh.pyghooks:XonshConsoleLexer", ],
], "pytest11": ["xonsh = xonsh.pytest_plugin"],
"pytest11": ["xonsh = xonsh.pytest_plugin"], }
} skw["cmdclass"]["develop"] = xdevelop
skw["cmdclass"]["develop"] = xdevelop skw["extras_require"] = {
skw["extras_require"] = { "ptk": ["prompt-toolkit>=2.0"],
"ptk": ["prompt-toolkit>=2.0"], "pygments": ["pygments>=2.2"],
"pygments": ["pygments>=2.2"], "mac": ["gnureadline"],
"mac": ["gnureadline"], "linux": ["distro"],
"linux": ["distro"], "proctitle": ["setproctitle"],
"proctitle": ["setproctitle"], "zipapp": ['importlib_resources; python_version < "3.7"'],
"zipapp": ['importlib_resources; python_version < "3.7"'], }
} skw["python_requires"] = ">=3.5"
skw["python_requires"] = ">=3.5"
setup(**skw) setup(**skw)