8000 tools/upip: Skip empty entries when looking for install path. by andrewleech · Pull Request #7536 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

tools/upip: Skip empty entries when looking for install path. #7536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

andrewleech
Copy link
Contributor

I'm not sure if I'm doing things backwards here, but I've got a local build of the unix port with the sys.path overridden to include relative project folders as such:

#define MICROPY_PY_SYS_PATH_DEFAULT ":./src:./src/lib:./src/lib/unix:~/.micropython/lib:/usr/lib/micropython"

Note the setting/string starts with an empty entry :
I recently started building with a manifest to include frozen modules such as upip, uasyncio etc and found I needed the empty path at the start to ensure that the fronzen modules were used by default.

This empty path however broke upip as it uses the first path entry as the default install target.
This PR addresses this by skipping any empty entries like this.

@codecov-commenter
Copy link
codecov-commenter commented Jul 13, 2021

Codecov Report

Merging #7536 (57bd653) into master (ee49ae8) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7536      +/-   ##
==========================================
+ Coverage   98.27%   98.28%   +0.01%     
==========================================
  Files         154      154              
  Lines       19995    19994       -1     
==========================================
+ Hits        19650    19652       +2     
+ Misses        345      342       -3     
Impacted Files Coverage Δ
py/objtype.c 100.00% <0.00%> (ø)
py/runtime.c 99.39% <0.00%> (+0.15%) ⬆️
py/obj.c 96.82% <0.00%> (+0.39%) ⬆️
py/bc.c 89.69% <0.00%> (+1.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee49ae8...57bd653. Read the comment docs.

@dpgeorge
Copy link
Member

I'm not sure this is a good addition, I think it's just working around the bug described in #2322 (and maybe #3509 is also relevant).

Instead the workaround for the moment could be to inject a value for install_path:

import upip
upip.install_path = "..."

@dpgeorge dpgeorge added the tools Relates to tools/ directory in source, or other tooling label Jul 22, 2021
@andrewleech
Copy link
Contributor Author

Oh, I have no problems importing frozen modules in script/repl when there's the "empty" path somewhere in sys.path but perhaps it would be better to have some other value there instead to specify where frozen modules should exist in the import priority order?

The workaround of overriding the upip install path in code doesn't help from command line, though I guess there's a command line option to set that too. I was hoping to avoid having to hardcode a target path into upip scripts though.

@dpgeorge
Copy link
Member

but perhaps it would be better to have some other value there instead to specify where frozen modules should exist in the import priority order?

Yes, that's definitely needed. See #6419.

@dpgeorge
Copy link
Member

@andrewleech is this still relevant now that we have .frozen 86ce442?

@andrewleech
Copy link
Contributor Author

Nope, the ordering of the default paths on UNIX port does pretty much fix this too - though can have a potentially unexpected result if you run upip from source python file - installed modules will be stored next to the upip script rather than any of the hardcoded import paths

@dpgeorge
Copy link
Member

This problem with upip still needs to be fixed, but in a different way. See #8105. I'll close this in favour of that.

@dpgeorge dpgeorge closed this Dec 21, 2021
RetiredWizard pushed a commit to RetiredWizard/micropython that referenced this pull request Feb 9, 2023
…n-main

Translations update from Hosted Weblate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relates to tools/ directory in source, or other tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0