Bug fixes
- Preserve text and notebook display metadata when copying or pickling the string returned by
pipdeptree.render()(#917) by @mayankdhingra02. - Stop
from-indexwith an error when a resolved package depends on a name that is not a project name, asfrom-lockalready does. The resolver accepts a requirement on a name that ends in an underscore, such ashelper_, and an index serving such a pair of packages ended the run in aPanicExceptiontraceback (#935) by @gaborbernat. -o cyclonedx-jsonno longer parses its own output back into memory to add emptydependsOnarrays. With--computed unique-deps-names, a chain of 2,000 packages writes 214 MB of SBOM; rendering it now peaks at 0.9 GB instead of 1.6 GB, with the same output (#939) by @gaborbernat.from-indexno longer reads a URL as a relative path. Before, a requirement such ashttps://example.com/demo-1.0.tar.gzwas joined to the working directory, or to the directory of the requirements file that listed it, so a directory tree spelled like the URL (https:/example.com/demo-1.0.tar.gz/) in a cloned repository resolved as a local project and its build backend ran. The URL now fails withURL requirements are not supported by the index resolver, asname @ URLalready did, on the command line, as a requirements file line and after-e, and the message leaves out a user name and password. A-ror-cline and a--requirementsor--pyprojectvalue given as a URL stop the command too, where they used to name a file spelled like the URL. A path that starts with./still names such a directory (#937) by @gaborbernat.
Security
- Check every package
nameandversionof a lock against the 255-byte limit beforefrom-lockbuilds the first requirement. Each dependency copies the locked version of the package it names, so a lock of about 150 KB whose first package listed thousands of dependencies on a later package with an oversized version used about 1 GB of memory before pipdeptree refused it (#928) by @gaborbernat. - Create the temporary directory for a generated
from-indexproject with owner-only permissions on Unix. This protects requirements, local paths and index URLs from other local accounts while resolution runs and if a terminated process leaves the directory behind (#919) by @kemzeb. - Drop the repeated
Project-URL,Home-pageandDownload-URLvalues of a package in linear time when writingcyclonedx-json. pipdeptree compared each URL with every one it had already collected for the package, so a 1 MBMETADATAwith 55,000Project-URLheaders took 4.4 seconds of CPU, four times as long for each doubling (#931) by @gaborbernat. - Evaluate a
Requires-Distmarker, a lock packagemarkeror the marker of afrom-indexrequirement one comparison at a time instead of parsing it into a decision diagram. The limit of 1024 bytes and 16extracomparisons did not bound that diagram, andfrom-indexrequirements had no limit: a 624-byte marker ofincomparisons took 1.9 GB to parse, a 974-byte marker that parsed at once took 13 minutes to evaluate, and 2000 markers within the limit took 1.9 GB together, because a parsed marker is never freed. pipdeptree now spends time and memory proportional to the length of a marker. TwoRequires-Distentries for the same requirement now merge into one edge only when their markers are written the same way; markers that are spelled differently but mean the same used to merge too.from-indexnow hands a marker to the resolver as written, where it used to rewrite it, so the resolver decides what every comparison means, and an invalid marker on the command line is reported asinvalid marker:followed by the marker (#927) by @gaborbernat. - Key the graph's tables of package and extra names with a randomly seeded hash. They used an unseeded one, so whoever wrote a lock file or
METADATAcould pick names that all fall into one bucket, and every lookup walked them all: a 1 MBMETADATAdeclaring 16,000 such extras made--extras activetake 4.8 seconds instead of 0.13 (#930) by @gaborbernat. - Preserve the renderer's UTF-8 bytes in redirected CLI output. Legacy stdout encodings could previously alter escaped Graphviz DOT labels or split
-o freezeURLs into extra requirements-file options (#918) by @kemzeb. - Query the
--pythoninterpreter, or the one auto-detected from an activated environment, from the root directory on Unix instead of a fresh directory below the temporary directory. Its parent is the shared/tmp, so with a relativePYTHONPATHentry such as.., or a version-manager shim that reads its configuration from parent directories, another local user's files in/tmpran as the user. Relative and emptyPYTHONPATHentries are no longer passed to the query on Unix (#922) by @gaborbernat. - Reject a
Requires-Distentry, or afrom-indexrequirement, with more than 4096 bytes before its marker or with more than 32 whitespace characters in a row after the@of a URL requirement before parsing it. The parser copies the whole requirement once for each extra and, at each whitespace character of a URL, reads to the end of the run, so one 200 KB entry such asdep @ x:followed by blanks and a letter took 37 seconds to parse, and twice the length took four times as long. Installed metadata reports such an entry with theInvalid requirement foundwarning;from-indexstops with an error.--summarylikewise ignores aRequires-Pythonlonger than 4096 bytes, whose 512 KB form took 16 seconds to rank (#927) by @gaborbernat. - Restore command lookup on
PATHfor bare--pythonnames such aspython3. Use an explicit path such as./python3to select an interpreter file in the working directory (#916) by @kemzeb. - Run
dotin an empty temporary directory for-o graphviz-<format>, so that only whatdotwrites to its standard output becomes pipdeptree's output. Before,dotstarted in the user's working directory, wheregraphviz-vrmlmakes it write anode<N>.pngtexture per package and follow symbolic links of those names: a checkout that commits such links had a pipdeptree run inside it overwrite or create files outside the checkout (#926) by @gaborbernat. - Stop
--freezefrom runningsvnin an editable install when a.svndirectory there or above it holds a non-emptywc.db-journalorwc.db-wal, or awc.dbthat is a symbolic link.svnopens that database for writing and SQLite first finishes the transaction such a file describes; a rollback journal can name a file anywhere on disk for SQLite to delete, so an installed distribution that shipped one made the scan delete a file of the user running it. pipdeptree now reports such an install as having no remote (#924) by @gaborbernat. - Stop
--freezefrom taking an editable install's remote and commit from a Mercurial, Subversion or Bazaar checkout that another account created in a directory above the project, such as/tmp/.hg. pipdeptree now uses the nearest.hg,.svnor.bzronly when it belongs to the owner of the editable location or to root, or sits in a folder that only its owner or root can write to; otherwise the project freezes as an editable install with no version control. Windows keeps the previous lookup (#923) by @gaborbernat. - Stop running
poetry env info --executableto find an environment. With no virtual or conda environment active, a plainpipdeptreeand--python autostarted Poetry in the working directory, and Poetry loads the project's.poetry/pluginsand runs its in-project.venvinterpreter before it answers, so a cloned repository that committed either ran its own code as the user. Skipping the interpreter Poetry reported did not prevent that. A plain run now inspects the interpreter running pipdeptree, and--python autofails to detect an environment. To inspect a Poetry environment, activate it or, in a project you trust, pass--python "$(poetry env info --executable)"(#921) by @gaborbernat. --computed unique-deps-count,unique-deps-namesandunique-deps-sizenow find every package's exclusive dependencies in one pass and keep them as ranges of a single ordering of the packages, instead of storing a set for each package. A chain of 12,000 small distributions, under 500 KB of metadata, took 1.4 GB of memory to render as JSON; it now takes 55 MB (#933) by @gaborbernat.--exclude-dependenciesnow runs in time proportional to the number of requirements. A package with many requirements on the same package, such as oneRequires-Distline repeated 400,000 times on an indexfrom-indexresolves from, or many distinct specifiers in installed metadata, could keep it busy for minutes (#929) by @gaborbernat.--summary -o richno longer panics when output is not a terminal and a license, classifier orRequires-Pythonvalue makes the table wider than 65,535 columns; the title is centered without Rust's formatter width, which stops there (#932) by @gaborbernat.-o freezeno longer writes a pin that ends in an archive suffix such as.zip,.whlor.tar.gz. pip reads such a line as the path of a local archive instead of a requirement, so a lock file or an installed distribution with the version1.0.zipmadepip install -rbuild the filedemo===1.0.zipfrom the directory pip ran in, even with--no-index. Freeze now writes-for the.that starts the suffix, which pins the same release when the version is valid (#925) by @gaborbernat.
New Contributors
- @mayankdhingra02 made their first contribution in #917