← index #795PR #672
Duplicate · high · value 1.531
QUERY · ISSUE

os-path causes build conflict with unix_ffi os

openby osresearchopened 2024-02-02updated 2024-02-08

Building fails for the unix port when adding the glob package to the variant manifest with:

require("glob", unix_ffi=True)

glob's manifest requires os-path, without unix_ffi, and that in turns requires os also without unix_ffi:

require("os", unix_ffi=True)
require("os-path")

os-path's manifest requires os:

require("os")
package("os")

This causes a conflict with the os that has already been required with unix_ffi:

build-standard/frozen_content.c:20526:27: error: redefinition of ‘const_qstr_table_data_os___init__’
20526 | static const qstr_short_t const_qstr_table_data_os___init__[158] = {
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build-standard/frozen_content.c:17919:27: note: previous definition of ‘const_qstr_table_data_os___init__’ was here
17919 | static const qstr_short_t const_qstr_table_data_os___init__[158] = {
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
....

If I add unix_ffi=True to lib/micropython-lib/python-stdlib/os-path/manifest.py, then it is able to compile the frozen content.

2 comments
dpgeorge · 2024-02-07

If I add unix_ffi=True to lib/micropython-lib/python-stdlib/os-path/manifest.py, then it is able to compile the frozen content.

I don't think that's the correct solution because it will most likely break targets (eg bare-metal ports) that can't use the unix-ffi code.

One solution would be to make it ignore subsequent packages if one is already require'd by the same name. So in this case the unix_ffi os will take precedence because it's require'd first.

dpgeorge · 2024-02-08

Should be fixed by https://github.com/micropython/micropython/pull/13620

CANDIDATE · PULL REQUEST

unix-ffi: Isolate packages from python-stdlib version of `os`

closedby jefferytoopened 2023-05-30updated 2026-01-26

Currently, installing email.message (or any package that requires it, i.e. email.feedparser, email.parser, http.client) or glob causes the python-stdlib version of os to be installed instead of the unix-ffi version.

This adds unix-ffi versions of os-path and uu so that the unix-ffi version of os is installed in these cases.

5 comments
jimmo · 2023-05-31

Thanks for the PR @jefferyto. Sorry the unix-ffi thing is a bit complicated, but I think this is a very reasonable way to solve this.

jefferyto · 2023-06-01

A more general solution could be to persist the unix_ffi=True flag into nested require() calls, that would allow a top-level unix-ffi package to include non-unix-ffi packages and have the stream of requires flow back into unix-ffi when necessary, but I'm not sure how difficult this would be or if there is any interest in this kind of functionality.

dpgeorge · 2024-02-08

See https://github.com/micropython/micropython/pull/13620 for an alternative solution.

dpgeorge · 2024-02-08

A more general solution could be to persist the unix_ffi=True flag into nested require() calls

That's effectively what the above-linked PR does.

dpgeorge · 2024-05-24

This was solved differently as per the two comments just above. See 23df50d0ea0d64c2a4e00f3014dd4590da0a510b

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied