question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cleanup other directories in .shiv

See original GitHub issue

I’d like to be able to have a shiv option that would instruct the bootstrap code to clean out old directories in .shiv for the current app. Maybe:

shiv --delete-other-builds

With that option, when the first bootstrap of a build finished, the boostrap code would essentially run:

rm -rf ~/.shiv/the_app_name_*

Excluding the folder that contains the files for the currently running app.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
lorencarvalhocommented, Aug 14, 2020

@luislew that’s awesome to hear! say hi to @borgstrom for me 😃

I went ahead and cut a PR with this feature, take it for a spin and let me know what you think 😃

3reactions
lorencarvalhocommented, Aug 8, 2020

Hey @rsyring, sorry that it’s taken me literal months to revisit this issue, but I think the --preamble idea I posed earlier will satisfy this request, take a look at my diff https://github.com/linkedin/shiv/compare/preamble?expand=1

I included an example script that cleans up old execution dirs:

(venv) darwin ~/src/shiv $ cat hello.py 
#!/usr/bin/env python3

import shutil

current = site_packages.parent
cache_path = current.parent
name, build_id = current.name.split('_')

if __name__ == "__main__":
    for path in cache_path.iterdir():
        if path.name.startswith(f"{name}_") and not path.name.endswith(build_id):
            print(f"deleting {path}")
            shutil.rmtree(path)

(venv) darwin ~/src/shiv git:preamble ± $ shiv -c http httpie setuptools --preamble hello.py -o http.pyz -q
(venv) darwin ~/src/shiv git:preamble ± $ ./http.pyz 
deleting /Users/lcarvalh/.shiv/http_22c7a1d09432cd2ee573ef360f7db8da966bd38ed3e6d8fb0a695d2fb562611d
deleting /Users/lcarvalh/.shiv/http_af27dd58fb73b60b31de79476d65ffe1e31a1f7f1efd4003fe4e864dc3512a6c
deleting /Users/lcarvalh/.shiv/http_905979cc227c81ac567e77271ede9f2394edb2182755eefb55aabae12e150c55
deleting /Users/lcarvalh/.shiv/http_edf9df1d0d243def92569ec0ae99705d26f9172fd0cb051ccdc2198acdd6f002
deleting /Users/lcarvalh/.shiv/http_4ae89d7b5745993c647e0df69e4846af2570729aa59a552f877f83a4e9c3781e
deleting /Users/lcarvalh/.shiv/http_27a78fe3ed4e9ef3c8e83d0f58d4f258f6704c66e3a784c451715729565b494c
deleting /Users/lcarvalh/.shiv/http_4925643d60a2c442c663cdd067af44ed3d9c1baaeb891111293fe706170a43b4
deleting /Users/lcarvalh/.shiv/http_41c4395c1f212521f2279831db24eeccbd1597023bd7834066b2398ad80c439c
deleting /Users/lcarvalh/.shiv/http_02eddecbc4ac31a08d0eb280294fa2698d9f6dd1ac7267058fcbef0d9643c0fa
deleting /Users/lcarvalh/.shiv/http_98e8bf10a09c5c9f4382b7e6373c3e1aa68fa2b7c27f128138e957b0057ea1eb
deleting /Users/lcarvalh/.shiv/http_77119414c923305efc4deeb168a88aaa8e6cb7dad28b7e337166a39d191dbf5e
deleting /Users/lcarvalh/.shiv/http_742c182a86c95b5a71b834367454b2abf86336f653069e3dceb5b3fc7cad1951
usage: http [--json] [--form] [--compress] [--pretty {all,colors,format,none}]
            [--style STYLE] [--unsorted] [--sorted]
            [--format-options FORMAT_OPTIONS] [--print WHAT] [--headers]
            [--body] [--verbose] [--all] [--history-print WHAT] [--stream]
            [--output FILE] [--download] [--continue]
            [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH]
            [--auth USER[:PASS]] [--auth-type {basic,digest}] [--ignore-netrc]
            [--offline] [--proxy PROTOCOL:PROXY_URL] [--follow]
            [--max-redirects MAX_REDIRECTS] [--max-headers MAX_HEADERS]
            [--timeout SECONDS] [--check-status] [--path-as-is]
            [--verify VERIFY] [--ssl {ssl2.3,ssl3,tls1,tls1.1,tls1.2}]
            [--ciphers CIPHERS] [--cert CERT] [--cert-key CERT_KEY]
            [--ignore-stdin] [--help] [--version] [--traceback]
            [--default-scheme DEFAULT_SCHEME] [--debug]
            [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]
http: error: the following arguments are required: URL

Theoretically you could even pack another pyz into the pyz (though I haven’t tested this). Let me know what you think, if it works for you I will add some tests and cut a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

shiv — shiv documentation
Shiv is a command line utility for building fully self-contained Python zipapps as outlined in PEP 441 but with all their dependencies included!...
Read more >
Shiv - Let's Build a Version Control System! - Shatterealm
We encode the name to prevent any characters in the file path from screwing anything up, and de-duplicate the staging file because we...
Read more >
Cleanup unused IDE directories - GoLand Guide - JetBrains
The IDE will automatically clean up any cache and log directories that were last updated more than 180 days ago. To trigger this...
Read more >
Why is my other storage so high on my Mac? - Quora
So, it is recommended to clean up the Other storage to make room for new files on ... The “/” directory is not...
Read more >
Delete files in one directory that do not exist in another ...
The other alternative would be to hold all filenames in /home/storage in an array and then simply grep -q "$fn" &>/dev/null <<<${array[@]} using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found