Skip to content
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

Add support for packaging binaries in scripts data directory #248

Merged
merged 2 commits into from
Jun 25, 2022

Conversation

messense
Copy link
Member

Closes #247

base_mod, name = mod.rsplit(".")
script = "%s=%s.%s:run" % (name, base_mod, _script_name(executable))
entry_points.append(script)
if "." in mod:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this, I'm thinking about change script=False to this the behavior of this PR.

IMO the current Binding.Exec with script=False build mode doesn't not much make sense since it only build the binary and put in somewhere in the package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to get my head around this comment. I agree that script=False is kind of weird / useless at the moment. Is there genuinely a use case where the current behaviour of placing the binary into site-packages is desirable?

On the other hand, if we change script=False to match this PR - I understand that this would mean that the binary would by default be copied into the bin directory (and added to PATH, essentially). Once we have that, is there ever a reason to want to use script=True?

Copy link
Member Author

@messense messense Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO most users reach to Exec binding and script=True to put the binary in PATH, otherwise it's not very useful.

In maturin we also build bin bindings by putting it in script data directory directly.

Here is the original issue for the current implementation: #22

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we change script=False to work like maturin is there a reason to use script=True ever? Maybe we can simplify and deprecate the argument?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we change script=False to work like maturin is there a reason to use script=True ever?

I don't think there is any.

Maybe we can simplify and deprecate the argument?

I think so.

According to the docs, target accepts Union[str, Dict[str, str]] right now

target (Union[str, Dict[str, str]]) – The full Python dotted name of the extension, including any packages, i.e not a filename or pathname. It is possible to specify multiple binaries, if extension uses Binding.Exec binding mode. In that case first argument has to be dictionary. Keys of the dictionary correspond to the rust binary names and values are the full dotted name to place the executable inside the python package. To install executables with kebab-case names, the final part of the dotted name can be in kebab-case. For example, hello_world.hello-world will install an executable named hello-world.

I'd also like to change it to accept List[str] and deprecate Dict[str, str] for multiple binary names.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what if we went further and made a RustBin class to use like RustExtension? Then no need to accept a List at all I think, users can write the list at the setup() level.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A RustBin class is nice, I'll give it a try.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm thinking that way maybe we can leave the existing behavior and emit warnings for deprecation, and then the RustBin class can have the new behavior which we want to have going forward. Gives users time to tell us they need the old way before we break / remove.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@messense
Copy link
Member Author

Hopefully this will resolve conda-forge/maturin-feedstock#60 (comment)

@davidhewitt
Copy link
Member

@messense, sorry for the slow response from me. See thread above - I think there's definitely room to improve the situation here, let's try and figure it out what we want to get and hopefully we can unblock the maturin conda feedstock swiftly. I'll try to reply quicker on this thread now!

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Looks like needs rebase for CHANGELOG conflict, feel free to merge after 👍

@davidhewitt
Copy link
Member

Hmmm, test_cross seems to be hanging?

@messense
Copy link
Member Author

Hmmm, test_cross seems to be hanging?

cross released 0.2.2 recently, something might be broken, I'm going to pin it to 0.2.1 for now and investigate later.

@messense messense merged commit 3590d1a into PyO3:main Jun 25, 2022
@messense messense deleted the data-scripts branch June 25, 2022 09:26
@messense
Copy link
Member Author

Hmmm, test_cross seems to be hanging?

Opened cross-rs/cross#864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support packaging binaries in .data directory
2 participants