summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Davis <mrd@redhat.com>2021-09-23 15:30:53 -0700
committerMatt Davis <mrd@redhat.com>2021-09-23 15:34:34 -0700
commita6d384c52ea54ded80df27032c7b6d3a98b0c2fa (patch)
treeea856093e5ab2b505b2d445c56a7a95c91b80258
parent8f3f9795b4ccc7087c439aad8342eaf916f273d0 (diff)
downloadpyyaml-git-a6d384c52ea54ded80df27032c7b6d3a98b0c2fa.tar.gz
Various setup fixes
* enable use of setuptools-embedded distutils * list 3.10 support * remove setup.cfg (and deprecated metadata in it) * run tests on ephemeral copy of intermediate build bits
-rw-r--r--setup.cfg25
-rw-r--r--setup.py36
2 files changed, 29 insertions, 32 deletions
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index b186858..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,25 +0,0 @@
-
-# The INCLUDE and LIB directories to build the '_yaml' extension.
-# You may also set them using the options '-I' and '-L'.
-[build_ext]
-
-# List of directories to search for 'yaml.h' (separated by ':').
-#include_dirs=/usr/local/include:../../include
-
-# List of directories to search for 'libyaml.a' (separated by ':').
-#library_dirs=/usr/local/lib:../../lib
-
-# An alternative compiler to build the extension.
-#compiler=mingw32
-
-# Additional preprocessor definitions might be required.
-#define=YAML_DECLARE_STATIC
-
-# The following options are used to build PyYAML Windows installer
-# for Python 2.7 on my PC:
-#include_dirs=../../../libyaml/tags/0.1.4/include
-#library_dirs=../../../libyaml/tags/0.1.4/win32/vs2008/output/release/lib
-#define=YAML_DECLARE_STATIC
-
-[metadata]
-license_file = LICENSE \ No newline at end of file
diff --git a/setup.py b/setup.py
index a9b5d90..ac378ba 100644
--- a/setup.py
+++ b/setup.py
@@ -32,6 +32,7 @@ CLASSIFIERS = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
@@ -63,11 +64,15 @@ int main(void) {
"""
-import sys, os, os.path, platform, warnings
+import sys, os, os.path, pathlib, platform, shutil, tempfile, warnings
+
+# for newer setuptools, enable the embedded distutils before importing setuptools/distutils to avoid warnings
+os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'local'
-from distutils import log
from setuptools import setup, Command, Distribution as _Distribution, Extension as _Extension
from setuptools.command.build_ext import build_ext as _build_ext
+# NB: distutils imports must remain below setuptools to ensure we use the embedded version
+from distutils import log
from distutils.errors import DistutilsError, CompileError, LinkError, DistutilsPlatformError
with_cython = False
@@ -246,11 +251,28 @@ class test(Command):
def run(self):
build_cmd = self.get_finalized_command('build')
build_cmd.run()
- sys.path.insert(0, build_cmd.build_lib)
- sys.path.insert(0, 'tests/lib')
- import test_all
- if not test_all.main([]):
- raise DistutilsError("Tests failed")
+
+ # running the tests this way can pollute the post-MANIFEST build sources
+ # (see https://github.com/yaml/pyyaml/issues/527#issuecomment-921058344)
+ # until we remove the test command, run tests from an ephemeral copy of the intermediate build sources
+ tempdir = tempfile.TemporaryDirectory(prefix='test_pyyaml')
+
+ try:
+ # have to create a subdir since we don't get dir_exists_ok on copytree until 3.8
+ temp_test_path = pathlib.Path(tempdir.name) / 'pyyaml'
+ shutil.copytree(build_cmd.build_lib, temp_test_path)
+ sys.path.insert(0, str(temp_test_path))
+ sys.path.insert(0, 'tests/lib')
+
+ import test_all
+ if not test_all.main([]):
+ raise DistutilsError("Tests failed")
+ finally:
+ try:
+ # this can fail under Windows; best-effort cleanup
+ tempdir.cleanup()
+ except Exception:
+ pass
cmdclass = {