Commit Graph

176 Commits

Author SHA1 Message Date
Éric Araujo 2c30e3999c Change one name in packaging’s test_uninstall to avoid confusion.
install_lib may be the name of a module, a command or an option, so I
find it clearer to use site_packages to refer to a string object
containing the path of the site-packages directory created in a
temporary directory during tests.
2011-10-06 04:59:41 +02:00
Éric Araujo c4637714b0 Cosmetic fixes for whitespace and a regex in packaging.
The goal of the regex is to catch a (alpha), b (beta), c or rc
(release candidate), so the existing pattern puzzled me. Tests were
OK before and after the change.
2011-10-05 01:46:37 +02:00
Éric Araujo 763cc6eaee Add tests for comparing candidate and final versions in packaging (#11841).
This used to be buggy; Filip Gruszczyński contributed tests and a code
patch but the latter is not needed.
2011-10-05 01:41:14 +02:00
Éric Araujo 4c0b7070ce Squash last tempdir leak in packaging tests.
Sweet taste of victory!  Alexis, you can fix the threads leaks :)
2011-09-19 20:57:52 +02:00
Éric Araujo 505f0ebf88 Final bag of small changes coming from distutils2.
- minor cleanup in Metadata
- trigger creation of the sysconfig._CONFIG_VARS dict
- home_page is used over home-page: it’s not a compound word, it’s an
  escaped space

Distutils2 is now synchronized with Packaging.
2011-09-19 15:12:23 +02:00
Éric Araujo cc95dd81f3 Branch merge 2011-09-18 20:24:27 +02:00
Éric Araujo 229011d949 Make a number of small changes to ease the backport to distutils2 2011-09-18 20:11:48 +02:00
Éric Araujo 41479450ec Fix fallback base class when tests run without threading 2011-09-18 17:00:38 +02:00
Éric Araujo 7724a6c10c Packaging cleanup: remove conditionals for < 2.6 support.
PEP 370 features and sys.dont_write_bytecode are always available
in 3.3; the distutils2 backport still has the conditionals.

I also renamed an internal misnamed method and fixed a few things
(“packaging2” name, stray print, unused import, fd leak).
2011-09-17 03:31:51 +02:00
Ned Deily e30186bf4b Issue #12765: Fix packaging.test.test_database failures on OS X due
to unwarranted assumption about absolute paths: on OS X /var is a
symlink to /private/var.  (Also true for /etc and /tmp).
2011-09-15 15:09:23 -07:00
Éric Araujo 37ccd6f794 Fix packaging.database.Distribution.list_distinfo_files (#12785).
This method was supposed to return only the file under the dist-info
directory, but it actually returned all installed files.

The tests didn’t catch this because they were flawed; I updated them.
Thanks to Nadeem Vawda and Jeremy Kloth for testing.

As a bonus, the removal of os.path.relpath use should also fix the
Windows buildbots.
2011-09-15 18:18:51 +02:00
Éric Araujo cde6576820 Remove unneeded --all option of “pysetup list”.
The command without arguments already prints all installed distributions
found.

In addition, change “releases” for “projects” in the description of the
list action.  Strictly speaking, one installed distribution satisfies
the requirement for a release (i.e. version) of a project, but as
currently only one release per project can be installed at a time, the
two are somewhat equivalent, and “project” is more understandable in
help texts (which call their argument “dist”, by the way..)
2011-09-12 16:45:38 +02:00
Éric Araujo e6db7a3a29 Fix determination of Metadata version in packaging (#8933).
Original patch by Filip Gruszczyński.
2011-09-10 05:22:48 +02:00
Éric Araujo 6bbd775377 Consolidate tests for packaging.metadata.
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.
2011-09-10 05:18:20 +02:00
Victor Stinner d4d8ae5a42 Issue #9561: packaging now writes egg-info files using UTF-8
instead of the locale encoding
2011-09-06 00:11:13 +02:00
Éric Araujo ae5af15e41 Minor: tweak docstrings and __all__ in packaging.tests.support 2011-09-01 23:48:13 +02:00
Éric Araujo d9299e97ab Minor improvement to extensions in setup.cfg: check parent package 2011-09-01 07:01:13 +02:00
Éric Araujo 336b4e4ff3 Minor improvement to extensions section in setup.cfg.
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.)
2011-09-01 06:29:11 +02:00
Éric Araujo 95fc53f2b3 Clean up packaging.util: add __all__, remove some unused functions.
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.
2011-09-01 05:11:29 +02:00
Éric Araujo b9fe54cccc Make bdist_* commands respect --skip-build passed to bdist (#10946).
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.
2011-08-30 01:42:50 +02:00
Éric Araujo 83ab3f319b Remove obsolete mentions of the compress program and .Z archives.
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.
2011-08-30 01:19:02 +02:00
Éric Araujo 5e48c78ecf Remove display options (--name, etc.) from the Distribution class.
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.
2011-08-30 00:55:02 +02:00
Éric Araujo 1329185890 Minor code simplification 2011-08-26 00:05:11 +02:00
Éric Araujo ced7eda717 Another (hopefully last) fix for test_packaging on Windws (#12678) 2011-08-25 18:13:58 +02:00
Éric Araujo e049f470cd Fix test_packaging on Windows (#12678).
See the distutils commit message for more detail.
2011-08-24 02:15:25 +02:00
Éric Araujo 0fe3605cac Try to fix packaging tests using build_ext on Windows (#12678) 2011-08-23 21:38:13 +02:00
Éric Araujo ad457d6d50 Fix test_command_install_dist in shared Python builds 2011-08-21 17:38:56 +02:00
Éric Araujo 2737222b49 Factor out the build_ext fixup for shared Python builds.
I need this to fix the failing test_command_install_dist.
2011-08-21 17:38:36 +02:00
Éric Araujo cd7c3d9d5f Remove obsolete code 2011-08-21 17:37:36 +02:00
Éric Araujo 0a733627f9 Add a simple test for the packaging RECORD file.
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).
2011-08-20 09:31:25 +02:00
Éric Araujo ba9b2689be Minor cleanup
- 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
2011-08-20 09:19:25 +02:00
Éric Araujo 540edc6e66 Add a test for extension modules in the old-style record file 2011-08-20 07:42:56 +02:00
Éric Araujo 746e72d59c Rework test_old_record a bit to make the test more exact
(i.e. to check the files found are what we expect)
2011-08-20 07:34:43 +02:00
Éric Araujo 60b0d31e35 Refactor the copying of xxmodule.c in packaging tests (#12141).
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.
2011-08-20 07:27:47 +02:00
Éric Araujo 9bb6dfe0a8 Restore $HOME after test has run (should fix #12765) 2011-08-19 17:47:52 +02:00
Éric Araujo 4460abea64 Use our existing drop-in, no-op decorator instead of redefining it.
Patch by Francisco Martin Brugue.
2011-08-12 00:15:41 +02:00
Éric Araujo b85b966de6 Stop trying to write into the stdlib during packaging tests (#12331).
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.
2011-07-31 20:47:47 +02:00
Éric Araujo bab50cb124 Minor packaging cleanup.
- Use shortcut dist.version instead of going through metadata;
- Use %r throughout to display project names and paths.
2011-07-29 02:37:21 +02:00
Antoine Pitrou db535957cd test_packaging should clean up after itself (but it doesn't really) 2011-07-15 23:26:19 +02:00
Éric Araujo eb39294101 Silence 2to3 warnings in packaging tests 2011-07-15 17:49:20 +02:00
Éric Araujo 4468e55d4b Close file handles in a timely manner in packaging.database (#12504).
This fixes a bug with the remove (uninstall) feature on Windows.  Patch
by Thomas Holmes.
2011-07-08 17:22:19 +02:00
Éric Araujo ce5fe83878 Factor out code used by packaging commands for HTTP requests (#12169).
We now have one function to prepare multipart POST requests, and we use
CRLF, as recommended by the HTTP spec (#10150).  Initial patch by John
Edmonds.
2011-07-08 16:27:12 +02:00
Ned Deily 5c727cb978 Issue #9516: Port OS X deployment target tests from distutils to packaging
test_command_build_ext.
2011-06-28 20:03:17 -07:00
Ned Deily 4a1ec12999 Issue #12141: Install copies of template C module file so that
test_build_ext of test_distutils and test_command_build_ext of
test_packaging are no longer silently skipped when
run outside of a build directory.
2011-06-28 00:53:54 -07:00
Éric Araujo 3e425ac64b packaging: Add the project directory to sys.path to support local setup hooks.
Original patch by Vinay Sajip on #11637.
2011-06-19 21:23:43 +02:00
Éric Araujo 348c572dcf Fix typo 2011-06-19 18:53:31 +02:00
Éric Araujo 74d68135ad Brange merge 2011-06-17 19:38:38 +02:00
Éric Araujo ed5d2f1310 Minor tweaks to packaging tests.
- Move a tearDown method right after setUp
- Use assertRaises instead of reinventing it
- Skip a test instead of commenting it out, as a reminder
2011-06-17 15:47:41 +02:00
Éric Araujo c06f46f74c Packaging tests: don’t let an internal cache grow indefinitely.
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.)
2011-06-17 15:43:18 +02:00
Victor Stinner 723993983a Issue #12333: run tests on the new module in a subprocess
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).
2011-06-17 13:52:56 +02:00
Victor Stinner 0f270b2c37 Issue #12333: close files before removing the directory
packaging.tests.support.TempdirManager: rmtree() fails on Windows if there are
still open files in the directory.
2011-06-17 13:25:53 +02:00
Éric Araujo d2c7e3fe96 Minor tweaks in packaging’s test_dist.
- 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
2011-06-17 13:24:33 +02:00
Victor Stinner ac6602bdc1 Issue #12333: restore the previous dir before removing the current directory
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).
2011-06-17 12:20:46 +02:00
Éric Araujo 6f67765389 Stop binding sys.path as default parameter value in packaging.
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.
2011-06-16 23:43:15 +02:00
Éric Araujo b6be20ca33 Packaging: remove last mentions and uses of setup.py in the code.
Now only the compatibility layer (in create, util and install) talk
about setup.py.
2011-06-16 23:34:55 +02:00
Éric Araujo 434812d569 Clean up packaging.tests.test_mixin2to3 2011-06-16 23:21:01 +02:00
Victor Stinner 4e97abce2d Issue #12167: Fix a reafleak in packaging.tests.PyPIServer constructor
Don't modify mutable default arguments...
2011-06-15 23:58:57 +02:00
Éric Araujo 043f5ae697 Specify the encoding of the setup.cfg in one packaging test (#12320) 2011-06-12 22:04:58 +02:00
Éric Araujo 643cb7345f Allow multiple setup hooks in packaging’s setup.cfg files (#12240).
Original patch by Erik Bray.
2011-06-11 00:33:38 +02:00
Éric Araujo 8474f2901b setup.cfg: Document that description-file can contain more than one file 2011-06-11 00:21:18 +02:00
Éric Araujo 3605030c9b Fix assorted bugs in packaging.util.cfg_to_args (#11595).
Original patch by Erik Bray.
2011-06-10 23:52:26 +02:00
Éric Araujo fa6cfbc4f7 Don’t try to install something when running from uninstalled source (#12246).
Original patch by Tshepang Lekhonkhobe.
2011-06-10 18:31:40 +02:00
Éric Araujo 2b612220e4 Clean up extra environment variable after packaging tests.
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.
2011-06-10 04:29:43 +02:00
Éric Araujo f53cd89006 Fix omission in test for packaging install_distinfo command.
The code does not write checksum or file length for .pyc and .pyo in the RECORD
file, in compliance with PEP 376, but the test forgot to take .pyo into
account.  This was not caught because there were no .pyo in the checkout, but
after installing there are .pyo files created by compileall, and the test picks
them up.
2011-06-10 03:53:49 +02:00
Éric Araujo 0a975f957d Fix example in packaging test_config.
The example C extension used the “three.fast_taunt” name, but no “three” parent
was defined in the setup.cfg.  This did not cause a failure nor even print a
warning, we may want to change that.
2011-06-09 07:47:25 +02:00
Éric Araujo 04fc999c05 Packaging cleanup: remove use of script_name where obsolete 2011-06-08 04:06:50 +02:00
Éric Araujo 69cdf9294f Fix UnboundLocalError in a finally block of one packaging test 2011-06-06 22:24:19 +02:00
Éric Araujo 7373fccd50 Fix sdist to always include setup.cfg (#11092), to comply with the spec 2011-06-06 21:55:43 +02:00
Éric Araujo 078368fe4d Use strings instead of sets of lines in packaging.create tests.
Using sets in tests did not check whether the values were written in the right
section or with the right key.
2011-06-06 20:59:56 +02:00
Éric Araujo de7563bd3c Fix comment 2011-06-06 20:28:13 +02:00
Éric Araujo 2ef747cb77 Cleanup in packaging: don’t unnecessarily instantiate exceptions 2011-06-04 22:33:16 +02:00
Éric Araujo 5d5bde1df2 Document autoflushing in packaging.test.support.LoggingCatcher.get_logs.
I’m afraid my docstring is not as clear as it should be, but I can’t
find a concise way of describing what the code does.  Suggestions for
improvements welcome.
2011-06-03 17:28:23 +02:00
Éric Araujo 8c86ecdab5 Fix format of warnings from the packaging check command 2011-06-02 14:54:44 +02:00
Éric Araujo 78af7d8392 Make packaging.tests.support.LoggingCatcher.get_logs flush the log handler.
This removes the need to call flush manually in each test, except when
testing code that creates warning without checking them.
2011-06-02 14:53:59 +02:00
Éric Araujo 98b6592266 Branch merge 2011-06-01 19:47:06 +02:00
Éric Araujo 9deedf696e Re-apply distutils2 changes lost before the merge of packaging.
wrap_text was removed in favor of standard textwrap but the removal of the
function was lost in a bad merge; a change in sdist mysteriously disappeared.
2011-05-31 18:04:32 +02:00
Éric Araujo b4fefc8fa2 Fix test name in debug message 2011-05-31 14:33:32 +02:00
Tarek Ziade 5a5ce388ed make sure we check for write access before starting the install, and add correct exit code 2011-05-31 12:09:34 +02:00
Tarek Ziade f47fa58b62 better UI when the user does not have the perms to remove the project 2011-05-30 23:26:51 +02:00
Tarek Ziade 1cc9bbd751 fixed the test_uninstall patch 2011-05-30 19:16:49 +02:00
Tarek Ziade 2da756592b removed spurious output 2011-05-30 12:25:21 +02:00
Tarek Ziade b1b6e1384c Cleaned up the installer output behavior.
This change also makes sure the logger handlers are not alterated after an
installation. That also fixes the remaining environment alteration issue in
test_packaging.
2011-05-30 12:07:49 +02:00
Tarek Ziade 43f289ad88 cleanup packaging.database 2011-05-30 11:07:54 +02:00
Tarek Ziade a17d8883fd a resource module for 2 functions is overkill. database is the right place for those 2011-05-30 10:57:44 +02:00
Éric Araujo 7f9b37be45 Port r86353 to packaging (#10359: “;” after function definition is invalid in ISO C) 2011-05-29 02:59:52 +02:00
Éric Araujo 601aba6f15 Merge touch-ups and fixes for #9831 (+port fix to packaging) and #9223 from 3.2 2011-05-29 00:56:39 +02:00
Tarek Ziade 5eb555990a Issue #12180: Fixed a few remaining errors in test_packaging when no threading. 2011-05-25 23:46:09 +02:00
Victor Stinner 9bcfacd4fc Issue #12167: packaging.tests.test_dist unloads the temporary module
Fix a reference leak.
2011-05-24 14:01:39 +02:00
Victor Stinner 79d1b1ce3f Issue #12167: packaging.tests.support, LoggingCatcher restores correctly the
log level. Avoid also calls to .addCleanup() in setUp().
2011-05-24 13:59:21 +02:00
Tarek Ziade e1177d9d17 Issue #12125: fixed the failures under Solaris due to improper test cleanup. 2011-05-23 19:07:56 +02:00
Tarek Ziade fabc30833f fixed the cwd cleanup in packaging test_util 2011-05-23 18:47:27 +02:00
Tarek Ziade eb64b61bf5 make sure the cwd is restored on tearDown 2011-05-23 18:31:20 +02:00
Tarek Ziade a1ae533ac9 make sure build_dir.build_lib is synced to the faked build location 2011-05-23 17:35:20 +02:00
Tarek Ziade e5f9cbdaae skip more tests in packaging if threading is not supported 2011-05-23 00:41:27 +02:00
Tarek Ziade a3c1545a2e not using a server name anymore as the 127.0.0.1 <> localhost symmetry is not true under Windows 7 2011-05-22 23:25:48 +02:00
Tarek Ziade 3517369894 Issue 12132 - skip the test_buil_ext test if the xx module is not found 2011-05-22 22:09:55 +02:00
Tarek Ziade 2bc55e482e Issue 10126 - backported distutils fix for the enable-share mode into packaging 2011-05-22 21:21:44 +02:00
Tarek Ziade 2c40f60c32 added the Content-Length header. that fixes the weird packaging.pypi.errors.HashDoesNotMatch errors 2011-05-21 23:59:09 +02:00
Tarek Ziade 99d4623850 deactivating one test under win32 for now 2011-05-21 23:05:19 +02:00
Tarek Ziade cc243cc808 make sure the crawler can browse file-based indexes under win32 2011-05-21 22:47:40 +02:00