New tests were added in test_metadata and old tests inherited from
distutils were still in test_dist, so I moved them into test_metadata
(except for one which was more at home in test_run) and merged
duplicates.
I also added some skips to lure contributors <wink>, optimized the
Metadata.update method a trifle, and added notes about a number of
issues.
A note: The tests in test_dist used to dump the Metadata objects to a
file in the METADATA format and look for strings in its contents; I
updated them to use the mapping API of Metadata instead. For some
fields with special writing rules, I have added tests to ensure my
conversion did not lose anything.
The right-hand part in [extension: foo] is now used as the name of the
extension module. (I changed the separator from = to : and allowed
whitespace to make the sections look nicer.)
This huge module is the heir of six distutils modules, and contains
a number of miscellaneous functions. I have attempted to help readers
of the source code with an annoted __all__. Removed or deprecated
functions have been removed from the documentation; I’m working on
another patch to document the remaining public functions.
For the curious:
The unzip_file and untar_file were used by (or intended to be used by)
“pysetup install path/to/archive.tar.gz”, but the code presently used
shutil.unpack_archive and an helper function, so I just deleted them.
They’re still in the repository if we need them in the future.
The find_packages function is not used anymore but I want to discuss
module and package auto-discovery (in “pysetup create”) again before
removing it.
subst_vars now lives in sysconfig; rfc822_escape is inlined in
packaging.metadata. Other functions are for internal use only, or
deprecated; I have left them out of __all__ and sprinkled TODO notes
for future cleanups.
There was already a test for this, but it was complicated and had a
subtle bug (custom command objects need to be put in dist.command_obj so
that other command objects may see them) that rendered it moot.
Packaging uses the shutil.make_archive function copied from distutils,
which does not support compress. There is no test to check that
“bdist --format whatever” works, so this slipped by.
These options were used to implement “setup.py --name”,
“setup.py --version”, etc. which are now handled by the pysetup metadata
action or direct parsing of the setup.cfg file.
As a side effect, the Distribution class no longer accepts a 'url' key
in its *attrs* argument: it has to be 'home-page' to be recognized as a
valid metadata field and passed down to the dist.metadata object.
I cleaned up some comments, docstrings and code along the way.
The existing test_record is not easily extendable to add script files or
extension modules: it collects all files from fake_dists and generates a
RECORD file at runtime. I felt more comfortable adding a new test
written from scratch more self-contained (just one project with
well-defined files) and more stupid (the checksums and sizes are
computed once and hard-coded).
- Rename an attribute and create it in initialize_options instead of
finalize_options to match the other install_* classes
- Remove unnecessary method call in tests
I need to copy this file in another test too, so I moved the support
code to distutils.tests.support and improved it to use proper skip
machinery instead of custom print/return/test suite fiddling.
Contrary to my similar change in distutils tests, I did not add support
for finding xxmodule.c when running a test from the tests directory,
because in that case my compiler didn’t find Python.h, so I figured it’s
better to skip than to fail.
This prevents tests from failing when run from a Python installed in a
read-only directory. The code is a bit uglier; shutil.copytree calls
copystat on directories behind our back, so I had to add an os.walk
with os.chmod (*and* os.path.join!) calls. shutil, I am disappoint.
This changeset is dedicated to the hundreds of neurons that were lost
while I was debugging this on an otherwise fine afternoon.
Victor Stinner diagnosed on #12167 that some reference leaks came from
util._path_created, a set used for caching; there are two tests that
cause additions to this set, so now they clear it in tearDown, avoiding
17 refleaks. (My tests show that it’s necessary to clear the set in
only one test, clearing it in both does not stop more refleaks, but
there’s no harm in doing it.)
It is not possible to unload a module written in C, so use a subprocess to run
the tests on the module compiled by test_build_ext(). Using a subprocess, we
don't have to unload the module, save/restore sys.path, and the test can be run
more than once.
This commit fixes also an access error on rmtree() on Windows: because the
module was not really unloaded, it was not possible to remove the temporary
directory (it is not possible to remove a directory on Windows if it still
contains an open file).
- Use different Metadata objects to write and read a PKG-INFO (METADATA)
file, to make sure the tested values come from the file
- No need to restore methods on an instance after monkey-patching them:
the methods are still the same on the class
- Harmonize dedent calls
packaging.tests.support.TempdirManager: removing the current directory is not
allowed on Windows or Solaris. Store the current directory and restore it
before removing the temporary directory (which is used as the working directory
during the tests).
The two public functions in database default to sys.path if the given
*paths* argument is None; the private functions don’t have default
values for their arguments anymore, which is fine as the public
functions that call them pass their arguments down. Likewise in
install, the functions will pass down their *paths* arguments down to
database functions.
A one-line unneeded function in install was removed instead of being
changed, and the few remaining tests that used brute-force restoration
of sys.path have been cleaned up to use sys.path.remove.
packaging.util.check_environ will define HOME and PLAT if they don’t exist; for
some reason, it does not define PLAT when running the tests from a checkout (so
no regrtest warning) but does when running from an installed Python.
Cleaning up the envvar in test_dist fixes the warning on my machine, but I
suspect that a test runner using a different order to run files or running them
in parallel may have PLAT defined in its environment because of another test.
Quite a lot of code ends up calling check_environ; maybe we should just clean
up PLAT in every test. For now I’m doing this simple fix, we’ll see if we get
bug reports.