-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit circumvents a countably infinite number of issues introduced by both pip 19.0.0 and 19.1.0 - all pertaining to PEP 517 and 518, which is to say "pyproject.toml". The mere existence of a "pyproject.toml" file fundamentally breaks pip in inexplicable, horrifying ways: a significantly worse state of affairs than the pre-PEP 517 and 518 days of setuptools yore. Say what you will of setuptools ("...so much hate"), but at least it sort of fundamentally worked. The same cannot be said of recent pip versions, which absolutely do not work whatsoever. Die, pip! Specifically, this commit: * Mandatory dependencies bumped: * setuptools >= 38.2.0. The same version of setuptools required by BETSEE is now required by BETSE, ensuring parity between the two codebases and avoiding painful dependency conflicts. For safety, this dependency is repeated in the top-level "pyproject.toml" file. * Installation improved: * pypa/pip#6163 resolved. All files and subdirectories of the project directory containing the top-level "setup.py" script are now safely registered to be importable modules and packages. Technically, this should not be required. The current build framework (e.g., pip, setuptools) should implicitly guarantee this to be the case. Indeed, the obsolete setuptools-based "easy_install" script does so. Sadly, pip >= 19.0.0 fails to do so for projects defining a top-level "pyproject.toml" file. Upstream purports to have resolved this, but the most recent stable release of pip continues to suffer this. * pypa/pip#6434 resolved. The top-level "pyproject.toml" file now explicitly declares a default value for the "build-backend" key. Doing so safeguards backward compatibility with pip 19.1.0, which erroneously violated PEP 51{7,8} by failing to fallback to a sane default value in the absence of this key. If this key is left undeclared, pip 19.1.0 fails on attempting to perform an editable (i.e., developer-specific) installation of this application. * Documentation revised: * pip-based editable installation. The top-level "README.rst" file now advises developers to leverage "pip" rather than "setuptools" when performing an editable installation of this application. * "setup.cfg"-based PyPI documentation. The top-level "setup.cfg" file now transcludes the contents of the top-level "README.rst" file, a substantial improvement over the prior code-based approach strewn throughout the codebase (e.g., "setup.py", "betse_setup.buputil"). * API generalized: * Defined a new "betse.util.py.module.pyimport" submodule: * Renamed the prior betse.util.py.pys.add_import_dirname() function to register_dir() for brevity and clarity. * Git maintenance: * Ignored all top-level pip-specific temporary directories (e.g., "pip-wheel-metadata") with respect to Git tracking. (Contemptible contusions of the combustible dirigible!)
- Loading branch information
Showing
11 changed files
with
251 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
# --------------------( LICENSE )-------------------- | ||
# Copyright 2014-2019 by Alexis Pietak & Cecil Curry. | ||
# See "LICENSE" for further details. | ||
|
||
''' | ||
Low-level module and package importation facilities. | ||
This submodule *only* defines functions implementing non-standard and | ||
occasionally risky "black magic" fundamentally modifying Python's standard | ||
importation semantics and mechanics. This submodule does *not* define | ||
commonplace functions for dynamically importing modules or testing or | ||
validating that importation. | ||
See Also | ||
---------- | ||
:mod:`betse.util.py.module.pymodname` | ||
Related submodule defining functions importing modules by name as well as | ||
testing and validating that importation. | ||
''' | ||
|
||
# ....................{ IMPORTS }.................... | ||
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
# WARNING: To raise human-readable exceptions on missing mandatory dependencies, | ||
# the top-level of this module may import *ONLY* from packages guaranteed to | ||
# exist at installation time -- which typically means *ONLY* BETSE packages and | ||
# stock Python packages. | ||
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
import sys | ||
from betse.util.io.log import logs | ||
from betse.util.type.types import type_check | ||
|
||
# ....................{ REGISTRARS }.................... | ||
@type_check | ||
def register_dir(dirname: str) -> None: | ||
''' | ||
Register all files and subdirectories of the directory with the passed | ||
dirname to be importable modules and packages (respectively) for the | ||
remainder of the active Python process if this directory has yet to be | ||
registered *or* reduce to a noop otherwise (i.e., if this directory is | ||
registered already). | ||
Specifically, this function appends this dirname to the current | ||
:data:`sys.path` listing (in order) the dirnames of all directories to be | ||
iteratively searched for any module or package on first importing that | ||
module or package. To comply with Python standards in which the first item | ||
of this list is either the dirname of the directory containing the script | ||
from which this process was invoked *or* the empty string (signifying the | ||
current directory), this list is appended to rather than prepended to. | ||
Parameters | ||
---------- | ||
dirname : str | ||
Absolute or relative path of the directory to be registered. | ||
''' | ||
|
||
# Avoid circular import dependencies. | ||
from betse.util.path import dirs | ||
|
||
# Log this addition. | ||
logs.log_debug('Registering import directory: %s', dirname) | ||
|
||
# If this directory does *NOT* exist or is unreadable, raise an exception. | ||
dirs.die_unless_dir(dirname) | ||
|
||
# If the current PYTHONPATH already contains this directory... | ||
if dirname in sys.path: | ||
# Log this edge case. | ||
logs.log_debug('Ignoring already registered import directory.') | ||
|
||
# Reduce to a noop. | ||
return | ||
# Else, the current PYTHONPATH does *NOT* already contain this directory. | ||
|
||
# Append this directory to the current PYTHONPATH. | ||
sys.path.append(dirname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.