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

idea: integrate cargo-generate to provide a maturin new command #615

Closed
davidhewitt opened this issue Sep 1, 2021 · 5 comments · Fixed by #705
Closed

idea: integrate cargo-generate to provide a maturin new command #615

davidhewitt opened this issue Sep 1, 2021 · 5 comments · Fixed by #705
Labels
enhancement New feature or request

Comments

@davidhewitt
Copy link
Member

I think it'd be really cool if maturin (or PyO3) provided a few template projects which users could use to get started with their projects.

cargo-generate already exists, so it's of course possible to make a few template repos and leave it there.

However, I think that users coming from Python to Rust for the first time would probably prefer to learn fewer tools, so wrapping up cargo-generate inside a maturin new command would be a nice experience for them.

It looks like it shouldn't be too hard to call cargo_generate::generate directly. I think the hard work would be creating and maintaining template repos.

What do you think?

@messense messense added the enhancement New feature or request label Sep 2, 2021
@messense
Copy link
Member

messense commented Sep 2, 2021

I'm a little worried that cargo-generate will pull in all of cargo's dependencies.

https://github.com/cargo-generate/cargo-generate/blob/983a03a8fb81c6f5fec9af09ec76106ea98137b6/Cargo.toml#L14

Edit: opened cargo-generate/cargo-generate#444

@davidhewitt
Copy link
Member Author

👍 it definitely might have negative impacts on maturin's build time, even with the cargo dependency removed.

@messense
Copy link
Member

messense commented Sep 11, 2021

Another way to do this is to just shell out to cargo-generate like how wrangler does.

Things gets complicated if we add cargo-generate as a dependency since it will pull in openssl while maturin is using rustls for easier cross compilation.

@davidhewitt
Copy link
Member Author

Another way to do this is to just shell out to cargo-generate like how wrangler does.

IMO there's two downsides to this, though neither of them game-changers:

  • if cargo-generate ever releases breaking changes, we might have some crashes reported by users who have mismatching versions
  • we need to instruct users to install an extra thing before starting their project if we use maturin new on the PyO3 README. I think it would be really cool if we could tell them just to use maturin to get it all started. Something like:
    $ pip install maturin
    $ maturin new hello_rust
    $ cd hello_rust
    $ maturin develop --release
    

Things gets complicated if we add cargo-generate as a dependency since it will pull in openssl while maturin is using rustls for easier cross compilation.

Hmm good point. Would you be happier if I opened a PR to switch cargo-generate to rustls?

Rather than put a lot of work into this, perhaps I can start by making some cargo-generate templates. Let's see whether we like those first before we put a lot of work into maturin new.

@messense
Copy link
Member

messense commented Sep 12, 2021

Hmm good point. Would you be happier if I opened a PR to switch cargo-generate to rustls?

openssl dependency comes from libgit2 so it's not that easy.

$ cargo tree -i openssl-sys
openssl-sys v0.9.66
├── libgit2-sys v0.12.22+1.1.0
│   └── git2 v0.13.21
│       └── cargo-generate v0.9.0 (/Users/messense/Projects/cargo-generate)
└── libssh2-sys v0.2.21
    └── libgit2-sys v0.12.22+1.1.0 (*)

Rather than put a lot of work into this, perhaps I can start by making some cargo-generate templates. Let's see whether we like those first before we put a lot of work into maturin new.

Sounds good.

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

Successfully merging a pull request may close this issue.

2 participants