├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── config.yml ├── .gitignore ├── CHANGES.txt ├── LICENSE.txt ├── README.md ├── __init__.py ├── docs ├── screen1.png ├── screen2.png └── screen3.png ├── pip-date.py ├── pip-describe.py ├── pip-search.py ├── pipbyday.py ├── pyOSinfo.py ├── pyfileinfo.py ├── setup.cfg └── setup.py /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | 9 | --- 10 | For new bugs and issues, please **make sure** to: 11 | - [ ] check and search previous issues for similar or related problems. 12 | - [ ] get info about your system configuration and environment, if relevant. 13 | - [ ] include detailed information on what you did before the *error/issue* occurred. 14 | - [ ] use code mark-down using 3 back-ticks (\`\`\`), to enclose multi-line code/input/output. 15 | - [ ] include a **screenshot** for issues concerning *layouts, formatting* or other UI stuff. 16 | - [ ] If this is a request for an enhancement or other improvement, please state this clearly. 17 | 18 | 19 | **Environment** 20 | Please provide some information about your computer environment: 21 | 22 | - [ ] OS: 23 | `$W = (Get-CimInstance Win32_OperatingSystem); '{0} ({1})' -f $W.Caption, $W.Verson` (On Windows) 24 | `uname -a` (On WSL or *nix based OS) 25 | - [ ] Python version: 26 | `python -VV && python -c "import os; print('\n'.join([os.name, os.sys.platform]));"` 27 | - [ ] pip version: 28 | `pip -V` 29 | - [ ] Terminal/Shell: (*powershell, pwsh, Windows Terminal, WSL* etc.) 30 | 31 | 32 | 33 | 34 | **Description** 35 | 36 | 37 | **Expected behavior** 38 | 39 | 40 | **Actual Behaviour:** 41 | 42 | 43 | 44 | **How to Reproduce** 45 | 46 | 47 | 1. Get package from '...' 48 | 2. Then run '...' 49 | 3. An error occurs. 50 | 51 | **Output** 52 | 53 | ``` 54 | Paste the output of the steps above, including the commands themselves and 55 | pip's output/traceback etc. 56 | ``` 57 | 58 | If the problem is graphical in nature, please add a screenshot. 59 | (A picture is worth...) 60 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled python modules 2 | *.pyc 3 | 4 | # Setuptools distribution folders 5 | /dist/ 6 | /build/ 7 | 8 | # Python egg metadata, regenerated from source files by setuptools. 9 | /*.egg-info 10 | /*.egg 11 | 12 | # git 13 | /.git/ 14 | 15 | # various dev junk 16 | /junk/ 17 | -------------------------------------------------------------------------------- /CHANGES.txt: -------------------------------------------------------------------------------- 1 | v1.0.5, 2022-01-23 -- New Release and bug fixes: 2 | 3 | * Added `*.py` extension to all script files for Windows compatibility 4 | (Fixes #12 and #22) 5 | * Fixed #21, pip-search with no arg issue 6 | * Add sys.implementation to pyOSinfo (fixes #13) 7 | * Bump version v1.0.5 8 | 9 | v1.0.4, 2022-01-22 -- New Release and bug fixes: 10 | 11 | * Fixed PR #11 for venv exception handling 12 | * Fixed pyOSinfo uname issue. 13 | * Fixed ANSI color capability check in is_posix() 14 | (May have broken on older Windows machines or Python versions.) 15 | * Fixed wrong Windows-10 creation and modification times ([cm]Times) 16 | (Need feedback from native *nix users.) 17 | * Added new script pip-search 18 | * Changed Shebangs from 'python3' to 'python' 19 | * Updated README 20 | * Bump version v1.0.4 21 | 22 | v1.0.4, 2022-01-22 -- Sync of old work 23 | 24 | * Synchronisation of previous work (2019-02-15) not pushed to repo. 25 | 26 | New Release and bug fixes: 27 | * Added __main__ function coding style 28 | * Added __author__ etc. 29 | * Added new search tool: pip-search 30 | * Fixed confused [acm]times as used in Windows-10, WSL 31 | * Some code cleanup to improve flake8 code formatting analysis: 32 | * Removed unused imports 33 | * Removed redundant whitespace not affecting readability 34 | * Fixed wrong date in CHANGES.txt 35 | 36 | v1.0.3, 2019-02-08 -- New Release and bug fixes: 37 | 38 | * Fixed path search mechnaism for full Linux support. Fixed #6 39 | * Fixed pyfileinfo crashing on binary files. Fixed #8 40 | * Fixed correct time order for [acm]time 41 | * Better terminal color-code compatibility check. Fixed #3 42 | * Removed ANSI control code garbage for non-ANSI-compatible 43 | terminals often found on Windows (CMD, PowerShell). Fixed #2 44 | * Implemented a 'uname' check for non-uname supported OS's 45 | * Improved IBM-437 OEM_CHARSET support for block characters. Fixed #5 46 | * Improved usage text to pip-describe. Fixes #7 47 | * Improved package location info: [apt,dev,sys,usr] 48 | * Improved pyOSinfo getsitepackages() info 49 | * Improved pipbyday to also show package location 50 | * Clarified table header and made it dynamic for different OS 51 | * Added usage help text to pip-date 52 | 53 | This release fixes all bugs that I could find and track. 54 | But I don't have a Mac so have not been able to test it there. 55 | 56 | Affected files: 57 | 58 | modified: CHANGES.txt 59 | modified: README.md 60 | modified: __init__.py 61 | modified: pip-date 62 | modified: pip-describe 63 | modified: pipbyday 64 | modified: pyOSinfo 65 | modified: pyfileinfo 66 | modified: setup.py 67 | 68 | 69 | v1.0.2, 2018-12-02 -- Package maintenance update with 3 new tools 70 | 71 | * Fix for issue #2 (windows) 72 | * Fixed UI PEP typo 73 | * Added pip-describe (requests) - get full descriptions of not installed packages 74 | * Added pyOSinfo - to get os,platform info 75 | * Added pyfileinfo - to get python-based stat info 76 | * General code and README cleanup 77 | * Updated color-highlight scheme 78 | 79 | 80 | v1.0.1, 2018-11-26 -- Initial release 81 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### pip-date - Date your pip packages! 2 | 3 | [![pypi supported versions][1]][2] 4 | [![PyPI version][3]][4] 5 | [![Maintenance][5]][6] 6 | [![GitHub last commit][7]][8] 7 | [![Average time to resolve an issue][9]][10] 8 | 9 | [1]: https://img.shields.io/pypi/pyversions/pip-date.svg 10 | [2]: https://pypi.python.org/pypi/pip-date 11 | [3]: https://badge.fury.io/py/pip-date.svg 12 | [4]: https://badge.fury.io/py/pip-date 13 | [5]: https://img.shields.io/badge/Maintained%3F-yes-green.svg 14 | [6]: https://GitHub.com/E3V3A/pip-date/graphs/commit-activity 15 | [7]: https://img.shields.io/github/last-commit/E3V3A/pip-date.svg 16 | [8]: https://github.com/E3V3A/pip-date/commits/master "Last commits to Master branch" 17 | [9]: http://isitmaintained.com/badge/resolution/E3V3A/pip-date.svg 18 | [10]: http://isitmaintained.com//project/E3V3A/pip-date "Average time to resolve an issue" 19 | 20 | A simple *Python3* CLI tool to show the installation or modification times of all your pip packages. 21 | 22 | | STATUS: | Version | Date | Maintained? | 23 | |:------- |:------- |:---- |:----------- | 24 | | Working | `1.0.5` | 2022-01-23 | YES | 25 | 26 | --- 27 | 28 | Example Output: 29 | 30 | ![Full](./docs/screen1.png) 31 | 32 | ![Full](./docs/screen2.png) 33 | 34 | 35 | Using `pip-search `: 36 | 37 | ![Full](./docs/screen3.png) 38 | 39 | --- 40 | 41 | **Q:** *What does **`pip-date`** do?* 42 | 43 | The primary use is for finding the *time* when a certain pip package was last modified or installed. 44 | It is basically using one or more of: **atime, ctime** and **mtime** from the file status (*stat*) info. 45 | This is essentially equivalent to using the \*nix *stat* command, but is handled differently on Windows. 46 | (See below for further details.) 47 | 48 | Using this information, it can show you and highlight packages that may have been corrupted or outdated. 49 | I also has some functionality of checking packages for outdated and deprecated installation methods. 50 | 51 | But it can do more. Some features are: 52 | 53 | - Highlight packages with inconsistent file modification times (*mTime*). 54 | - Highlight package **versions** which are not conforming to the [PEP-0440](https://www.python.org/dev/peps/pep-0440/) standard. 55 | - Highlight packages installed with an unusual package distribution *priority* given by: **`[chk, src, bin, egg, dev]`** 56 | - Highlight *`setuptools`* dependency packages for easy review 57 | - Show package installation type: with pip/wheel as **`wheel`**, and source as **`sdist`** (**FIX!**) 58 | - Show package installation location: **`usr`** for `--user` and **`sys`** for *global* installations. 59 | - Show correct file modification time, depending on OS/FS architecture (*mtime* vs *ctime*) 60 | 61 | **Q:** *What does it **not** do?* 62 | 63 | - Does not install packages 64 | - Does not show dependencies 65 | - Does not (yet) show packages in a *`virtualenv`* or *`pipenv`* envrionment (**ToDo**) 66 | - Does not check package consistency 67 | - Does not show the very first time you installed a package, if it has been updated since. 68 | (Althought there are left-over artifacts that may show otherwise, we don't look for these.) 69 | 70 | 71 | **Q:** *Why is this needed?* 72 | 73 | It probably isn't, **BUT**... 74 | 75 | Because python packages often rely on a large number of sub-dependencies, it is very easy to accidentally 76 | overwrite some required dependency of one package with a different version needed by another package. 77 | You will never know about it, until it breaks something. One common scenario causing package corruption 78 | is that you have installed some package XXX using pip, but then get an OS update and install the update 79 | using you OS packagemanagement system, like `apt-get install XXX`, which would probably overwrite the 80 | *globally* installed pip package. This is especially true for beginners of python, who has not yet learned 81 | how to use a virtual environment, and installing evything in either the global system (default) or 82 | user (`--user`) environments. This may also occur when installing packages from sources, or when 83 | you have to run some other non-pip installers like `setup.py`, `make install` or like, 84 | and you don't really know what it is going to do. 85 | 86 | 87 | **Q:** *What else is included?* 88 | 89 | * A script called **`pip-describe`**, that will do what *pip* doesn't, which is to show the 90 | full-text `long_description` for **any** PyPI package (including those not already installed). 91 | 92 | * A script called **`pipbyday`**, that will print a simple table with: 93 | `mTime/aTime` + `package-name` + `package-version`, sorted by time. 94 | 95 | * A script called **`pyfileinfo`**, that will show detailed file and date information 96 | for a given file using python's `os.stat` info. 97 | 98 | * A script called **`pyOSinfo`**, that will print a number of *os, system* 99 | and *platform* variables, as seen by your Python interpreter. 100 | 101 | * **`NEW`** A script called (hold your breath!) **`pip-search`**, that will download and 102 | search all of the PyPi package database for packages matching your search criteria. 103 | However, for colored and sexy package searches, I recommend using [pip_search](https://github.com/victorgarric/pip_search). 104 | Also, for cool powershell wrapper of pip-search, read [this](https://github.com/E3V3A/pip-date/issues/17#issuecomment-1019325517). 105 | 106 | **Q:** *Will I continue to support this tool?* 107 | 108 | Sure, if it is broken, but I will not spend any more time for new features. So if you would like to add 109 | something just send me a PR, or at the very least, a detailed code snippet of what I need to implement. 110 | 111 | --- 112 | 113 | ### Dependencies 114 | 115 | 116 | * [requests](https://github.com/requests/requests) - used by `pip-describe` to get PyPI info 117 | * [lxml](https://github.com/lxml/lxml) - used by `pip-search` to parse html from PyPI 118 | 119 | and what you already have: 120 | * [Python3](https://www.python.org/) 121 | * [pip](https://github.com/pypa/pip/) 122 | 123 | 124 | ### Installation 125 | 126 | There is nothing to install really. Just download the `pip-date.py` file and make sure to place it in your `PATH`. 127 | 128 | **For pip installation:** 129 | 130 | ```bash 131 | pip install pip-date 132 | ``` 133 | 134 | 135 | **For single file installation:** 136 | 137 | ```bash 138 | cd /usr/bin/ 139 | wget https://github.com/E3V3A/pip-date/raw/master/pip-date 140 | chmod 755 pip-date 141 | ``` 142 | 143 | 144 | **For developer installation:** 145 | 146 | ```bash 147 | git clone https://github.com/E3V3A/pip-date.git 148 | cd pip-date 149 | pip install pip-date --user 150 | ``` 151 | 152 | 153 | ### How to Run 154 | 155 | ```bash 156 | pip-date # When it's in your PATH 157 | ./pip-date # When it's not in your PATH 158 | ``` 159 | 160 | --- 161 | 162 | ### References: 163 | 164 | **Time Stamps** 165 | 166 | It's quite amusing to see how different OS's and File System's (FS) are handling file time stamps. 167 | In the Linux world the available time stamps are called [atime](), [ctime]() and [mtime](), where 168 | they are generally available through the *`stat`* command. However, Windows systems doesn't have 169 | this commmand because NTFS is using a different way to keep track of time-stamps, so older python 170 | versions would (and Windows OS) would report the wrong values for these. But have since been fixed. 171 | 172 | 177 | 178 | Then we use: `os.path.getctime(pkg_loc)` to get the file time stamp. 179 | 180 | For all the gory details, see: 181 | [here](https://linuxhandbook.com/file-timestamps/), 182 | [here](https://www.unixtutorial.org/atime-ctime-mtime-in-unix-filesystems/) and 183 | [here](https://en.wikipedia.org/wiki/MAC_times). 184 | 185 | --- 186 | 187 | #### Glossary: 188 | 189 | * **`bdist`** - *"Built Distribution"*: 190 | A Distribution format containing files and metadata that only need 191 | to be moved to the correct location on the target system, to be 192 | installed. *Wheel* is such a format, whereas distutil’s *Source 193 | Distribution* is not, in that it requires a build step before it 194 | can be installed. (A **"Binary Distribution"** is also a *bdist*, but 195 | with additional compiled extensions.) 196 | 197 | * **`sdist`** - *"Source Distribution"*: 198 | A distribution format (usually generated using python setup.py 199 | sdist) that provides metadata and the essential source files needed 200 | for installing by a tool like pip, or for generating a Built 201 | Distribution. 202 | 203 | * **`egg`** - **[deprecated]**: 204 | The older *Built Distribution* format introduced by *setuptools*, 205 | which is being replaced by *wheel*. 206 | 207 | * **`wheel`** - "": 208 | A *Built Distribution* **format** introduced by [**`PEP-0427`**](https://www.python.org/dev/peps/pep-0427/), which is 209 | intended to replace the "egg" format. A wheel (`bdist_wheel`) is a 210 | ZIP-format archive with a specially formatted file name and using 211 | the **`.whl`** extension. Normally, you need one wheel file for each 212 | operating system and architechture. And that list can get long for big 213 | projects, like *numpy*. 214 | 215 | 216 | --- 217 | 218 | #### Recommeded or Similar Tools: 219 | 220 | - **[pip-check](https://github.com/bartTC/pip-check/)** - Check you pip package update status with nice ANSI colored CLI 221 | - **[pip-chill](https://github.com/rbanffy/pip-chill)** - Lists only the dependencies (or not) of installed packages 222 | - **[pip_search](https://github.com/victorgarric/pip_search)** - Victor's amazing pip search replacement 223 | - **[venvlink](https://github.com/np-8/venvlink)** - Using virtual environments outside of the project folder, like a boss! 224 | --- 225 | 226 | #### Bugs and Warnings 227 | 228 | None 229 | 230 | 231 | #### ToDo / Help Needed 232 | 233 | See issues marked [ToDo](https://github.com/E3V3A/pip-date/issues?q=is%3Aopen+is%3Aissue+label%3AToDo). 234 | 235 | #### Contribution 236 | 237 | Feel free to post issues and PR's related to this tool. 238 | Feel free to fork, break, fix and contribute. Enjoy! 239 | 240 | 241 | #### Additional Badges 242 | 243 | [![build status][11]][12] [![codecov][13]][14] 244 | [![codecov](https://codecov.io/gh/E3V3A/pip-date/branch/master/graph/badge.svg?token=wHBDKVmtPk)](https://codecov.io/gh/E3V3A/pip-date) 245 | 246 | --- 247 | 248 | #### License 249 | 250 | [![GitHub license][21]][22] 251 | A license to :sparkling_heart:! 252 | 253 | I use `GPLv3` because sharing code modifications is more beneficial for the world. 254 | 255 | [11]: https://ci.appveyor.com/api/projects/status/github/pip-date/pip-date?branch=master&svg=true 256 | [12]: https://ci.appveyor.com/project/pip-date/pip-date 257 | [13]: https://codecov.io/gh/E3V3A/pip-date/branch/master/graph/badge.svg?token=wHBDKVmtPk 258 | [14]: https://codecov.io/gh/pip-date/pip-date 259 | 260 | [21]: https://img.shields.io/github/license/E3V3A/pip-date.svg 261 | [22]: https://github.com/E3V3A/pip-date/blob/master/LICENSE.txt -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | name = "pip-date" 2 | __version__ = "1.0.5" 3 | -------------------------------------------------------------------------------- /docs/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E3V3A/pip-date/846d71c32fa43bcd69330c7d239a67d955ef7635/docs/screen1.png -------------------------------------------------------------------------------- /docs/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E3V3A/pip-date/846d71c32fa43bcd69330c7d239a67d955ef7635/docs/screen2.png -------------------------------------------------------------------------------- /docs/screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E3V3A/pip-date/846d71c32fa43bcd69330c7d239a67d955ef7635/docs/screen3.png -------------------------------------------------------------------------------- /pip-date.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | #---------------------------------------------------------------------- 4 | # Author: E:V:A 5 | # Date: 2018-02-15 6 | # Change: 2022-01-24 7 | # Version: 1.0.5 8 | # License: GPLv3 9 | # URL: https://github.com/E3V3A/pip-date/ 10 | # Description Show the install date of all pip-installed python3 packages 11 | #---------------------------------------------------------------------- 12 | # ToDo: 13 | # [ ] better RegEx for "pip" 14 | # [/] add flake8 QA ignore comments 15 | # [/] fix rounding of floats in [a/c/m]Time 16 | # [ ] Add CLI options: 17 | # - [ ] '-d' : Enable extra debug info 18 | # - [ ] '-e' : Show "env" column to display 'virtualenv' name 19 | # - [ ] '-f' : Force to use opposite (to detected) ctime method for FS 20 | # - [ ] '-n' : Disable colors 21 | # - [ ] '-h' : THIS help/usage message 22 | # - [ ] '-v' : THIS program version 23 | # - [ ] '-t ' : To highlight packages installed ago 24 | # 25 | # NOTES: 26 | #---------------------------------------------------------------------- 27 | # [a/c/m]time 28 | # ------------------------------------------------------------------ 29 | # On Windows (via Cygwin & Python3): 30 | # The creation time is: aTime .CreationTime === .LastAccessTime in Poweshell, but known as "access" time in Linux) 31 | # The modification time is: mTime == cTime .LastWriteTime in Poweshell 32 | # 33 | # On Linux: 34 | # The creation time is: cTime 35 | # The modification time is: mTime 36 | # The access time is: aTime (normally not used) 37 | # 38 | # ==> For seeing last modification time, use "cTime" on Windows FS's, and "mTime" on *linux FS's 39 | #---------------------------------------------------------------------- 40 | # References: 41 | # [1] https://linuxhandbook.com/file-timestamps/ 42 | # [2] https://www.unixtutorial.org/atime-ctime-mtime-in-unix-filesystems/ 43 | #---------------------------------------------------------------------- 44 | import re, os, sys, platform # noqa: E401 45 | #import subprocess 46 | import site, pkg_resources # noqa: E401 47 | from datetime import datetime 48 | from datetime import timedelta 49 | #from time import strftime 50 | 51 | __author__ = "E:V:A (E3V3A)" 52 | __copyright__ = "GPLv3 2022" 53 | #__credits__ = ["https://github.com/E3V3A/pip-date/"] 54 | __version__ = '1.0.5' 55 | 56 | #---------------------------------------------------------- 57 | # OS Check-1 58 | #---------------------------------------------------------- 59 | # Apparently for: 60 | # python.exe -c "import os,sys; print('TERM=%s' % os.getenv('TERM'));" 61 | # python -c "import os; print('\n'.join([os.name, os.sys.platform]));" 62 | # PowerShell/CMD Windows python: TERM=None 63 | # PowerShell/CMD Cygwin python: TERM=cygwin 64 | # WSL TERM=xterm-256color 65 | #---------------------------------------------------------- 66 | def is_posix(): 67 | noco = ('dumb', 'xtermm', 'xterm-mono') # dumb = No VT, 'others' --> $PSStyle.OutputRendering = PlainText 68 | px_term = os.getenv('TERM') # [cygwin, xterm, xterm-color, xterm-256color] 69 | px_name = os.name # [posix, nt, ...] 70 | px_plat = sys.platform # [linux, cygwin, win32] 71 | 72 | if px_term in noco: 73 | return False 74 | if ((px_term == 'None') or (px_term == '')): # For native Windows "consoles" often return "None", since ="". 75 | if ( (px_name == 'nt') and (px_plat == 'win32') ): 76 | return True 77 | else: 78 | return False 79 | # Assume we have a color term 80 | return True 81 | 82 | #---------------------------------------------------------- 83 | # OS Check-2 84 | #---------------------------------------------------------- 85 | # We need to test how [a/c/m]time works on the OS 86 | def isWinFS(): 87 | if platform.architecture()[1] == "WindowsPE": 88 | print("Using cTime for WindowsPE\n") 89 | return True 90 | else: 91 | print("Using mTime for Linux FS\n") 92 | return False 93 | 94 | #---------------------------------------------------------- 95 | # Text Coloring 96 | #---------------------------------------------------------- 97 | # Usage: print(yellow("This is yellow")) 98 | def color(text, color_code): 99 | #if self.nposix: 100 | if not is_posix(): 101 | return text 102 | # for brighter colors, use "1;" in front of "color_code" 103 | bright = '' # '1;' 104 | return '\x1b[%s%sm%s\x1b[0m' % (bright, color_code, text) 105 | 106 | def red(text): return color(text, 31) # # noqa 107 | def green(text): return color(text, 32) # '1;49;32' # noqa 108 | def bgreen(text): return color(text, '1;49;32') # bright green # noqa 109 | def orange(text): return color(text, '0;49;91') # 31 - looks bad! # noqa 110 | def yellow(text): return color(text, 33) # # noqa 111 | def blue(text): return color(text, '1;49;34') # bright blue # noqa 112 | def purple(text): return color(text, 35) # aka. magenta # noqa 113 | def cyan(text): return color(text, '0;49;96') # 36 # noqa 114 | def white(text): return color(text, '0;49;97') # bright white # noqa 115 | 116 | #---------------------------------------------------------- 117 | # Print Usage 118 | #---------------------------------------------------------- 119 | def usage(): 120 | print(" Usage: %s\n" % os.path.basename(__file__)) 121 | print(" This will return a detailed sorted list of all your installed packages.") 122 | print(" The command doesn't take any arguments, and is part of the pip-date") 123 | print(" package. Other commands includeded in this package are: pipbyday,") 124 | print(" pip-describe, pyfileinfo and pyOSinfo.\n") 125 | print(" Please file any bug reports at:") 126 | print(" https://github.com/E3V3A/pip-date/\n") 127 | print(" Version: %s" % __version__) 128 | print(" License: GPLv3\n") 129 | sys.exit(2) 130 | 131 | #---------------------------------------------------------- 132 | # Print Warning 133 | #---------------------------------------------------------- 134 | def print_warning(): 135 | print('\n') 136 | print('-'*60) 137 | print(' WARNING!') 138 | print(' You are missing out on important color coded information!') 139 | print(' This is because you are probably using a Windows console') 140 | print(' that is not fully supporting ANSI color sequencies.') 141 | print(' For best experience, either run this in Cygwin or WSL,') 142 | print(' or install WinPty, ConEmu or a PowerShell version >6.1.') 143 | print(' If you do have a POSIX compatible color terminal, then') 144 | print(' make sure your TERM environment variable is set.') 145 | #print(' (Usally to \"xterm\".)') 146 | print('-'*60) 147 | 148 | #---------------------------------------------------------- 149 | # Print Color Legend 150 | #---------------------------------------------------------- 151 | # See: 152 | # https://github.com/PowerShell/PowerShell/issues/8409 153 | # https://en.wikipedia.org/wiki/Code_page_437 154 | # https://en.wikipedia.org/wiki/Box-drawing_character 155 | # https://en.wikipedia.org/wiki/Block_Elements 156 | # Let's try: 157 | # 2585, # Look best but is not part of cp437 and thus font dependent & not widely available 158 | # 2580, 25A0, 2588 # IBM-437 159 | #---------------------------------------------------------- 160 | def print_legend(): 161 | #cc = u'\u2585' # Unicode Character for a "5/8th box" # (U+2585) is not part of IBM-437 162 | #cc = u'\u2588' # Unicode Character for a "full box" # (U+2588) is part of IBM-437 163 | #cc = u'\u25A0' # Unicode Character for a "black square" # (U+25A0) is part of IBM-437 164 | cc = u'\u2580' # Unicode Character for a "Upper half block" # (U+2580) is part of IBM-437 165 | print(" {} = ERROR (preventing package processing)".format(red(cc))) 166 | print(" {} = Using a Bad, Deprecated or Non-Standard installation Path".format(purple(cc))) 167 | print(" {} = Possibly Multiple installations (differing file times)".format(yellow(cc))) 168 | print(" {} = Recently Changed / Installed (in last 7 days)".format(cyan(cc))) 169 | print(" {} = Non-PEM-compliant Version string (PEP-0440) | ~/.local install".format(green(cc))) 170 | print(" {} = A 'setuptools' dependency package".format(blue(cc))) 171 | 172 | #---------------------------------------------------------- 173 | # Helper Functions 174 | #---------------------------------------------------------- 175 | def safe_name(name): 176 | # Replace runs of non-alphanumeric characters with a single '-'. 177 | return re.sub('[^A-Za-z0-9]+', '-', name) 178 | 179 | def safe_version(version): 180 | # Convert an arbitrary string to a standard version string 181 | version = version.replace(' ', '.') 182 | return re.sub('[^A-Za-z0-9.]+', '-', version) 183 | 184 | def to_filename(name): 185 | # Replace any '-' characters with '_'. 186 | return name.replace('-', '_') 187 | 188 | def test_loc(loc): 189 | # Test package location to give us some idea of what type of install it came with. 190 | # .local : are usually local user installs in: $HOME/.local/lib/pythonX.Y/site-packages/... 191 | # site-packages : are usually system user installs (sudo) 192 | # dist-packages : are usually system package-manager installs (apt) 193 | # /PATH/ : are usually developer installs using "pip install ." 194 | if '.local' in loc: 195 | ploc = bgreen('usr') # user (unprivileged local install) 196 | elif 'dist-packages' in loc: 197 | ploc = 'apt' # system (apt package-manger installed) 198 | elif 'site-packages' in loc: 199 | ploc = 'sys' # system (user sudo installed) 200 | else: 201 | #ploc = red(loc) # show actual path 202 | ploc = red('dev') # dev (user development install via "pip install .") 203 | return ploc 204 | 205 | def pre2txt(pre): 206 | # Distribution "precedence" constants: (../pkg_resources/__init__.py) 207 | # EGG_DIST, BINARY_DIST, SOURCE_DIST, CHECKOUT_DIST, DEVELOP_DIST : [3,2,1,0,-1] 208 | # { 'egg': 3, 'bin': 2, 'src': 1, 'chk': 0, 'dev': -1 } 209 | # However, this seem poorly implemented since most packages show "-1" or 3. 210 | d = ['chk', 'src', 'bin', 'egg', 'dev'] 211 | return d[pre] 212 | 213 | def is_canonical(version): 214 | # Check PEP-0440 Version string compliance: 215 | # https://www.python.org/dev/peps/pep-0440/ 216 | canrex = r'^([1-9]\d*!)?(0|[1-9]\d*)(\.(0|[1-9]\d*))*((a|b|rc)(0|[1-9]\d*))?(\.post(0|[1-9]\d*))?(\.dev(0|[1-9]\d*))?$' 217 | return re.match(canrex, version) is not None 218 | 219 | def pkgcol(pkgarr): 220 | #---------------------------------------------------------- 221 | # The color require special treatment, because 222 | # of sorting on key position and getting ljust space. 223 | # https://packaging.python.org/key_projects/ 224 | cygset = ['setuptools', 'appdirs', 'packaging', 'pyparsing', 'six'] # Cygwin python3-setuptools dependency packages 225 | #cygset += ['wheel', 'virtualenv', 'pipenv', 'pip'] # ...some additional essentials 226 | #cygset += ['scikit-build', 'distlib'] # ...some additional essentials 227 | # NOTE! 228 | # We can't use "pip" because the we're only checking if the string is present in line, 229 | # Thus anything with "pip" in it would be caught, so we need a smarter RE here. 230 | #---------------------------------------------------------- 231 | line = '' 232 | for i in range(len(pkgarr)): 233 | line = pkgarr[i] 234 | for pname in cygset: 235 | # ToDo: only replace if in 1st word 236 | if pname in line: 237 | #pkgarr[i] = re.sub(r'^[a-zA-Z0-9_\-]+', blue(pname), line, 1) 238 | rx = line.find(pname) 239 | if rx < 20 and rx != '-1': 240 | pkgarr[i] = line.replace(pname, blue(pname), 1) 241 | break 242 | return pkgarr 243 | 244 | #---------------------------------------------------------- 245 | # MAIN 246 | #---------------------------------------------------------- 247 | def main_func(): 248 | 249 | print() 250 | debug = 0 251 | #nposix = 0 252 | pcnt = 0 253 | pkg = [] 254 | 255 | #--------------------------------------- 256 | # CLI arguments 257 | #--------------------------------------- 258 | narg = len(sys.argv) - 1 259 | if narg >= 1: 260 | #pkg = sys.argv[1] 261 | usage() 262 | #if is_posix(): 263 | # nposix = 1 264 | #--------------------------------------- 265 | 266 | # Check [a/c,m]time availability 267 | useWinStat = False # Linux ELF based FS system 268 | if isWinFS(): 269 | useWinStat = True # WindowsPE FS system 270 | 271 | #--------------------------------------- 272 | # MacOS: ?? 273 | # Cygwin: native python, we only have 1 location: 274 | # /usr/lib/python3.6/site-packages 275 | # Linux Mint (19.1): we have several (3) 276 | # /usr/local/lib/python3.6/dist-packages 277 | # /usr/lib/python3/dist-packages 278 | # /usr/lib/python3.6/dist-packages 279 | # Also add the unprivileged user's local package location: 280 | # $HOME/.local/lib/python3.6/site-packages/ 281 | #--------------------------------------- 282 | try: 283 | site_loc = site.getsitepackages() # [...] 284 | if debug: print("site_locs (site): ", site_loc) 285 | site_loc += [site.getusersitepackages()] # add $HOME/.local/lib/python3.6/site-packages/ 286 | if debug: print("site_locs (all): ", site_loc) 287 | except AttributeError: 288 | site_loc = site.USER_SITE 289 | 290 | for d in pkg_resources.working_set: 291 | 292 | try: 293 | pkg_name = d.project_name # 294 | pkg_ver = d.version # 295 | #pkg_loc = d.location # NOT always a file! 296 | pkg_typ = 'n/a' # "wheel" if d.location.is_wheel else "sdist" # 'Type' 297 | 298 | if debug: 299 | pkg_pre = d.precedence # 'Prec' [-1..3] 300 | else: 301 | pkg_pre = pre2txt(d.precedence) if (d.precedence != -1) else '' # 'Prec' string 302 | 303 | pkg_ins = d.get_metadata('INSTALLER').strip() if d.has_metadata('INSTALLER') else '' # get_metadata_lines() '???' 304 | pkg_whl = d.get_metadata('WHEEL').strip() if d.has_metadata('WHEEL') else '' # get_metadata_lines() '???' 305 | # ^^^^^ This often have multiple lines, we need to format: 306 | if pkg_whl: 307 | pw = pkg_whl.split('\n') 308 | pw = '\n ' + '\n '.join(pw,) 309 | pkg_whl = pw 310 | 311 | except ValueError as e: 312 | print(red("ERROR:") + " %s" % e) 313 | 314 | #--------------------------------------- 315 | # Get the correct package location 316 | #--------------------------------------- 317 | # Because d.location doesn't return a file, but only a directory, 318 | # for certain packages, we also check the "module directory" ??? 319 | try: 320 | mod_dir = next(d._get_metadata('top_level.txt')) # module_dir 321 | pkg_loc = os.path.join(d.location, mod_dir) # 322 | os.stat(pkg_loc) # 323 | 324 | except (StopIteration, OSError): 325 | try: 326 | pkg_loc = os.path.join(d.location, d.key) 327 | os.stat(pkg_loc) 328 | except OSError: 329 | pkg_loc = d.location 330 | #--------------------------------------- 331 | 332 | if debug: 333 | print('-'*40) 334 | print("pkg_loc: %s: %s (%s)" % (pkg_name.ljust(20,' '), pkg_loc, pkg_pre)) # pkg_pre always empty ?? 335 | print("pkg_typ: %s" % pkg_ins) 336 | print("pkg_whl: %s" % pkg_whl) 337 | print("pkg_ins: %s" % pkg_ins) 338 | 339 | # A work-around for packages with deprecated location(s): 340 | if ".egg" in pkg_loc: 341 | print(purple("Found Bad Path Location for:") + " %s" % white(pkg_name)) 342 | print("Package Location found at: %s" % (pkg_loc)) 343 | 344 | #--------------------------------------- 345 | # Getting OS Dependent TimeStamps 346 | #--------------------------------------- 347 | # NOTE: 348 | # (1) [acm]time as used in variable names HERE, is true for LinuxFS, 349 | # but swapped for WindowsFS's 350 | # (2) In a WindowsPE based FS: 351 | # (a) The true "creation" time is the (python stat) "atime" 352 | # (b) The true "modification" time is the (python stat) "mtime"=="ctime" 353 | # (3) In a ELF based LinuxFS: 354 | # aTime = access time ... - Rarely used because of FS performance 355 | # mtime = modification time - 356 | # ctime = creation time - is the "real" last modification time on windows 357 | #--------------------------------------- 358 | if debug: print("pkg_loc: %s" % pkg_loc) 359 | 360 | if os.path.exists(pkg_loc): 361 | if useWinStat: 362 | tsc = os.path.getctime(pkg_loc) # WindowsFS: ctime: "creation time" 363 | tsm = os.path.getmtime(pkg_loc) # WindowsFS: mtime: "last modified" 364 | #tsm = os.path.getatime(pkg_loc) # WindowsFS: atime: "last accessed" 365 | else: 366 | tsc = os.path.getctime(pkg_loc) # LinuxFS (ctime) 367 | tsm = os.path.getmtime(pkg_loc) # LinuxFS (mtime) 368 | else: 369 | #print(red("Skipping Bad Path of:") + " %s: \t%s" % (pkg_name, pkg_path)) # to_filename(pkg_name)) 370 | print(red("Skipping Bad Path of:") + " %s: \t%s" % (pkg_name, pkg_loc)) # to_filename(pkg_name)) 371 | continue 372 | 373 | #------------------------------------------------------------------------------------ 374 | # Processing Time Stamps 375 | #------------------------------------------------------------------------------------ 376 | # Logic: 377 | # 1. IF ( mTime > (K * cTime) ) THEN highlight mTime ELSE don't show # (1) 378 | # 2. IF ( cTime < '1-week-ago' ) THEN highlight cTime # (2) 379 | # 380 | #------------------------------------------------------------------------------------ 381 | pkg_ctime = datetime.fromtimestamp(tsc).strftime("%Y-%m-%d %H:%M:%S").strip() # str 382 | pkg_mtime = datetime.fromtimestamp(tsm).strftime("%Y-%m-%d %H:%M:%S").strip() # str 383 | 384 | # NOTE: If TS differs by < 1 second, it will not show. To do so, test: tsc == tsm 385 | max_tdelta = 60 # Max allowed time difference: ~60s 386 | tdelta = abs(tsc - tsm) # Calculate time difference 387 | #if pkg_ctime != pkg_mtime: # This is too restrictive (OS need seconds to install) 388 | if tdelta > max_tdelta: # 389 | pkg_mtime = yellow(pkg_mtime) # (1) Highlight packages with different creation vs modification Times 390 | else: 391 | pkg_mtime = '' # Skip those where: mTime ~= cTime 392 | 393 | ctNow = datetime.now() # Time: "now" 394 | ct7dy = ctNow - timedelta(days=7) # Time: 1-week-ago 395 | pctim = datetime.fromtimestamp(tsc) # Time: file cTime (Time Stamp) 396 | if pctim > ct7dy: 397 | pkg_ctime = cyan(pkg_ctime) # (2) Highlight packages recently created (cTime < 1-week-ago) 398 | #------------------------------------------------------------------------------------ 399 | 400 | if pkg_pre: 401 | pkg_pre = yellow(pkg_pre) + " " # [egg,...] 402 | 403 | if not is_canonical(pkg_ver): 404 | pkg_ver = green(pkg_ver) + " "*3 # green + ugly color-code-length hack when using colors... 405 | 406 | # ugly test here... must be a better way 407 | if 'bdist_wheel' in pkg_whl: 408 | pkg_typ = 'wheel' 409 | else: 410 | #pkg_typ = white('sdist') 411 | pkg_typ = orange('sdist') 412 | 413 | pkg_loc = test_loc(pkg_loc) 414 | 415 | pcnt += 1 416 | pkg += ["{:20} {:<20} {:<20} {:<16} {:6} {:<4} {:5} {:3}".format(pkg_name.ljust(20,' '), pkg_ctime, pkg_mtime, pkg_ver, pkg_ins, pkg_pre, pkg_typ, pkg_loc)] # noqa 417 | 418 | if useWinStat: 419 | # header_str = "{:20} {:20} {:20} {:16} {:6} {:4} {:5} {:3}".format('Package'.ljust(20, ' '), 'LastModified (mTime)', 'FirstSeen (aTime)', 'Version', 'Inst', 'Prec', 'Type ', 'Loc') 420 | header_str = "{:20} {:20} {:20} {:16} {:6} {:4} {:5} {:3}".format('Package'.ljust(20, ' '), 'Installed (cTime)', 'LastModified (mTime)', 'Version', 'Inst', 'Prec', 'Type ', 'Loc') 421 | else: 422 | header_str = "{:20} {:20} {:20} {:16} {:6} {:4} {:5} {:3}".format('Package'.ljust(20, ' '), 'LastModified (mTime)', 'FirstSeen (cTime)', 'Version', 'Inst', 'Prec', 'Type ', 'Loc') 423 | 424 | hlen = len(header_str) 425 | print('\n' + header_str) 426 | 427 | print("-"*hlen) 428 | spkg = sorted(pkg, key=str.lower) 429 | spkg = pkgcol(spkg) 430 | print('\n'.join(spkg)) 431 | 432 | print("-"*hlen) 433 | print_legend() 434 | 435 | print("-"*hlen) 436 | print("Found %d packages." % pcnt) 437 | 438 | #if not nposix: 439 | if not is_posix(): 440 | print_warning() 441 | 442 | print("\nDone!") 443 | 444 | 445 | if __name__ == "__main__": 446 | main_func() 447 | sys.exit(0) 448 | -------------------------------------------------------------------------------- /pip-describe.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | #---------------------------------------------------------------------- 4 | # File Name : pip-describe 5 | # Author : E:V:A 6 | # Last Modified : 2018-02-08 7 | # Version : 1.0.1 8 | # License : GPLv3 9 | # URL : https://github.com/E3V3A/pip-date 10 | # Description: : Show full text package description from PyPI 11 | #---------------------------------------------------------------------- 12 | # NOTE: We don't do the summary as it is already available 13 | # from the `pip search` results. 14 | # [ ] But we can always add CLI switch `-s` for summary 15 | #---------------------------------------------------------------------- 16 | import os, sys 17 | #import requests as req 18 | 19 | try: 20 | import requests as req 21 | # exception ImportError as err: # 3.3 22 | except ModuleNotFoundError as err: # 3.6 23 | print("\nThis program need the \"requests\" package to work.") 24 | print("Please download and install from:\nhttps://github.com/requests/requests") 25 | print(err) 26 | sys.exit(1) 27 | 28 | __version__ = '1.0.1' 29 | 30 | def usage() : 31 | print("\n Usage: %s \n" % os.path.basename(__file__)) # sys.argv[0] 32 | print(" This will return the full-text package description (usually the README)") 33 | print(" as found on PyPI, for any given .\n") 34 | print(" This script is part of the pip-date package at:") 35 | print(" https://github.com/E3V3A/pip-date/\n") 36 | sys.exit(2) 37 | 38 | narg = len(sys.argv) - 1 39 | if narg == 1: 40 | pkg = sys.argv[1] 41 | else: 42 | usage() 43 | 44 | url = 'https://pypi.org/pypi/%s/json' % pkg 45 | res = req.get(url) 46 | if res.status_code == 200: 47 | dat = res.json() 48 | #smm = dat['info']['summary'].strip() # (short) description 49 | des = dat['info']['description'].strip() # long_description (often full README) 50 | print("\nPackage Description:") 51 | print("-"*80) 52 | print("%s" % des) 53 | print("-"*80) 54 | else: 55 | print('\nERROR (%s): Package \"%s\" doesn\'t exist!' % (res.status_code,pkg)) 56 | sys.exit(2) 57 | 58 | sys.exit(0) 59 | -------------------------------------------------------------------------------- /pip-search.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | #---------------------------------------------------------------------- 4 | # File Name : pip-search.py 5 | # Author : E:V:A 6 | # Last Modified : 2022-01-24 7 | # Version : 1.0.3 8 | # License : GPLv3 9 | # URL : https://github.com/E3V3A/pip-date 10 | # Description : Getting a list of pip packages matching a string 11 | # 12 | # References: 13 | # [1] https://docs.python.org/3/howto/regex.html 14 | # [2] https://github.com/victorgarric/pip_search 15 | # [3] 16 | # 17 | #---------------------------------------------------------------------- 18 | # ToDo: 19 | # [ ] Add color 20 | # [ ] Add '-n ' comand line switch to show max (max_shown) matches. 21 | # [ ] Put result list in local file under $USERPROFILE (Win) or $HOME (*nix) 22 | # [ ] In windows search type: "manage app execution aliases" 23 | #---------------------------------------------------------------------- 24 | # 25 | # Getting a list of pip packages 26 | # curl -i -X OPTIONS -H 'Accept: application/json' -H "Content-Type: application/json" https://pypi.org/simple/ >pypilist.html 27 | # cat pypilist.html | grep -io '' | sed 's/\(\)//g' >plink.txt 28 | # sed -e 's/^\/simple\///' |sed -e 's/.$//' 29 | #---------------------------------------------------------------------- 30 | # 31 | # python -c "a='ars*'; print('yes') if('*' in a) else print('no');" 32 | # if ('*' in arg): 33 | # rep = r'{}'.format(arg) 34 | # else: 35 | # rep = r'.*{}.*'.format(arg) 36 | #---------------------------------------------------------------------- 37 | import os, re, sys 38 | import datetime 39 | import requests 40 | from lxml import html 41 | 42 | __author__ = "E:V:A (E3V3A)" 43 | __copyright__ = "GPLv3 2022" 44 | __version__ = '1.0.3' 45 | 46 | debug = 0 47 | showline = ' '+'-'*60 48 | 49 | #TS = '{:%Y%m%d_%H%M%S}'.format(datetime.datetime.now()) 50 | TS = '{:%Y%m%d}'.format(datetime.datetime.now()) 51 | filename = 'tmp_piplist_{}.txt'.format(TS) 52 | 53 | name_list = [] 54 | match_list = [] 55 | my_headers = {'user-agent': 'curl/7.55.1','accept': 'application/json', 'content-type': 'application/json', 'referer': 'https://pypi.org/', 'cache-control': 'no-cache', 'connection': 'close'} 56 | 57 | #---------------------------------------------------------- 58 | # Print Usage 59 | #---------------------------------------------------------- 60 | def usage(): 61 | print('\n Usage: {} | ""\n'.format( os.path.basename(__file__)) ) 62 | print(' Getting a list of pip packages matching a partial name string.') 63 | print(' The string can also be a RegEx for matching unknown packages.') 64 | print(' This script is part of the \'pip-date\' package.') 65 | print(" Please file any bug reports at:") 66 | print(" https://github.com/E3V3A/pip-date/\n") 67 | print(' Version: {}'.format(__version__)) 68 | print(' License: {}\n'.format(__copyright__)) 69 | sys.exit(2) 70 | 71 | #---------------------------------------------------------- 72 | # CLI arguments 73 | #---------------------------------------------------------- 74 | arg = "pyt" 75 | narg = len(sys.argv) - 1 76 | if narg != 1: 77 | usage() 78 | arg = sys.argv[1] # CLI provided search string (args[0]) 79 | 80 | rep = r'.*{}.*'.format(arg) # pattern 81 | rec = re.compile(rep, re.I) # compiled 82 | 83 | #---------------------------------------------------------------------- 84 | # Utilitiy Functions 85 | #---------------------------------------------------------------------- 86 | 87 | def print_warn(): 88 | print('\n Warning!') 89 | print(' Searching all ~350,000 pip packages can take a very long time!') 90 | print(' This script will first download the 19 MB (HTML) file, and only') 91 | print(' then search the list for the content requested.') 92 | print(' This can take up to 20 seconds.\n') 93 | 94 | def save_list(file, data): 95 | print(' Saving package list to file:\n ./{} '.format(file)) 96 | if os.path.exists(file): 97 | print(' WARNING: The file already exists, so skipping.') 98 | else: 99 | f = open(file, 'w') 100 | for i in data: 101 | f.write('{}\n'.format(i)) 102 | f.close() 103 | 104 | def load_list(file): 105 | data = [] 106 | print(' Trying to load package list from file...',end='') 107 | if os.path.exists(file): 108 | f = open(file, 'r') 109 | #with open(file, 'r') as f: 110 | for x in f: 111 | item = x[:-1] 112 | data.append(item) 113 | f.close() 114 | print('ok\n ./{}'.format(file)) 115 | else: 116 | print('FAIL\n Previous package list file is too old or doesn\'t exist!') 117 | #print(' (./{})'.format(file)) 118 | if (debug): print('\nDATA:\n{}\n...\n{}\n\n'.format(data[0:20], data[len(data)-100:])) 119 | return data 120 | 121 | def download_pip_list(): 122 | name_list = [] 123 | #name_list = '' 124 | print('\n Downloading full pip list... ', end='') 125 | with requests.Session() as s: 126 | try: 127 | r = s.get('https://pypi.org/simple/', headers=my_headers) 128 | except: 129 | pass 130 | print('ok') 131 | 132 | tree = html.fromstring(r.content) # Use lxml to get package names 133 | package_list = [package for package in tree.xpath('.//a/@href')] # Grab the part 134 | #print(showline) 135 | print(' Found {:,} packages in current list.\n'.format(len(package_list))) 136 | 137 | if (debug): print(package_list[1:30]) 138 | 139 | p = re.compile(r'/simple/(.*)/') # Only get the pip package name 140 | #name_list = list(filter(p.match, package_list)) # Maybe try using "filter" to match 141 | for i in package_list: 142 | item = p.match(i) 143 | name_list.append(item.group(1)) 144 | 145 | if (debug): 146 | print(' Package name list is now clean, with {:,} items.\n'.format(len(name_list))) 147 | print('\nDATA:\n{}\n...\n{}\n\n'.format(name_list[0:20], name_list[len(name_list)-100:])) 148 | return name_list 149 | 150 | def print_matches(name_list): 151 | # Print matching package items 152 | j=0 153 | for i in name_list: 154 | m = rec.search(i) 155 | if not (m == None): 156 | #print(m[0]) 157 | match_list.append(m[0]) 158 | j += 1 159 | 160 | #print(showline) 161 | print('\n Found {:,} matches in current list.'.format(j)) 162 | if (j >= 60): 163 | print('\n Only showing first 60 matches of list.') # ToDo: .format(max_shown)) 164 | print(' Try to narrow your search or use regex.') 165 | print(showline) 166 | #print(match_list[1:60]) 167 | for x in match_list[1:60]: print(' {}'.format(x)); 168 | else: 169 | print(showline) 170 | #print(match_list) 171 | for x in match_list: print(' {}'.format(x)); 172 | print(showline) 173 | #print('\n') 174 | 175 | #---------------------------------------------------------------------- 176 | # Main 177 | #---------------------------------------------------------------------- 178 | 179 | def main_func(): 180 | print_warn() 181 | 182 | name_list = load_list(filename) 183 | if not (name_list): 184 | name_list = download_pip_list() 185 | save_list(filename, name_list) 186 | 187 | print_matches(name_list) 188 | print('ok\n') 189 | 190 | if __name__ == "__main__": 191 | main_func() 192 | sys.exit(0) 193 | 194 | #---------------------------------------------------------------------- 195 | # EOF 196 | #---------------------------------------------------------------------- 197 | -------------------------------------------------------------------------------- /pipbyday.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # pipbyday - Prints when python packages were installed 4 | #---------------------------------------------------------------------- 5 | # File Name : pipbyday 6 | # Author : E:V:A 7 | # Last Modified : 2018-02-08 8 | # Version : 1.0.1 9 | # License : GPLv3 10 | # URL : https://github.com/E3V3A/pip-date 11 | # Description : Print a sorted list when python packages were installed 12 | # : This is based on mtime or ctime, depending on OS 13 | #---------------------------------------------------------------------- 14 | 15 | from __future__ import print_function 16 | from datetime import datetime 17 | import os, platform 18 | import pkg_resources as p 19 | from time import strftime 20 | 21 | __version__ = '1.0.1' 22 | 23 | if __name__ == "__main__": 24 | packages = [] 25 | 26 | if platform.architecture()[1] == "WindowsPE": 27 | isWinFS = True 28 | print("\nUsing ctime for WindowsPE\n") 29 | else: 30 | isWinFS = False 31 | print("\nUsing mtime for Linux FS\n") 32 | 33 | # The package: "name version" 34 | for package in p.working_set: 35 | pkg_nam_ver = str(package) 36 | 37 | try: 38 | module_dir = next(package._get_metadata('top_level.txt')) 39 | pkg_loc = os.path.join(package.location, module_dir) 40 | os.stat(pkg_loc) 41 | 42 | except (StopIteration, OSError): 43 | try: 44 | pkg_loc = os.path.join(package.location, package.key) 45 | os.stat(pkg_loc) 46 | except: 47 | pkg_loc = package.location 48 | 49 | # aTime = access time ... 50 | # mtime = modification time 51 | # ctime = creation time BUT is the "real" last modification time on windows. 52 | if isWinFS: 53 | mtime = os.path.getctime(pkg_loc) # modification time on Windows 54 | else: 55 | mtime = os.path.getmtime(pkg_loc) # modification time on Linux 56 | 57 | mtime = datetime.fromtimestamp(mtime).strftime("%Y-%m-%d %H:%M:%S") 58 | #packages.append([mtime, pkg_nam_ver]) 59 | packages.append([mtime, pkg_nam_ver, pkg_loc]) 60 | 61 | for mtime, pkg_nam_ver, pkg_loc in sorted(packages): 62 | print("{:22} : {:<30} : {:<40}".format(mtime.ljust(22,' '), pkg_nam_ver, pkg_loc)) 63 | #for mtime, pkg_nam_ver in sorted(packages): 64 | # print("{:22} : {:<30}".format(mtime.ljust(22,' '), pkg_nam_ver)) 65 | 66 | print("\nDone!") 67 | -------------------------------------------------------------------------------- /pyOSinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # pyOSinfo - Show what Python thinks about your system environment 4 | #---------------------------------------------------------------------- 5 | # File Name : pyOSinfo 6 | # Author : E:V:A 7 | # Date : 2018-02-08 8 | # Last Modified : 2022-01-24 9 | # Version : 1.0.5 10 | # License : GPLv3 11 | # URL : https://github.com/E3V3A/pip-date/ 12 | # Description : Show some system, os and platform information as seen by python3 13 | #---------------------------------------------------------------------- 14 | # NOTE: 15 | # On Cygwin, yuo have to pay attention to the parts of the PATH 16 | # that is cpoied fromt he Windows (System PATH). This will interfere 17 | # with the resulsts of 'os.name' [nt vs posix], depeding on which 18 | # python*.exe was used. Try to test with: 19 | # ls -al `which python.exe` 20 | #---------------------------------------------------------------------- 21 | import os, sys, platform, site 22 | from os.path import join 23 | 24 | __version__ = '1.0.5' 25 | 26 | TRUECOLOR = "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m" 27 | 28 | def hasUname(): 29 | try: 30 | os.uname()[0] 31 | return True 32 | except: 33 | return False 34 | 35 | print("\nCurrent OS variables as seen by Python3 (%s)\n" % platform.python_version() ) 36 | print('os.getenv(\"TERM\"): %s' % os.getenv("TERM")) # [xterm, xterm-color, xterm-256color] 37 | print('os.name: %s' % os.name ) # [posix, nt, java] 38 | print('os.sys.platform: %s' % os.sys.platform ) # [linux, win32, cygwin, darwin] 39 | print('sys.platform: %s' % sys.platform ) # [linux, win32, cygwin, darwin] 40 | print('TRUECOLOR (orange): %s' % TRUECOLOR ) # TRUECOLOR written in nice orange 41 | 42 | # Apparently some Windows Pythons doesn't provide os.uname attribute. 43 | # Like: Winpython64-3.6.7.0Zero 44 | print('\nos.uname:') # sysname, nodename, release, version, machine 45 | if hasUname(): 46 | print('\tnodename: %s' % os.uname()[1] ) # 47 | print('\tmachine: %s' % os.uname()[4] ) # 48 | print('\tsysname: %s' % os.uname()[0] ) # 49 | print('\trelease: %s' % os.uname()[2] ) # 50 | print('\tversion: %s' % os.uname()[3] ) # 51 | else: 52 | print('\tN/A' ) 53 | 54 | print('\nplatform:') 55 | print('\tnode : %s' % platform.node() ) 56 | print('\tmachine : %s' % platform.machine() ) 57 | print('\tprocessor : %s' % platform.processor() ) 58 | print('\tsystem : %s' % platform.system() ) 59 | print('\trelease : %s' % platform.release() ) 60 | print('\tversion : %s' % platform.version() ) 61 | print('\tplatform : %s' % platform.platform() ) 62 | print('\tuname (6) : {}'.format(platform.uname()) ) # (system, node, release, version, machine) # not processor 63 | print('\tarchitecture (2): (%s,%s)' % platform.architecture() ) # (bits, linkage) 64 | #print('\twin32_ver (4): (%s,%s,%s,%s)' % platform.win32_ver() ) # (release, version, csd, ptype) 65 | 66 | # python -c "import os, sys; print(sys.implementation);" 67 | # (_multiarch='x86_64-cygwin', cache_tag='cpython-38', hexversion=50856116, name='cpython', version=sys.version_info(major=3, minor=8, micro=0, releaselevel='beta', serial=4)) 68 | # (name='cpython', cache_tag='cpython-310', version=sys.version_info(major=3, minor=10, micro=0, releaselevel='final', serial=0), hexversion=50987248) 69 | print('\nsys:') 70 | #print('\timplementation (7) : {}'.format(sys.implementation()) ) # 71 | print('\timplementation (7) : WIP') # 72 | 73 | print("\nsite:") 74 | print("\tgetusersitepackages: %s" % site.getusersitepackages()) 75 | i=0 76 | for ploc in site.getsitepackages(): # Returns a [] 77 | print("\tgetsitepackages[%i]: %s" % (i, ploc)) # site.getsitepackages()[0]) 78 | i+=1 79 | print() 80 | print("\tPREFIXES (2) : %s" % site.PREFIXES) 81 | print("\tUSER_SITE : %s" % site.USER_SITE) 82 | print("\tUSER_BASE : %s" % site.USER_BASE) 83 | 84 | print('\nsys.path:\n\t%s\n' % ('\n\t'.join(sys.path)) ) 85 | 86 | sys.exit(0) 87 | -------------------------------------------------------------------------------- /pyfileinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # pyfileinfo - Get detailed file info from "stat" of file 4 | #---------------------------------------------------------------------- 5 | # File Name : pyfileinfo 6 | # Author : E:V:A 7 | # Last Modified : 2018-02-08 8 | # Version : 1.1.1 9 | # License : GPLv3 10 | # URL : https://github.com/E3V3A/pip-date 11 | # Description : Show detailed file information for a given file using python's os.stat info 12 | # 13 | # References: 14 | # [1] https://linuxhandbook.com/file-timestamps/ 15 | # [2] https://www.unixtutorial.org/atime-ctime-mtime-in-unix-filesystems/ 16 | #---------------------------------------------------------------------- 17 | import os, sys, stat, platform 18 | import time, getopt 19 | 20 | __version__ = '1.1.1' 21 | 22 | #------------------------------------------------ 23 | # Helper Functions 24 | #------------------------------------------------ 25 | def usage() : 26 | print("\nUsage: %s " % os.path.basename(__file__)) 27 | print("\nOptions:") 28 | print(" -c : For License/Copyright info") 29 | print(" -h, --help : For this help ") 30 | print(" -v, --version : For Version info") 31 | sys.exit() 32 | 33 | def copyright(): 34 | print("\nProgram License: GPLv3\nMaintenance URL: https://github.com/E3V3A/pip-date") 35 | sys.exit() 36 | 37 | def pversion(): 38 | print("\nVersion: %s" % __version__) 39 | sys.exit() 40 | 41 | def print_legend(): 42 | print("\nThe tuple items have the following meanings:") 43 | print(" st_mode: : protection bits") 44 | print(" st_ino : inode number") 45 | print(" st_dev : device") 46 | print(" st_nlink : number of hard links") 47 | print(" st_uid : user ID of owner") 48 | print(" st_gid : group ID of owner") 49 | print(" st_size : file size (bytes)") 50 | print(" st_atime : last access time (seconds since epoch)") 51 | print(" st_mtime : last modification time") 52 | print(" st_ctime : time of: \"creation\" for Linux / \"change\" for Windows") 53 | print() 54 | 55 | #------------------------------------------------ 56 | # CLI arguments 57 | #------------------------------------------------ 58 | narg = len(sys.argv) - 1 59 | 60 | try: 61 | opts, args = getopt.getopt(sys.argv[1:], ":hvc", ["help", "version"]) 62 | except getopt.GetoptError : 63 | usage() 64 | sys.exit(2) 65 | 66 | if not opts: 67 | if not args or narg > 1: 68 | usage(); 69 | sys.exit(); 70 | elif narg == 1: 71 | filename = args[0] 72 | else: 73 | for opt, arg in opts: 74 | if opt in ("-h", "--help"): usage(); 75 | elif opt in ("-v", "--version"): pversion(); 76 | elif opt == "-c": copyright(); 77 | 78 | #------------------------------------------------ 79 | # MAIN 80 | #------------------------------------------------ 81 | if platform.architecture()[1] == "WindowsPE": 82 | isWinFS = True 83 | else: 84 | isWinFS = False 85 | 86 | try: 87 | fhand = open(filename) 88 | except IsADirectoryError as e: 89 | print ("ERROR: %s" % e) 90 | sys.exit(2) 91 | 92 | count = 0 93 | is_binary = False 94 | try: 95 | for lines in fhand: 96 | count = count + 1 97 | fdata = open(filename).read() 98 | t_char = len(fdata) 99 | except UnicodeDecodeError as e: 100 | #print ("\nThis is a binary file.") 101 | is_binary = True 102 | t_char = 0 103 | pass 104 | 105 | try: 106 | file_stats = os.stat(filename) 107 | print ("\nThe os.stat() tuple:\n") 108 | print (file_stats) 109 | print_legend() 110 | 111 | except OSError: 112 | print ("\nNameError : [%s] No such file or directory\n", filename) 113 | sys.exit(2) 114 | 115 | file_info = { 116 | 'fname': filename, 117 | 'fsize': file_stats[stat.ST_SIZE], 118 | 'no_of_lines':count, 119 | 't_char':t_char, 120 | 'f_lm' : time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(file_stats[stat.ST_MTIME])), 121 | 'f_la' : time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(file_stats[stat.ST_ATIME])), 122 | 'f_ct' : time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(file_stats[stat.ST_CTIME])), 123 | } 124 | 125 | print (" File Name : ", file_info['fname']) 126 | print (" File Type : ", end='') 127 | if (stat.S_ISDIR(file_stats[stat.ST_MODE])): 128 | print (" directory") 129 | #sys.exit(2) 130 | elif is_binary: 131 | print (" binary") 132 | else: 133 | print(" normal (text) file") 134 | 135 | print (" File Size : ", file_info['fsize'] , " (bytes)") 136 | print (" Total Lines : ", file_info['no_of_lines']) 137 | print (" Total Chars : ", file_info['t_char']) 138 | print() 139 | 140 | if isWinFS: 141 | # powershell.exe -Command "Get-Item CHANGES.txt | Format-List" 142 | # Poweshell: .CreationTime = .LastAccessTime 143 | # Poweshell: .LastWriteTime 144 | print("Using WindowsPE") 145 | print (" ctime: OS change time : ", file_info['f_ct'], " (PS: n/a)") 146 | print (" mtime: user modified : ", file_info['f_lm'], " (PS: .LastWriteTime)") 147 | print (" atime: creation time : ", file_info['f_la'], " (PS: .CreationTime = .LastAccessTime)") 148 | else: 149 | print("Using a Linux based OS?") 150 | print (" ctime: creation time : ", file_info['f_ct']) 151 | print (" mtime: last modified : ", file_info['f_lm']) 152 | print (" atime: last accessed : ", file_info['f_la']) 153 | 154 | sys.exit(0) 155 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | license_file = LICENSE.txt 4 | 5 | [bdist_wheel] 6 | # 1 : Generate wheels that support both Python 2 and Python3 7 | # 0 : Generate separate wheels for each Python version 8 | universal=0 9 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | from os import path 3 | 4 | #------------------------------------------------------------------------------ 5 | # The current standard for setup info. 6 | # For details, see: 7 | # https://packaging.python.org/guides/distributing-packages-using-setuptools/ 8 | # https://github.com/pypa/sampleproject/blob/master/setup.py 9 | # https://pypi.org/classifiers/ 10 | # https://choosealicense.com/ 11 | #------------------------------------------------------------------------------ 12 | 13 | def readme(): 14 | # Get the long description from the README file 15 | here = path.abspath(path.dirname(__file__)) 16 | with open(path.join(here, 'README.md'), encoding='utf-8') as f: 17 | return f.read() 18 | 19 | setup( 20 | name = 'pip-date', 21 | version = '1.0.5', 22 | author = 'E:V:A', 23 | author_email = 'xdae3v3a@gmail.com', 24 | description = 'Show the installation/modification times of all your pip packages and other tools', 25 | #long_description = 'A light CLI tool-set to show the installation or modification times of all your pip packages.', 26 | #long_description_content_type='text/plain', 27 | long_description = readme(), 28 | long_description_content_type = 'text/markdown', 29 | license='LICENSE.txt', 30 | url = 'https://github.com/E3V3A/pip-date/', 31 | packages = find_packages(), 32 | scripts=['pip-date.py', 'pip-describe.py', 'pip-search.py', 'pipbyday.py', 'pyfileinfo.py', 'pyOSinfo.py'], 33 | keywords = 'pip date package management setuptools wheel egg stat os', 34 | install_requires=[ 35 | 'requests', 'lxml', 36 | ], 37 | python_requires = '>=3', 38 | classifiers=[ 39 | #'Private :: Do Not Upload', 40 | 'Development Status :: 5 - Production/Stable', 41 | 'Intended Audience :: Developers', 42 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 43 | 'Operating System :: OS Independent', 44 | 'Programming Language :: Python :: 3', 45 | 'Programming Language :: Python :: 3.6', 46 | 'Programming Language :: Python :: 3.7', 47 | 'Programming Language :: Python :: 3.8', 48 | 'Programming Language :: Python :: 3.9', 49 | 'Programming Language :: Python :: 3.10', 50 | 'Topic :: Software Development :: Version Control', 51 | 'Topic :: System :: Installation/Setup', 52 | 'Topic :: System :: Software Distribution', 53 | 'Topic :: System :: Systems Administration', 54 | ], 55 | project_urls={ 56 | 'Bug Reports': 'https://github.com/E3V3A/pip-date/issues', 57 | #'Funding' : 'https://donate.pypi.org', 58 | #'Credits' : 'http://saythanks.io/to/example', 59 | #'Source' : 'https://github.com/pypa/sampleproject/', 60 | }, 61 | #zip_safe = False, 62 | ) 63 | --------------------------------------------------------------------------------