Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ffilib: Initial version of wrapper for ffi module. #27

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
dpgeorge wants to merge 2 commits into micropython:master from dpgeorge:ffilib

Conversation

@dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented Jun 4, 2015

This library allows to search for an module to load with ffi. See issue #25 for background.

There is a bit of code duplication here but I couldn't find a way to reduce it.

I think I'd rather just allow a list of libs to be passed in and searched. It's much simpler.

Copy link
Contributor

pfalcon commented Jun 5, 2015

You didn't run make_metadata.py script on this, did you? Its purpose is to generate setup.py from metatdata.txt.

Copy link
Contributor

pfalcon commented Jun 5, 2015

There is a bit of code duplication here but I couldn't find a way to reduce it.

There's of course a way, possibly taking more heap space. But how it is should be good enough for v1.

Copy link
Contributor

pfalcon commented Jun 5, 2015

I think I'd rather just allow a list of libs to be passed in and searched. It's much simpler.

Patching _libc.py with few lines was much simpler, but you decided to go a longer way ;-). There're various ways to tweak it, but as I said, should be good enough for v1. Possible tweaks: make "extra" a "wellknown", and start with them (that's to address your concern, I'm not sure it wouldn't be changed later again). Start with maxversion and down-count to 1. And well, you didn't even consider that on Windows, libpcre.so would likely be pcre.dll ;-)

Copy link
Contributor

pfalcon commented Jun 5, 2015

So, again, this is good enough to go, once metadata is fixed. Let's make sure we know the next steps. And that would be adding a convenience method to load libc - as I mentioned, this new module is to replace _libc.py. So, suppose we add "libc()" function for that, which saves other modules from repeating params, us patching them in multiple places, and actually, it's quite adhoc matter (guess how libc is called under Windows).

What's next? On normal unix, socket API is part of normal API, but on windows, it's a separate DLL. So, need another convenience function in this module, which will return the same libc on unix, but adhoc lib on Windows. The idea is clear I hope. Thinking about naming convention for such functions beforehand may help then.

Copy link
Member Author

dpgeorge commented Jun 5, 2015

You didn't run make_metadata.py script on this, did you?

No, I just copied over from _libc/*. I guess the script should be called make_setup.py :)

There's of course a way, possibly taking more heap space.

Yeah, I didn't want to make an explicit list of all libs to try. But I just realised there is a way using generators:

def name_list():
 for ext in ('so', 'dylib', 'dll'):
 yield '%s.%s' % (name, ext)
 for i in range(maxver):
 yield '%s.so.%u' % (name, i)
 for n in extra:
 yield n

And of course you can use sys.platform to see if you're on linux and need to check the .so's. Generators are a bit pricey, but I think I like the above better than the way it currently is; what do you think?

Possible tweaks: make "extra" a "wellknown", and start with them

"extra" was supposed to be for corner cases that didn't fit the standard scheme.

Start with maxversion and down-count to 1.

That's probably better.

this new module is to replace _libc.py.

So does in need "bitness"?

Copy link
Member Author

dpgeorge commented Jun 5, 2015

Updated:

  • now using yield pattern to iterate filenames
  • checks for linux platform
  • setup.py generated by make_metadata.py

Copy link
Contributor

pfalcon commented Jun 5, 2015

Generators are a bit pricey, but I think I like the above better than the way it currently is; what do you think?

Yes, I meant a generator. But as I told above, even how it is is good enough for starters.

So does in need "bitness"?

Ah, so there's bitness... You see, _libc.py was already used as a catch-all. Currently, bitness is used only by select.py, but between moving it there and to ffilib, I think the latter is better. (Again, that can go as next action(s), to be done on demand).

Copy link
Member Author

dpgeorge commented Jun 5, 2015

Merged in 6dae7a2.

Copy link
Contributor

pfalcon commented Jun 5, 2015

Pushed to pypi.

@dpgeorge dpgeorge deleted the ffilib branch August 31, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /