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

Support template in a subfolder of a repo #1063

Closed
wants to merge 2 commits into from

Conversation

DSEnvel
Copy link

@DSEnvel DSEnvel commented Apr 9, 2018

Allows to specify a subfolder in the repo in which to search for the template.

Usage

At Bloomberg we find it convenient to keep the templates in one repo (like templates belonging to the same team, or grouped by any other criteria), i.e.:

.
|-- cookiecutter-pipproject
|   |-- README.md
|   |-- cookiecutter.json
|   |-- tasks.py
|   `-- {{cookiecutter.app_name}}
`-- cookiecutter-python-app
    |-- LICENSE
    |-- README.rst
    |-- cookiecutter.json
    |-- requirements.txt
    |-- tests
    `-- {{cookiecutter.project_slug}}

Unfortunately, cookiecutter doesn't allow you to have such a configuration easily.

This patch makes it possible with `cookiecutter' using the following syntax:

cookiecutter --subfolder cookiecutter-python-app <YOU REPO>

where <YOU REPO> is the git repo where the templates are and cookiecutter-python-app is the name of the template inside the repo (as in the example above) to be used for generating the code.

I hope all the guidelines have been followed, but please feel free to point me out to any problem with the PR!

Many thanks

DSEnvel and others added 2 commits April 6, 2018 12:31
Allows to specify a subfolder inside the repo in which to search for the template.
BloombergLP open-source contribution.
@codecov-io
Copy link

codecov-io commented Apr 9, 2018

Codecov Report

Merging #1063 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1063   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          18      18           
  Lines         781     785    +4     
======================================
+ Hits          781     785    +4
Impacted Files Coverage Δ
cookiecutter/main.py 100% <ø> (ø) ⬆️
cookiecutter/cli.py 100% <100%> (ø) ⬆️
cookiecutter/repository.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0730981...eb49642. Read the comment docs.

@DSEnvel DSEnvel changed the title Support template in a subfolder of a repo [BloombergLP] Support template in a subfolder of a repo Apr 9, 2018
@pydanny
Copy link
Member

pydanny commented Apr 14, 2018

First off, thanks for this pull request. However, is there any reason why this can't be placed in a tool that employs the internal Cookiecutter API?

@vivainio
Copy link

FWIW I was just looking for this feature (just to avoid repo profileration). Having it as a flag in the main cookiecutter binary would aid discovery

@heitorlessa
Copy link

That is awesome! I essentially did this the other day using the Cookiecutter API, but this PR would simplify all the boilerplate and the concerns I had with repo proliferation too for those using the CLI.

+1 to that if the owners agree to that as this adds a huge value

@pydanny
Copy link
Member

pydanny commented Apr 22, 2018

None of us maintainers will argue that this doesn't add value. Why we hesitate to include it is because it adds to our bandwidth.

@vivainio
Copy link

In case this is rejected because it adds a feature to a set that we want to keep minimal, is there an alternative cookiecutter cli application that can accept features like this? Or are users expected to whip up custom applications of their own?

@luzfcb
Copy link
Contributor

luzfcb commented Apr 22, 2018

Speaking as a long-time cookiecutter user ( i'm not a maintainer of this project. ).

I believe that any new feature, however useful and cool it may be, is unlikely to be accepted in this momment, because this project, even if it is used by a lot of people, including extra large companies, is not sufficiently funded, so that their maintainers can not devote more time to it than they currently do.

Maintainers can not cope with an even greater burden of to support this library without sufficient funding. #848 (comment).

Current project has almost seven thousand stars in github, but still failed to get even $60 per month of funding.

https://www.patreon.com/hackebrot
https://www.patreon.com/danielroygreenfeld

(Although it is obvious, as incredible as it sounds, software developers, also have the day with 24h like everyone, of which, have to use to get the money to pay the bills. :-) )

If you work in a company (or not), and cookiecutter helps you Create Value ( saving you time with boring and repetitive tasks, necessary to create a new project ), and you have some money and want to support this incredible software, talk about it with the maintainers.

related links:

https://www.fordfoundation.org/library/reports-and-studies/roads-and-bridges-the-unseen-labor-behind-our-digital-infrastructure/

https://github.com/pybee/paying-the-piper

@pydanny
Copy link
Member

pydanny commented Apr 23, 2018

@vivainio Cookiecutter does one thing, and it does it quite well. Cookiecutter supports every supported version of Python in every environment, so increasing it's features is often more complicated than it seems. And as much as we love working on this project, our work on it comes out of our free time. Adding more features means the maintainers have to do even more unpaid volunteer work.

@luzfcb is right to point out this project is not sufficiently funded. It's frustrating knowing how many Fortune 500 companies use this tool and yet all that we make from it is worth what in the USA we call "Enough for Taco Bell twice a month".

That said, I hear your plea and those of the others on this thread. We love this project and want to improve it. We're working to change the funding method. To that end, we are launching paid courses that use Cookiecutter extensively. A substantial amount from these courses will be going to support Cookiecutter and its ecosystem.

So if you want this feature and this project to move forward, please tell people who want to know about Python packaging to go to https://courses.twoscoopspress.com/courses/creating-and-distributing-python-packages

@DSEnvel
Copy link
Author

DSEnvel commented Apr 24, 2018

Thanks everyone for the feedback!

@pydanny I see your point. Is there any technical problem with the feature itself that can prevent it from being added to the tool?

@hackebrot hackebrot added the enhancement This issue/PR relates to a feature request. label Apr 24, 2018
@pydanny
Copy link
Member

pydanny commented Apr 24, 2018

@DmitrySavinBloomberg with the 5 minutes of unpaid volunteer time I can afford to spare, it doesn't appear to have any problems.

@vivainio
Copy link

Assuming cookiecutter won't be growing in features much due to resource starvation, it seems like the best workaround is to write own cli's using cookiecutter api (but cli would deal with discovery etc, and just do the rendering with cookiecutter lib). Are there best practice or documentation examples on how to use the api, or is it just about reading the source? An example of such an utility I was thinking of would be seeking the templates from package.json up the tree, and then render them in current directory.

@DSEnvel DSEnvel changed the title [BloombergLP] Support template in a subfolder of a repo Support template in a subfolder of a repo Apr 25, 2018
@insspb
Copy link
Member

insspb commented Sep 12, 2019

Hi @DSEnvel
Thank you for your contribution!
Unfortunately I discovered this PR a little latter, then #1224 and we already reviewed #1224.
So I think we will merge fresh PR, but will mention this PR and your contribution in credits.
If you still interested and have some time, please review #1224.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate enhancement This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants