-
Notifications
You must be signed in to change notification settings - Fork 109
Enable fpm to create a new package #102
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
Enable fpm to create a new package #102
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and works on my machine 👍
A minor observation: I expected the behaviour to be to initialise a project in the current directory (like git init
), as opposed to the command creating a new directory - but I think that is just something that needs documenting somewhere for users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve but this also needs to be documented in the README or elsewhere. What does it do exactly? Give an example.
A description in the PR body would help reviewers as well.
This ( |
Co-authored-by: Laurence Kedward <[email protected]>
Yeah, I'll add some documentation to the README, and maybe PACKAGING.md |
I believe this should be called init.
Furthermore, it should initialize in the current directory without an argument, or create a new directory with an argument, just like git or Cargo.
Let's keep the UI as similar to others established tools as possible.
…On Fri, Jun 19, 2020, at 8:57 AM, Brad Richardson wrote:
Yeah, I'll add some documentation to the README, and maybe PACKAGING.md
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFAWHVVJAAHKPTZZ565HTRXN4EFANCNFSM4OCLLZMQ>.
|
@certik, see cargo new and cargo init. In short, cargo new (and likewise, fpm new) creates a new directory and initializes the TOML and starter source files. I think this is what this PR implements, but again, without a PR description or some example in the documentation, hard to say. @everythingfunctional can you please describe the behavior with a small example? How is this invoked? What files are created?
At least this is my understanding of it. |
Sorry, I didn't mean to nag. :) I saw your earlier response after writing this. |
No, |
See #96 where I go into all the details. See also #96 (comment). |
Both |
For Indeed, if starting from scratch, they appear very much the same and redundant. However, if there is anything special about the directory layout (multiple binaries, tests etc.) and contents that would be reflected in Cargo.toml, I would expect For fpm it should. For example, if you have a package layout with multiple programs,
It's very nice and useful to use Cargo and Rust for reference, but it's not an end all. We're not targeting Rust users. What we make should make sense to us. |
For me it makes sense to use "fpm init" like "git init". Create a new project from scratch.
I don't think by default it should do something different based on an existing project. However let's have it as an option.
We should optimize for the most common use case. I think that would be to start a new project from scratch.
Also, let's have only one command, init. Having two seems redundant and confusing.
…On Fri, Jun 19, 2020, at 1:19 PM, Milan Curcic wrote:
`cargo new` only creates a new directory and initializes a project in it.
`cargo init` initializes a project in an existing directory, and
optionally does what `cargo new` does.
For `cargo new`, `PATH` is required. For `cargo init`, `PATH` is optional.
Indeed, if starting from scratch, they appear very much the same and redundant.
However, if there is anything special about the directory layout
(multiple binaries, tests etc.) and contents that would be reflected in
Cargo.toml, I would expect `cargo init` to do that. But I don't think
it does, at least in the simple example I tried.
For fpm it should. For example, if you have a package layout with
multiple programs, `fpm init` should be able to output a correct
fpm.toml according to the special layout.
`fpm new` simply bootstraps something from scratch.
It's very nice and useful to use Cargo and Rust for reference, but it's
not an end all. We're not targeting Rust users. What we make should
make sense to us. `fpm new` for a new project very much makes sense,
and `fpm init` makes more sense for initializing an existing project.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFAWBLCKEQ6AJ52AAUTJLRXO24NANCNFSM4OCLLZMQ>.
|
But I agree that we shouldn't have redundant commands like Cargo does. It looks like the choice is whether we want to have one command that does multiple things or two narrowly-scoped commands.
I think @certik prefers option 1. I prefer option 2. as it's easier to understand to me. There may be some other options I missed. @everythingfunctional @LKedward what do you prefer? |
An argument for So I am not opposed to the word "init". But I do prefer smaller utility commands over more general ones that would behave differently depending on current directory. |
Technically, I like having two different commands because they do two different things. Since the most common use case would be to start a new project from scratch, that's why I implemented it first. |
@@ -53,6 +53,19 @@ stack install | |||
|
|||
On Linux, the above command installs `fpm` to `${HOME}/.local/bin`. | |||
|
|||
### Creating a new project | |||
|
|||
Creating a new fpm project is as simple as running the command `fpm new project_name`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new fpm project is as simple as running the command `fpm new project_name`. | |
Creating a new fpm project is as simple as running the command `fpm new <project-name>`. |
This will create a new folder in your current directory with the following contents | ||
and initialized as a git repository. | ||
|
||
* `fpm.toml` with your project's name and some default standard meta-data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `fpm.toml` with your project's name and some default standard meta-data | |
* `fpm.toml` with your project's name and some default standard metadata |
* `fpm.toml` with your project's name and some default standard meta-data | ||
* `README.md` with your project's name | ||
* `.gitgnore` | ||
* `src/project_name.f90` with a simple hello world subroutine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `src/project_name.f90` with a simple hello world subroutine | |
* `src/<project-name>.f90` with a module containing a simple hello world subroutine |
* `app/main.f90` (if `--with-executable` flag used) a program that calls the subroutine | ||
* `test/main.f90` (if `--with-test` flag used) an empty test program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be tackled in a separate PR, but I suggest we use --bin
instead of --with-executable
(and also make it the default). Also, add an empty test program by default, as this will encourage all new projects to have tests.
How often do you expect to initialize fpm for an existing project? I don't ever expect to do that, after I convert my existing projects. So I don't think we should optimize for this rare case.
So I vote to rename new to init and we are in agreement.
…On Fri, Jun 19, 2020, at 4:24 PM, Brad Richardson wrote:
Technically, `giti init` doesn't create a new project from scratch. It
initializes an existing project's git configuration.
I like having two different commands because they do two different
things. `fpm new` for new projects, and `fpm init` for existing
projects.
Since the most common use case would be to start a new project from
scratch, that's why I implemented it first.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFAWFIEEUF4HMPJRLSMM3RXPQTHANCNFSM4OCLLZMQ>.
|
I expect that we'll use It also depends how you're used to doing things. I never ever ran git init to create a new repo from scratch. I always run it after I've written and played with some code and want to make a git repo out of it. Same with fpm. For any more complex layout package, I'd much rather run Even if it's an edge case and something that we'd want down the road, I think it's useful to carefully design and name things early on. |
I always indeed run "git init" on an empty repository to start a new project.
Regarding adding new files, you don't modify fpm.toml when you do that.
…On Fri, Jun 19, 2020, at 5:25 PM, Milan Curcic wrote:
> How often do you expect to initialize fpm for an existing project? I don't ever expect to do that, after I convert my existing projects.
I expect that we'll use `fpm init` quite often in the early days,
perhaps even more often than `fpm new`, as we'll work hard on adapting
existing Fortran packages (ours and those of others) into fpm. In the
long run, I expect `fpm new` would be used more often.
It also depends how you're used to doing things. I never ever ran git
init to create a new repo from scratch. I always run it after I've
written and played with some code and want to make a git repo out of
it. Same with fpm. For any more complex layout package, I'd much rather
run `fpm init` and have fpm write the fpm.toml for me, than me editing
it by hand every time I add a new file.
Even if it's an edge case and something that we'd want down the road, I
think it's useful to carefully design and name things early on.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFAWDWQADEDJQCBLH5LDLRXPXVDANCNFSM4OCLLZMQ>.
|
More generally, let's follow what Rust does, it's a well tested approach. Once we use it and don't like it, then let's discuss to do something else.
…On Fri, Jun 19, 2020, at 5:52 PM, Ondřej Čertík wrote:
I always indeed run "git init" on an empty repository to start a new project.
Regarding adding new files, you don't modify fpm.toml when you do that.
On Fri, Jun 19, 2020, at 5:25 PM, Milan Curcic wrote:
>
>
> > How often do you expect to initialize fpm for an existing project? I don't ever expect to do that, after I convert my existing projects.
>
> I expect that we'll use `fpm init` quite often in the early days,
> perhaps even more often than `fpm new`, as we'll work hard on adapting
> existing Fortran packages (ours and those of others) into fpm. In the
> long run, I expect `fpm new` would be used more often.
>
> It also depends how you're used to doing things. I never ever ran git
> init to create a new repo from scratch. I always run it after I've
> written and played with some code and want to make a git repo out of
> it. Same with fpm. For any more complex layout package, I'd much rather
> run `fpm init` and have fpm write the fpm.toml for me, than me editing
> it by hand every time I add a new file.
>
> Even if it's an edge case and something that we'd want down the road, I
> think it's useful to carefully design and name things early on.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#102 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAAFAWDWQADEDJQCBLH5LDLRXPXVDANCNFSM4OCLLZMQ>.
>
|
I honestly didn't even know that I still think that the command that makes the most sense for creating a new project is
|
Here is the guide for Cargo: https://doc.rust-lang.org/cargo/guide/creating-a-new-project.html it seems they recommend I explained my position above, Milan and Brad explained theirs, and it looks like they prefer to use However, I reserve the right to run a poll later on, and if more people prefer |
Definitely, we don't have a majority agreement right now. |
This is just the bare minimum I would say is necessary for
fpm new
.