├── templates
├── README.md
├── requirements.txt
├── licenses
│ ├── Apache-2.0
│ ├── GPL-3.0
│ ├── MIT
│ ├── BSD 2-Clause
│ ├── BSD 3-Clause
│ ├── EPL-2.0
│ ├── CC0-1.0
│ └── MPL-2.0
├── setup.py
└── __init__.py
├── src
├── main.rs
├── error.rs
├── interact.rs
├── templates
│ ├── mod.rs
│ └── license.rs
├── util.rs
└── lib.rs
├── SECURITY.ja.md
├── Cargo.toml
├── SECURITY.md
├── .github
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ └── release.yml
├── .gitignore
├── LICENSE
├── CODE_OF_CONDUCT.ja.md
├── README.ja.md
├── README.md
└── CODE_OF_CONDUCT.md
/templates/README.md:
--------------------------------------------------------------------------------
1 | # {{ name }}
2 |
3 | {{ desc }}
4 |
--------------------------------------------------------------------------------
/templates/requirements.txt:
--------------------------------------------------------------------------------
1 | # Input here requirement(s).
2 |
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | use pyinit::{Result, PyInitArgs, PyInit};
2 |
3 | fn main() -> Result<()> {
4 | let args: PyInitArgs = clap::Parser::parse();
5 | PyInit::from_interaction_and_args(args)?.run()?;
6 | Ok(())
7 | }
8 |
--------------------------------------------------------------------------------
/SECURITY.ja.md:
--------------------------------------------------------------------------------
1 | [[英語/English](SECURITY.md)]
2 |
3 | # セキュリティポリシー
4 |
5 | 当プロジェクトのセキュリティを重視しています。セキュリティ上の脆弱性を発見した場合は、以下の手順に従って報告してください。
6 |
7 | ## 脆弱性の報告
8 |
9 | 脆弱性を報告するには、`admin@t3tra.net`までメールでご連絡ください。以下の情報を含めていただくと、問題の理解と解決に役立ちます:
10 |
11 | - 脆弱性の説明
12 | - 問題を再現する手順
13 | - 潜在的な影響
14 | - その他関連情報
15 |
16 | できるだけ早く対応いたします。プロジェクトのセキュリティ維持にご協力いただきありがとうございます。
17 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pyinit"
3 | version = "1.0.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | clap = { version = "4.0", features = ["derive"] }
8 | reqwest = { version = "0.11", features = ["blocking"] }
9 | dialoguer = { version = "0.10" }
10 | chrono = { version = "0.4" }
11 | askama = { version = "0.12" }
12 | thiserror = { version = "1" }
13 |
--------------------------------------------------------------------------------
/src/error.rs:
--------------------------------------------------------------------------------
1 | #[derive(Debug, thiserror::Error)]
2 | pub enum Error {
3 | #[error("failed to render template: {0}")]
4 | TemplateRendering(#[from] askama::Error),
5 |
6 | #[error("validation failed: {0}")]
7 | ArgValidation(&'static str),
8 |
9 | #[error("error in IO: {0}")]
10 | IO(#[from] std::io::Error),
11 |
12 | #[error("failed to fetch: {0}")]
13 | Fetch(#[from] reqwest::Error),
14 |
15 | #[error("the library name '{name}' is already taken on PyPI")]
16 | LibraryNameTaken { name: String },
17 | }
18 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | [[Japanese/日本語](SECURITY.ja.md)]
2 |
3 | # Security Policy
4 |
5 | We take the security of our project seriously. If you discover any security vulnerabilities, please follow the procedure below.
6 |
7 | ## Reporting a Vulnerability
8 |
9 | To report a vulnerability, please email us at `admin@t3tra.net`. Include the following information to help us understand and resolve the issue:
10 |
11 | - Description of the vulnerability
12 | - Steps to reproduce the issue
13 | - Potential impact
14 | - Any other relevant information
15 |
16 | We will respond as quickly as possible to address the issue. Thank you for helping us keep our project secure.
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/templates/licenses/Apache-2.0:
--------------------------------------------------------------------------------
1 | Copyright {{ year }} {{ author }}
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | You may obtain a copy of the License at
16 | http://www.apache.org/licenses/LICENSE-2.0
17 |
--------------------------------------------------------------------------------
/templates/setup.py:
--------------------------------------------------------------------------------
1 | import codecs
2 | import os.path
3 |
4 | from setuptools import setup, find_packages
5 |
6 |
7 | def read(rel_path):
8 | here = os.path.abspath(os.path.dirname(__file__))
9 | with codecs.open(os.path.join(here, rel_path), 'r') as fp:
10 | return fp.read()
11 |
12 |
13 | def get_version(rel_path):
14 | for line in read(rel_path).splitlines():
15 | if line.startswith('__version__'):
16 | delim = '"' if '"' in line else "'"
17 | return line.split(delim)[1]
18 | else:
19 | raise RuntimeError("Unable to find version string.")
20 |
21 |
22 | setup(
23 | name='{{ name }}',
24 | version=get_version("{{ name }}/__init__.py"),
25 | description="{{ desc }}",
26 | author='{{ author }}',
27 | packages=find_packages(),
28 | license='{{ license }}'
29 | )
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | debug/
4 | target/
5 |
6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8 | Cargo.lock
9 |
10 | # These are backup files generated by rustfmt
11 | **/*.rs.bk
12 |
13 | # MSVC Windows builds of rustc generate these, which store debugging information
14 | *.pdb
15 |
16 | # RustRover
17 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
18 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
19 | # and can be added to the global gitignore or merged into this file. For a more nuclear
20 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
21 | #.idea/
22 |
--------------------------------------------------------------------------------
/templates/licenses/GPL-3.0:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) {{ year }} {{ author }}
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 |
19 | ---
20 |
21 | {name}
22 | ~~~~~~~~~~~~~~~~~~~
23 |
24 | :copyright: (C) {year} {author}
25 | :license: GPLv3, see the LICENSE file for more details.
26 |
--------------------------------------------------------------------------------
/templates/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | {{ name }}
3 | ~~~~~~~~~~~~~~~~~~~
4 |
5 | {{ desc }}
6 |
7 | :copyright: (c) {{ year }} {{ author }}
8 | :license: {{ license }}, see LICENSE for more details.
9 |
10 | """
11 |
12 |
13 | __title__ = '{{ name }}'
14 | __author__ = '{{ author }}'
15 | __license__ = '{{ license }}'
16 | __copyright__ = 'Copyright {{ year }} {{ author }}'
17 | __version__ = '0.0.1'
18 |
19 | __path__ = __import__('pkgutil').extend_path(__path__, __name__)
20 |
21 | import logging
22 | from typing import NamedTuple, Literal
23 |
24 |
25 | class VersionInfo(NamedTuple):
26 | major: int
27 | minor: int
28 | micro: int
29 | releaselevel: Literal["alpha", "beta", "candidate", "final"]
30 | serial: int
31 |
32 |
33 | version_info: VersionInfo = VersionInfo(major=0, minor=0, micro=1, releaselevel='final', serial=0)
34 |
35 | logging.getLogger(__name__).addHandler(logging.NullHandler())
36 |
37 | del logging, NamedTuple, Literal, VersionInfo
38 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/src/interact.rs:
--------------------------------------------------------------------------------
1 | use std::str::FromStr;
2 |
3 | pub fn text_required(prompt: &str) -> crate::Result
4 | where
5 | Text: Clone + ToString + FromStr,
6 | ::Err: ToString + std::fmt::Debug,
7 | {
8 | let text = dialoguer::Input::new()
9 | .with_prompt(prompt)
10 | .interact_text()?;
11 | Ok(text)
12 | }
13 |
14 | pub fn text_optional(prompt: &str) -> crate::Result>
15 | where
16 | Text: Clone + ToString + FromStr + std::ops::Deref,
17 | ::Err: ToString + std::fmt::Debug,
18 | {
19 | let text: Text = dialoguer::Input::new()
20 | .with_prompt(prompt)
21 | .allow_empty(true)
22 | .interact_text()?;
23 | Ok(if text.is_empty() {None} else {Some(text)})
24 | }
25 |
26 | pub fn select_one<'op, Option: ToString>(prompt: &str, options: &'op [Option]) -> crate::Result<&'op Option> {
27 | let index = dialoguer::Select::new()
28 | .with_prompt(prompt)
29 | .items(options)
30 | .interact()?;
31 | Ok(&options[index])
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024-present t3tra-dev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/templates/licenses/MIT:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) {{ year }} {{ author }}
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/templates/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod license;
2 |
3 | macro_rules! templates {
4 | ($( $path:literal as $Struct:ident $(<$lt:lifetime>)? { $( $field:ident: $Type:ty, )* } )*) => {
5 | $(
6 | #[derive(askama::Template)]
7 | #[template(path = $path, escape = "none")]
8 | pub struct $Struct $(<$lt>)? {
9 | $( pub $field: $Type, )*
10 | }
11 |
12 | impl $(<$lt>)? $Struct $(<$lt>)? {
13 | pub fn generate_in(self, dir: impl AsRef) -> crate::Result<()> {
14 | std::fs::write(dir.as_ref().join($path), askama::Template::render(&self)?)?;
15 | Ok(())
16 | }
17 | }
18 | )*
19 | };
20 | }
21 |
22 | templates! {
23 | "requirements.txt" as RequirementsText {
24 | }
25 | "README.md" as README<'t> {
26 | name: &'t str,
27 | desc: &'t str,
28 | }
29 | "__init__.py" as InitPy<'t> {
30 | name: &'t str,
31 | desc: &'t str,
32 | year: u16,
33 | author: &'t str,
34 | license: &'t str,
35 | }
36 | "setup.py" as SetupPy<'t> {
37 | name: &'t str,
38 | desc: &'t str,
39 | author: &'t str,
40 | license: &'t str,
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/templates/licenses/BSD 2-Clause:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) {{ year }}, {{ author }}
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/templates/licenses/BSD 3-Clause:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) {{ year }}, {{ author }}
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | 3. Neither the name of {{ author }} nor the names of its contributors may be used
16 | to endorse or promote products derived from this software without specific
17 | prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/src/util.rs:
--------------------------------------------------------------------------------
1 | pub fn is_available_name_on_pypi(name: &str) -> crate::Result {
2 | let status: reqwest::StatusCode = reqwest::blocking::get(format!("https://pypi.org/pypi/{name}/json"))?.status();
3 | Ok(status == reqwest::StatusCode::NOT_FOUND)
4 | }
5 |
6 | pub fn current_year() -> u16 {
7 | use chrono::Datelike;
8 |
9 | let now: chrono::DateTime = chrono::Utc::now();
10 | now.year() as u16
11 | }
12 |
13 | #[derive(Clone)]
14 | pub struct AlphaNumeric(String);
15 | const _: () = {
16 | impl AlphaNumeric {
17 | pub fn new(mut input: &str) -> crate::Result {
18 | input = input.trim();
19 |
20 | if input.is_empty() {
21 | return Err(crate::Error::ArgValidation("it can't be empty"));
22 | }
23 |
24 | if input.starts_with('-') || input.ends_with('-') {
25 | return Err(crate::Error::ArgValidation("the first and last characters can't be hyphens"));
26 | }
27 |
28 | if !input.chars().all(|c: char| c.is_alphanumeric() || c == '-') {
29 | return Err(crate::Error::ArgValidation("it can only have alphanumeric characters or hyphens"));
30 | }
31 |
32 | Ok(AlphaNumeric(input.into()))
33 | }
34 | }
35 |
36 | /// to use for field of `derive(Parser)` struct
37 | impl std::str::FromStr for AlphaNumeric {
38 | type Err = crate::Error;
39 | fn from_str(s: &str) -> Result {
40 | AlphaNumeric::new(s)
41 | }
42 | }
43 |
44 | impl std::fmt::Display for AlphaNumeric {
45 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 | f.write_str(&self.0)
47 | }
48 | }
49 |
50 | impl std::ops::Deref for AlphaNumeric {
51 | type Target = str;
52 | fn deref(&self) -> &Self::Target {
53 | &self.0
54 | }
55 | }
56 | };
57 |
--------------------------------------------------------------------------------
/templates/licenses/EPL-2.0:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 2.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
4 |
5 | {{ name }} (the "Program")
6 |
7 | Copyright (c) {{ year }} {{ author }}
8 |
9 | All rights reserved.
10 |
11 | 1. GRANT OF RIGHTS
12 | Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Program and such derivative works in source code and object code form.
13 |
14 | 2. CONTRIBUTIONS
15 | Contributions are licensed to the Recipient under the terms of the Agreement. Contributor grants to the Recipient a non-exclusive, worldwide, royalty-free license to distribute the contributions.
16 |
17 | 3. REQUIREMENTS
18 | A. If You distribute the Program in any form, You must provide a copy of this Agreement or indicate where the license can be found.
19 | B. You may distribute the Program in object code form under Your own license terms, provided that you include this Agreement.
20 | C. You must retain all copyright, patent, trademark, and attribution notices present in the Program.
21 |
22 | 4. DISCLAIMER OF WARRANTY
23 | THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. EACH RECIPIENT IS SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING AND DISTRIBUTING THE PROGRAM AND ASSUMES ALL RISKS ASSOCIATED WITH ITS EXERCISE OF RIGHTS UNDER THIS AGREEMENT.
24 |
25 | 5. LIMITATION OF LIABILITY
26 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
27 |
28 | 6. GENERAL
29 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties to this Agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
30 |
31 | This Agreement is governed by the laws of the jurisdiction where the Program is created and distributed.
32 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.ja.md:
--------------------------------------------------------------------------------
1 | [[英語/English](CODE_OF_CONDUCT.md)]
2 |
3 | # コントリビューター行動規範
4 |
5 | ## 私たちの誓い
6 |
7 | 私たちは、メンバー、コントリビューター、リーダーとして、年齢、体型、目に見えるまたは目に見えない障害、民族、性的特徴、性自認や表現、経験レベル、学歴、社会経済的地位、国籍、個人の外見、人種、カースト、肌の色、宗教、性的指向やアイデンティティに関係なく、すべての人がハラスメントのない形でコミュニティに参加できるように努めることを誓います。
8 |
9 | 私たちは、オープンで歓迎的、多様で包摂的、そして健全なコミュニティに貢献するために行動し、交流することを誓います。
10 |
11 | ## 私たちの基準
12 |
13 | コミュニティにおいて、ポジティブな環境を作る行動の例には次のものがあります:
14 |
15 | - 他の人々に対して共感と優しさを示すこと
16 | - 異なる意見、視点、経験を尊重すること
17 | - 建設的なフィードバックを与え、受け入れること
18 | - 自分の過ちに責任を持ち、影響を受けた人に謝罪し、その経験から学ぶこと
19 | - 個人としての利益ではなく、コミュニティ全体にとって最善の結果を追求すること
20 |
21 | 容認できない行動の例には次のものがあります:
22 |
23 | - 性的な言葉や画像の使用、あらゆる種類の性的な注意や誘い
24 | - 荒らし、侮辱的または軽蔑的なコメント、個人的または政治的な攻撃
25 | - 公的または私的なハラスメント
26 | - 明示的な許可なしに他人の住所やメールアドレスなどの個人情報を公開すること
27 | - プロフェッショナルな場において不適切とみなされるその他の行為
28 |
29 | ## 執行責任
30 |
31 | コミュニティリーダーは、容認される行動基準を明確にし、これを実施する責任を負い、不適切、脅威的、攻撃的、または有害と判断された行動に対して適切かつ公正な措置を講じます。
32 |
33 | コミュニティリーダーは、コメント、コミット、コード、Wikiの編集、問題、およびその他の貢献がこの行動規範に沿わない場合、それらを削除、編集、または拒否する権利と責任を持ち、適切な場合にはその理由を説明します。
34 |
35 | ## 範囲
36 |
37 | この行動規範は、すべてのコミュニティスペース内で適用され、また、個人が公的な場で公式にコミュニティを代表する場合にも適用されます。コミュニティを代表する例には、公式のメールアドレスの使用、公式のソーシャルメディアアカウントを介しての投稿、オンラインやオフラインイベントでの代表としての行動が含まれます。
38 |
39 | ## 執行
40 |
41 | 虐待的、ハラスメント的、またはその他容認できない行動の事例は、メールにてコミュニティリーダーに報告されることができます。すべての苦情は迅速かつ公正に審査および調査されます。
42 |
43 | すべてのコミュニティリーダーは、事件の報告者のプライバシーと安全を尊重する義務を負っています。
44 |
45 | ## 執行ガイドライン
46 |
47 | コミュニティリーダーは、違反行為に対する結果を決定する際に、以下のコミュニティへの影響ガイドラインに従います。
48 |
49 | ### 1. 訂正
50 |
51 | **コミュニティへの影響**: 不適切な言葉の使用や、プロフェッショナルでないまたは歓迎されないとみなされる行動。
52 |
53 | **結果**: コミュニティリーダーからの非公開の書面による警告。違反の性質に関する明確な説明と、なぜその行動が不適切だったのかの説明。場合によっては公的な謝罪が求められることがあります。
54 |
55 | ### 2. 警告
56 |
57 | **コミュニティへの影響**: 単一の事件または一連の行動による違反。
58 |
59 | **結果**: 継続的な行動に対する警告。特定の期間、関係者や行動規範を実施する者との望まれないやり取りを含む一切の交流を禁止。この期間中、コミュニティスペース内および外部チャネル(ソーシャルメディアなど)での交流を避ける必要があります。これらの条件に違反した場合、一時的または永久的な禁止が課される可能性があります。
60 |
61 | ### 3. 一時的な禁止
62 |
63 | **コミュニティへの影響**: コミュニティ基準に対する重大な違反、または持続的な不適切行動。
64 |
65 | **結果**: 特定の期間、コミュニティとのあらゆる形の交流や公的なコミュニケーションを一時的に禁止。この期間中、関係者や行動規範の執行者との公的または私的な交流は許可されません。これらの条件に違反した場合、永久的な禁止が課される可能性があります。
66 |
67 | ### 4. 永久的な禁止
68 |
69 | **コミュニティへの影響**: コミュニティ基準に対する持続的な違反行動、個人へのハラスメント、または特定の個人や集団に対する攻撃や中傷。
70 |
71 | **結果**: コミュニティとのあらゆる形の公的な交流に対する永久的な禁止。
72 |
73 | ## 帰属
74 |
75 | この行動規範は、[Contributor Covenant][homepage]のバージョン2.1から適応されたものであり、[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]で入手できます。
76 |
77 | コミュニティへの影響ガイドラインは、[Mozillaの行動規範の執行手順][Mozilla CoC]に触発されたものです。
78 |
79 | この行動規範に関する一般的な質問については、[https://www.contributor-covenant.org/faq][FAQ]をご覧ください。翻訳は[https://www.contributor-covenant.org/translations][translations]にてご利用いただけます。
80 |
81 | [homepage]: https://www.contributor-covenant.org
82 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
83 | [Mozilla CoC]: https://github.com/mozilla/diversity
84 | [FAQ]: https://www.contributor-covenant.org/faq
85 | [translations]: https://www.contributor-covenant.org/translations
86 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Build and Release pyinit CLI
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*.*.*'
7 |
8 | permissions:
9 | contents: write
10 |
11 | jobs:
12 | build:
13 | runs-on: ${{ matrix.os }}
14 | strategy:
15 | matrix:
16 | os: [ubuntu-latest, macos-latest, windows-latest]
17 | include:
18 | - os: ubuntu-latest
19 | target: x86_64-unknown-linux-gnu
20 | file_extension: ""
21 | - os: macos-latest
22 | target: x86_64-apple-darwin
23 | file_extension: ""
24 | - os: windows-latest
25 | target: x86_64-pc-windows-msvc
26 | file_extension: ".exe"
27 |
28 | steps:
29 | - name: Checkout repository
30 | uses: actions/checkout@v4
31 |
32 | - name: Install Rust toolchain
33 | uses: actions-rs/toolchain@v1
34 | with:
35 | toolchain: stable
36 | target: ${{ matrix.target }}
37 | override: true
38 |
39 | - name: Build the CLI
40 | run: cargo build --release --target ${{ matrix.target }}
41 |
42 | - name: Set executable permissions (Linux/macOS)
43 | if: ${{ matrix.os != 'windows-latest' }}
44 | run: chmod +x target/${{ matrix.target }}/release/pyinit
45 |
46 | - name: Upload build artifacts
47 | uses: actions/upload-artifact@v3
48 | with:
49 | name: build-${{ matrix.os }}
50 | path: target/${{ matrix.target }}/release/pyinit${{ matrix.file_extension }}
51 |
52 | archive:
53 | needs: build
54 | runs-on: ${{ matrix.os }}
55 | strategy:
56 | matrix:
57 | os: [ubuntu-latest, macos-latest, windows-latest]
58 | include:
59 | - os: ubuntu-latest
60 | file_extension: ""
61 | - os: macos-latest
62 | file_extension: ""
63 | - os: windows-latest
64 | file_extension: ".exe"
65 |
66 | steps:
67 | - name: Download build artifacts
68 | uses: actions/download-artifact@v3
69 | with:
70 | name: build-${{ matrix.os }}
71 |
72 | - name: Archive the build output (Linux/macOS)
73 | if: ${{ matrix.os != 'windows-latest' }}
74 | run: |
75 | mkdir -p dist
76 | zip -j dist/pyinit-${{ matrix.os }}-${{ github.ref_name }}.zip pyinit
77 |
78 | - name: Archive the build output (Windows)
79 | if: ${{ matrix.os == 'windows-latest' }}
80 | shell: pwsh
81 | run: |
82 | New-Item -ItemType Directory -Force -Path dist
83 | Compress-Archive -Path "pyinit${{ matrix.file_extension }}" -DestinationPath "dist/pyinit-${{ matrix.os }}-${{ github.ref_name }}.zip"
84 |
85 | - name: Upload archive artifacts
86 | uses: actions/upload-artifact@v3
87 | with:
88 | name: archive-${{ matrix.os }}
89 | path: dist/*.zip
90 |
91 | release:
92 | needs: archive
93 | runs-on: ubuntu-latest
94 |
95 | steps:
96 | - name: Download archive artifacts (Linux)
97 | uses: actions/download-artifact@v3
98 | with:
99 | name: archive-ubuntu-latest
100 |
101 | - name: Download archive artifacts (macOS)
102 | uses: actions/download-artifact@v3
103 | with:
104 | name: archive-macos-latest
105 |
106 | - name: Download archive artifacts (Windows)
107 | uses: actions/download-artifact@v3
108 | with:
109 | name: archive-windows-latest
110 |
111 | - name: Move artifacts to dist folder
112 | run: |
113 | mkdir -p dist
114 | mv pyinit*.zip dist/
115 |
116 | - name: Upload build artifacts as release assets
117 | uses: softprops/action-gh-release@v2
118 | with:
119 | files: dist/*.zip
120 | env:
121 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122 |
--------------------------------------------------------------------------------
/src/lib.rs:
--------------------------------------------------------------------------------
1 | mod util;
2 | mod error;
3 | mod interact;
4 | mod templates;
5 |
6 | use error::Error;
7 | use util::AlphaNumeric;
8 | use templates::license::{License, BuiltinLicense, PackageInfo};
9 | use templates::{InitPy, RequirementsText, SetupPy, README};
10 | use ::std::{path::PathBuf, fs};
11 |
12 | pub type Result = std::result::Result;
13 |
14 | #[derive(clap::Parser)]
15 | #[command(version, about = "CLI tool to create Python library scaffolding")]
16 | pub struct PyInitArgs {
17 | /// Library name
18 | #[arg(short = 'n')]
19 | name: Option,
20 |
21 | /// Library description
22 | #[arg(short = 'd')]
23 | description: Option,
24 |
25 | /// Library author's name
26 | #[arg(short = 'a')]
27 | author: Option,
28 |
29 | /// License type
30 | #[arg(short = 'l')]
31 | license: Option,
32 | }
33 |
34 | pub struct PyInit {
35 | name: AlphaNumeric,
36 | description: Option,
37 | author: AlphaNumeric,
38 | license: Option,
39 | }
40 |
41 | impl PyInit {
42 | pub fn from_interaction_and_args(args: PyInitArgs) -> Result {
43 | let name: AlphaNumeric = match args.name {
44 | Some(name) => name,
45 | None => interact::text_required("Enter the library name")?
46 | };
47 |
48 | if !util::is_available_name_on_pypi(&name)? {
49 | return Err(Error::LibraryNameTaken { name: name.to_string() })
50 | }
51 |
52 | let description: Option = match args.description {
53 | Some(description) => Some(description),
54 | None => interact::text_optional("Enter a description for the library (optional)")?
55 | };
56 |
57 | let author: AlphaNumeric = match args.author {
58 | Some(author) => author,
59 | None => interact::text_required("Enter the author's name")?
60 | };
61 |
62 | let license: Option = match args.license {
63 | Some(a_builtin_license) => Some(a_builtin_license.into()),
64 | None => {
65 | let options: Vec<&str> = [License::BUILTIN_NAMES, &["Other (custom)"]].concat();
66 | match License::builtin(interact::select_one("Choose a license", &options)?) {
67 | Some(a_builtin_license) => Some(a_builtin_license),
68 | None => interact::text_optional("Enter your custom license (optional)")?.map(License::custom)
69 | }
70 | }
71 | };
72 |
73 | Ok(Self { name, description, author, license })
74 | }
75 |
76 | pub fn run(self) -> Result<()> {
77 | let project_dir: PathBuf = PathBuf::from_iter([".", &self.name]);
78 | fs::create_dir_all(&project_dir)?;
79 |
80 | let module_dir: PathBuf = project_dir.join(&*self.name);
81 | fs::create_dir(&module_dir)?;
82 |
83 | InitPy {
84 | name: &self.name,
85 | desc: self.description.as_deref().unwrap_or(""),
86 | year: util::current_year(),
87 | author: &self.author,
88 | license: self.license.as_ref().map(License::name).unwrap_or("")
89 | }.generate_in(&module_dir)?;
90 |
91 | SetupPy {
92 | name: &self.name,
93 | desc: self.description.as_deref().unwrap_or(""),
94 | author: &self.author,
95 | license: self.license.as_ref().map(License::name).unwrap_or("")
96 | }.generate_in(&project_dir)?;
97 |
98 | README {
99 | name: &self.name,
100 | desc: self.description.as_deref().unwrap_or("")
101 | }.generate_in(&project_dir)?;
102 |
103 | RequirementsText {
104 | }.generate_in(&project_dir)?;
105 |
106 | if let Some(license) = self.license {
107 | fs::write(project_dir.join("LICENSE"), license.render_with(PackageInfo {
108 | name: self.name.to_string(),
109 | author: self.author.to_string()
110 | })?)?;
111 | }
112 |
113 | println!("Project files created successfully!");
114 |
115 | Ok(())
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/README.ja.md:
--------------------------------------------------------------------------------
1 | [[英語/English](README.md)]
2 |
3 | # pyinit
4 |
5 | `pyinit`は、Pythonライブラリプロジェクトを迅速にセットアップするためのコマンドラインツールです。`README.md`、`LICENSE`、`setup.py`など、ライブラリ開発に必要なファイルを自動で生成し、開発者がプロジェクト構築にかかる手間を省きます。
6 |
7 | ## 特徴
8 |
9 | - Pythonライブラリプロジェクトのディレクトリ構造を自動生成
10 | - `README.md`、`LICENSE`、`__init__.py`、`setup.py`、`requirements.txt`などの重要ファイルを作成
11 | - 柔軟なカスタムテンプレートのサポート
12 | - Linux、macOS、Windowsをサポートするクロスプラットフォーム対応
13 | - インタラクティブなプロンプトとコマンドライン引数での高速セットアップを提供
14 |
15 | ## インストール方法
16 |
17 | ### Linux
18 |
19 | `pyinit`をLinuxにインストールするには、[リリースページ](https://github.com/t3tra-dev/pyinit/releases)から最新バイナリをダウンロードし、バイナリを`PATH`にあるディレクトリに移動します。
20 |
21 | ```bash
22 | wget https://github.com/t3tra-dev/pyinit/releases/download/v1.0.0/pyinit-linux-latest-v1.0.0.zip
23 | unzip pyinit-linux-latest-v1.0.0.zip
24 | chmod +x pyinit
25 | sudo mv pyinit /usr/local/bin/
26 | ```
27 |
28 | `pyinit`を実行して使い始めます:
29 |
30 | ```bash
31 | pyinit --help
32 | ```
33 |
34 | ### macOS
35 |
36 | macOS向けに`pyinit`をインストールするには、[リリースページ](https://github.com/t3tra-dev/pyinit/releases)から最新バイナリをダウンロードし、バイナリを`PATH`にあるディレクトリに移動します。
37 |
38 | ```bash
39 | curl -L -O https://github.com/t3tra-dev/pyinit/releases/download/v1.0.0/pyinit-macos-latest-v1.0.0.zip
40 | unzip pyinit-macos-latest-v1.0.0.zip
41 | chmod +x pyinit
42 | sudo mv pyinit /usr/local/bin/
43 | ```
44 |
45 | `pyinit`を実行して使い始めます:
46 |
47 | ```bash
48 | pyinit --help
49 | ```
50 |
51 | ### Windows
52 |
53 | Windowsで`pyinit`を使用するには、[リリースページ](https://github.com/t3tra-dev/pyinit/releases)から最新バイナリをダウンロードして解凍します。
54 |
55 | ```bash
56 | Invoke-WebRequest -Uri https://github.com/t3tra-dev/pyinit/releases/download/v1.0.0/pyinit-windows-latest-v1.0.0.zip -OutFile pyinit.zip
57 | Expand-Archive -Path pyinit.zip -DestinationPath .
58 | ```
59 |
60 | 以下の手順で`pyinit`を`PATH`に追加します:
61 |
62 | 1. 「このPC」を右クリックし、「プロパティ」を選択
63 | 2. 「システムの詳細設定」をクリックし、「環境変数」を選択
64 | 3. 「システム環境変数」の中から`Path`を探し、選択後「編集」をクリック
65 | 4. 「新規」をクリックし、`pyinit.exe`があるパスを追加
66 | 5. すべてのウィンドウで「OK」をクリックして閉じる
67 |
68 | これでコマンドラインから`pyinit`が実行できるようになります:
69 |
70 | ```bash
71 | pyinit --help
72 | ```
73 |
74 | ## ローカルでのビルド方法
75 |
76 | `pyinit`をソースコードからローカル環境でビルドするには、Rustがインストールされている必要があります。
77 |
78 | ### 前提条件
79 |
80 | - [Rust](https://www.rust-lang.org/tools/install)がシステムにインストールされていること
81 |
82 | ### ビルド・インストール手順
83 |
84 | リポジトリをクローンして `cargo install --path .` を実行してください:
85 |
86 | ```bash
87 | git clone https://github.com/t3tra-dev/pyinit.git
88 | cd pyinit
89 | cargo install --path .
90 | ```
91 |
92 | これで、`pyinit`が実行できるようになります:
93 |
94 | ```bash
95 | pyinit --help
96 | ```
97 |
98 | ## 使用方法
99 |
100 | `pyinit`は、対話形式およびコマンドライン引数を使用して非対話形式で実行できます。
101 |
102 | ### コマンドライン引数
103 |
104 | ```bash
105 | pyinit [OPTIONS]
106 | ```
107 |
108 | #### オプション
109 |
110 | - `--name`, `-n`: ライブラリの名前を指定
111 | - `--description`, `-d`: ライブラリの説明を指定
112 | - `--author`, `-a`: 作者の名前を指定
113 | - `--license`, `-l`: ライセンスの種類を指定(MIT、GPL、Apache-2.0、など)
114 | - `--help`, `-h`: CLIのヘルプ情報を表示(`-h`はサマリー)
115 | - `--version`: CLIのバージョンを表示
116 |
117 | #### 使用例
118 |
119 | インタラクティブにPythonライブラリプロジェクトを作成するには、以下のコマンドを実行します:
120 |
121 | ```bash
122 | pyinit
123 | ```
124 |
125 | プロジェクト名や説明、作者、ライセンスを尋ねられるので、入力して進みます。非対話形式でプロジェクトを作成する場合は、コマンドライン引数を使用します:
126 |
127 | ```bash
128 | pyinit --name mylib --description "A Python library for awesome features" --author "John Doe" --license MIT
129 | ```
130 |
131 | これにより、以下のディレクトリ構造が生成されます:
132 |
133 | ```
134 | mylib/
135 | ├── LICENSE
136 | ├── README.md
137 | ├── mylib/
138 | │ └── __init__.py
139 | ├── requirements.txt
140 | ├── setup.py
141 | └── tests/
142 | ```
143 |
144 | ### ライセンスの選択
145 |
146 | ライセンスに`custom`を選んだ場合、カスタムライセンステキストを入力するか、空白のままにすることができます。それ以外の場合は、選択したライセンスに基づいて`LICENSE`ファイルが自動的に生成されます。
147 |
148 | ## コントリビューティングとサポート
149 |
150 | `pyinit`への貢献は大歓迎です!以下の手順に従って貢献できます:
151 |
152 | 1. リポジトリをフォークします: [https://github.com/t3tra-dev/pyinit](https://github.com/t3tra-dev/pyinit)
153 | 2. フィーチャーブランチを作成します: `git checkout -b feature/your-feature`
154 | 3. 変更をコミットします: `git commit -m 'Add a new feature'`
155 | 4. ブランチをプッシュします: `git push origin feature/your-feature`
156 | 5. プルリクエストを送信します。
157 |
158 | サポートや質問については、リポジトリの[Issuesセクション](https://github.com/t3tra-dev/pyinit/issues)に問題を報告してください。
159 |
160 | 全てのコントリビューターに感謝しています!
161 |
162 | 
163 |
164 | ---
165 |
166 | `pyinit`はMITライセンスの下で提供されています。詳細については[LICENSE](https://github.com/t3tra-dev/pyinit/blob/main/LICENSE)ファイルをご覧ください。
167 |
--------------------------------------------------------------------------------
/src/templates/license.rs:
--------------------------------------------------------------------------------
1 | pub struct License(Repr);
2 |
3 | enum Repr {
4 | Builtin(BuiltinLicense),
5 | Custom { name: String },
6 | }
7 |
8 | macro_rules! BuiltinLicense {
9 | ($( $path:literal as $Struct:ident # $doc:literal ),* $(,)?) => {
10 | #[derive(Clone, clap::ValueEnum)]
11 | #[value(rename_all = "verbatim")]
12 | pub enum BuiltinLicense {
13 | $(
14 | #[doc = $doc]
15 | $Struct
16 | ),*
17 | }
18 |
19 | impl BuiltinLicense {
20 | const NAMES: &'static [&'static str] = &[$( $Struct::NAME ),*];
21 |
22 | fn from_name(name: &str) -> Option {
23 | match name {
24 | $( $Struct::NAME => Some(Self::$Struct), )*
25 | _ => None
26 | }
27 | }
28 |
29 | fn name(&self) -> &str {
30 | match self {
31 | $( Self::$Struct => $Struct::NAME, )*
32 | }
33 | }
34 |
35 | fn render_with(self, package_info: PackageInfo) -> crate::Result {
36 | match self {
37 | $( Self::$Struct => $Struct::from_package_info(package_info).render(), )*
38 | }
39 | }
40 | }
41 |
42 | $(
43 | #[derive(askama::Template)]
44 | #[template(path = $path, escape = "none")]
45 | #[allow(unused)]
46 | struct $Struct {
47 | year: u16,
48 | name: String,
49 | author: String,
50 | }
51 |
52 | impl $Struct {
53 | const NAME: &'static str = const_name_of($path);
54 |
55 | fn from_package_info(PackageInfo { name, author }: PackageInfo) -> Self {
56 | let year = crate::util::current_year();
57 | Self { year, name, author }
58 | }
59 |
60 | fn render(self) -> crate::Result {
61 | let r = ::render(&self)?;
62 | Ok(r)
63 | }
64 | }
65 | )*
66 | };
67 | }
68 |
69 | BuiltinLicense! {
70 | "licenses/Apache-2.0" as Apache # "Apache-2.0 license",
71 | "licenses/BSD 2-Clause" as BSD2 # "BSD 2-Clause license",
72 | "licenses/BSD 3-Clause" as BSD3 # "BSD 3-Clause license",
73 | "licenses/CC0-1.0" as CC0 # "CC0-1.0 license",
74 | "licenses/EPL-2.0" as EPL # "EPL-2.0 license",
75 | "licenses/GPL-3.0" as GPL # "GPL-3.0 license",
76 | "licenses/MIT" as MIT # "MIT license",
77 | "licenses/MPL-2.0" as MPL # "MPL-2.0 license",
78 | }
79 |
80 | pub struct PackageInfo {
81 | pub name: String,
82 | pub author: String,
83 | }
84 |
85 | impl License {
86 | pub const BUILTIN_NAMES: &'static [&'static str] = BuiltinLicense::NAMES;
87 |
88 | pub fn builtin(name: &str) -> Option {
89 | BuiltinLicense::from_name(name)
90 | .map(Repr::Builtin).map(Self)
91 | }
92 |
93 | pub fn custom(name: String) -> Self {
94 | Self(Repr::Custom { name })
95 | }
96 |
97 | pub fn name(&self) -> &str {
98 | match &self.0 {
99 | Repr::Builtin(b) => b.name(),
100 | Repr::Custom { name } => &name
101 | }
102 | }
103 |
104 | pub fn render_with(self, package_info: PackageInfo) -> crate::Result {
105 | match self.0 {
106 | Repr::Builtin(b) => b.render_with(package_info),
107 | Repr::Custom { .. } => Ok(String::new())
108 | }
109 | }
110 | }
111 |
112 | impl From for License {
113 | fn from(builtin: BuiltinLicense) -> Self {
114 | Self(Repr::Builtin(builtin))
115 | }
116 | }
117 |
118 | const fn const_name_of(path: &'static str) -> &'static str {
119 | if !path.is_ascii() {
120 | panic!("unexpected non-ascii path")
121 | }
122 |
123 | let bytes: &[u8] = path.as_bytes();
124 | let mut i: usize = path.len() - 1;
125 | while i > 0 {
126 | if bytes[i] == b'/' {
127 | return unsafe {
128 | std::str::from_utf8_unchecked(
129 | std::slice::from_raw_parts(
130 | bytes.as_ptr().add(i + 1),
131 | bytes.len() - (i + 1)
132 | )
133 | )
134 | }
135 | }
136 | i -= 1;
137 | }
138 |
139 | path
140 | }
141 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [[Japanese/日本語](README.ja.md)]
2 |
3 | # pyinit
4 |
5 | `pyinit` is a command-line tool designed to help developers quickly scaffold Python library projects. This tool generates essential files like `README.md`, `LICENSE`, `setup.py`, and more, allowing developers to focus on coding without worrying about project setup.
6 |
7 | ## Features
8 |
9 | - Automatically creates Python library project structure.
10 | - Generates essential files such as `README.md`, `LICENSE`, `__init__.py`, `setup.py`, and `requirements.txt`.
11 | - Supports custom templates for flexibility.
12 | - Cross-platform: Works on Linux, macOS, and Windows.
13 | - Command-line interface with interactive prompts and support for command-line arguments for faster project initialization.
14 |
15 | ## Installation
16 |
17 | ### Linux
18 |
19 | To install `pyinit` on Linux, download the latest release from the [releases page](https://github.com/t3tra-dev/pyinit/releases) and move the binary to a directory in your `PATH`.
20 |
21 | ```bash
22 | wget https://github.com/t3tra-dev/pyinit/releases/download/v1.0.0/pyinit-linux-latest-v1.0.0.zip
23 | unzip pyinit-linux-latest-v1.0.0.zip
24 | chmod +x pyinit
25 | sudo mv pyinit /usr/local/bin/
26 | ```
27 |
28 | Now you can run `pyinit`:
29 |
30 | ```bash
31 | pyinit --help
32 | ```
33 |
34 | ### macOS
35 |
36 | For macOS, download the latest release from the [releases page](https://github.com/t3tra-dev/pyinit/releases) and move the binary to your `PATH`.
37 |
38 | ```bash
39 | curl -L -O https://github.com/t3tra-dev/pyinit/releases/download/v1.0.0/pyinit-macos-latest-v1.0.0.zip
40 | unzip pyinit-macos-latest-v1.0.0.zip
41 | chmod +x pyinit
42 | sudo mv pyinit /usr/local/bin/
43 | ```
44 |
45 | Now you can run `pyinit`:
46 |
47 | ```bash
48 | pyinit --help
49 | ```
50 |
51 | ### Windows
52 |
53 | For Windows, download the latest release from the [releases page](https://github.com/t3tra-dev/pyinit/releases) and extract it:
54 |
55 | ```bash
56 | Invoke-WebRequest -Uri https://github.com/t3tra-dev/pyinit/releases/download/v1.0.0/pyinit-windows-latest-v1.0.0.zip -OutFile pyinit.zip
57 | Expand-Archive -Path pyinit.zip -DestinationPath .
58 | ```
59 |
60 | Add the binary to your `PATH` by following these steps:
61 |
62 | 1. Right-click "This PC" and select "Properties."
63 | 2. Click "Advanced system settings" and go to "Environment Variables."
64 | 3. Under "System variables," select `Path` and click "Edit."
65 | 4. Click "New" and add the path where `pyinit.exe` is located.
66 | 5. Click "OK" to close all windows.
67 |
68 | You can now run `pyinit` from the command line:
69 |
70 | ```bash
71 | pyinit --help
72 | ```
73 |
74 | ## Building Locally
75 |
76 | To build `pyinit` from source locally, you need to have Rust installed.
77 |
78 | ### Prerequisites
79 |
80 | - Install [Rust](https://www.rust-lang.org/tools/install) on your system.
81 |
82 | ### Build and Install:
83 |
84 | Clone the repository and run `cargo install --path .`:
85 |
86 | ```bash
87 | git clone https://github.com/t3tra-dev/pyinit.git
88 | cd pyinit
89 | cargo install --path .
90 | ```
91 |
92 | Now you can run `pyinit`:
93 |
94 | ```bash
95 | pyinit --help
96 | ```
97 |
98 | ## Usage
99 |
100 | `pyinit` can be used interactively or non-interactively by providing command-line arguments.
101 |
102 | ### Command-line Arguments
103 |
104 | ```bash
105 | pyinit [OPTIONS]
106 | ```
107 |
108 | #### Options
109 |
110 | - `--name`, `-n`: Specify the name of the Python library.
111 | - `--description`, `-d`: Provide a description for the library.
112 | - `--author`, `-a`: Specify the author's name.
113 | - `--license`, `-l`: Choose the license type (MIT, GPL, Apache-2.0, and more).
114 | - `--help`, `-h`: Display help information (`-h` shows summary).
115 | - `--version`: Print version
116 |
117 | #### Example
118 |
119 | To create a Python library project interactively, run:
120 |
121 | ```bash
122 | pyinit
123 | ```
124 |
125 | You'll be prompted to enter the project details such as the name, description, author, and license. If you want to skip the interactive mode, you can use command-line arguments:
126 |
127 | ```bash
128 | pyinit --name mylib --description "A Python library for awesome features" --author "John Doe" --license MIT
129 | ```
130 |
131 | This will generate the following directory structure:
132 |
133 | ```
134 | mylib/
135 | ├── LICENSE
136 | ├── README.md
137 | ├── mylib/
138 | │ └── __init__.py
139 | ├── requirements.txt
140 | ├── setup.py
141 | └── tests/
142 | ```
143 |
144 | ### License Selection
145 |
146 | When selecting `custom` as the license type, you'll be prompted to enter custom license text or leave it blank. Otherwise, the selected license will automatically populate the `LICENSE` file.
147 |
148 | ## Contributing and Support
149 |
150 | We welcome contributions! Please follow these steps to contribute:
151 |
152 | 1. Fork the repository: [https://github.com/t3tra-dev/pyinit](https://github.com/t3tra-dev/pyinit).
153 | 2. Create a feature branch: `git checkout -b feature/your-feature`.
154 | 3. Commit your changes: `git commit -m 'Add a new feature'`.
155 | 4. Push to the branch: `git push origin feature/your-feature`.
156 | 5. Open a Pull Request.
157 |
158 | For any questions or support, feel free to open an issue in the repository's [Issues section](https://github.com/t3tra-dev/pyinit/issues).
159 |
160 | thanks for all contributors!
161 |
162 | 
163 |
164 | ---
165 |
166 | `pyinit` is licensed under the MIT License. See the [LICENSE](https://github.com/t3tra-dev/pyinit/blob/main/LICENSE) file for more details.
167 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | [[Japanese/日本語](CODE_OF_CONDUCT.ja.md)]
2 |
3 | # Contributor Covenant Code of Conduct
4 |
5 | ## Our Pledge
6 |
7 | We as members, contributors, and leaders pledge to make participation in our
8 | community a harassment-free experience for everyone, regardless of age, body
9 | size, visible or invisible disability, ethnicity, sex characteristics, gender
10 | identity and expression, level of experience, education, socio-economic status,
11 | nationality, personal appearance, race, caste, color, religion, or sexual
12 | identity and orientation.
13 |
14 | We pledge to act and interact in ways that contribute to an open, welcoming,
15 | diverse, inclusive, and healthy community.
16 |
17 | ## Our Standards
18 |
19 | Examples of behavior that contributes to a positive environment for our
20 | community include:
21 |
22 | * Demonstrating empathy and kindness toward other people
23 | * Being respectful of differing opinions, viewpoints, and experiences
24 | * Giving and gracefully accepting constructive feedback
25 | * Accepting responsibility and apologizing to those affected by our mistakes,
26 | and learning from the experience
27 | * Focusing on what is best not just for us as individuals, but for the overall
28 | community
29 |
30 | Examples of unacceptable behavior include:
31 |
32 | * The use of sexualized language or imagery, and sexual attention or advances of
33 | any kind
34 | * Trolling, insulting or derogatory comments, and personal or political attacks
35 | * Public or private harassment
36 | * Publishing others' private information, such as a physical or email address,
37 | without their explicit permission
38 | * Other conduct which could reasonably be considered inappropriate in a
39 | professional setting
40 |
41 | ## Enforcement Responsibilities
42 |
43 | Community leaders are responsible for clarifying and enforcing our standards of
44 | acceptable behavior and will take appropriate and fair corrective action in
45 | response to any behavior that they deem inappropriate, threatening, offensive,
46 | or harmful.
47 |
48 | Community leaders have the right and responsibility to remove, edit, or reject
49 | comments, commits, code, wiki edits, issues, and other contributions that are
50 | not aligned to this Code of Conduct, and will communicate reasons for moderation
51 | decisions when appropriate.
52 |
53 | ## Scope
54 |
55 | This Code of Conduct applies within all community spaces, and also applies when
56 | an individual is officially representing the community in public spaces.
57 | Examples of representing our community include using an official email address,
58 | posting via an official social media account, or acting as an appointed
59 | representative at an online or offline event.
60 |
61 | ## Enforcement
62 |
63 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
64 | reported to the community leaders responsible for enforcement at
65 | Mail.
66 | All complaints will be reviewed and investigated promptly and fairly.
67 |
68 | All community leaders are obligated to respect the privacy and security of the
69 | reporter of any incident.
70 |
71 | ## Enforcement Guidelines
72 |
73 | Community leaders will follow these Community Impact Guidelines in determining
74 | the consequences for any action they deem in violation of this Code of Conduct:
75 |
76 | ### 1. Correction
77 |
78 | **Community Impact**: Use of inappropriate language or other behavior deemed
79 | unprofessional or unwelcome in the community.
80 |
81 | **Consequence**: A private, written warning from community leaders, providing
82 | clarity around the nature of the violation and an explanation of why the
83 | behavior was inappropriate. A public apology may be requested.
84 |
85 | ### 2. Warning
86 |
87 | **Community Impact**: A violation through a single incident or series of
88 | actions.
89 |
90 | **Consequence**: A warning with consequences for continued behavior. No
91 | interaction with the people involved, including unsolicited interaction with
92 | those enforcing the Code of Conduct, for a specified period of time. This
93 | includes avoiding interactions in community spaces as well as external channels
94 | like social media. Violating these terms may lead to a temporary or permanent
95 | ban.
96 |
97 | ### 3. Temporary Ban
98 |
99 | **Community Impact**: A serious violation of community standards, including
100 | sustained inappropriate behavior.
101 |
102 | **Consequence**: A temporary ban from any sort of interaction or public
103 | communication with the community for a specified period of time. No public or
104 | private interaction with the people involved, including unsolicited interaction
105 | with those enforcing the Code of Conduct, is allowed during this period.
106 | Violating these terms may lead to a permanent ban.
107 |
108 | ### 4. Permanent Ban
109 |
110 | **Community Impact**: Demonstrating a pattern of violation of community
111 | standards, including sustained inappropriate behavior, harassment of an
112 | individual, or aggression toward or disparagement of classes of individuals.
113 |
114 | **Consequence**: A permanent ban from any sort of public interaction within the
115 | community.
116 |
117 | ## Attribution
118 |
119 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
120 | version 2.1, available at
121 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
122 |
123 | Community Impact Guidelines were inspired by
124 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
128 | [https://www.contributor-covenant.org/translations][translations].
129 |
130 | [homepage]: https://www.contributor-covenant.org
131 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
132 | [Mozilla CoC]: https://github.com/mozilla/diversity
133 | [FAQ]: https://www.contributor-covenant.org/faq
134 | [translations]: https://www.contributor-covenant.org/translations
135 |
--------------------------------------------------------------------------------
/templates/licenses/CC0-1.0:
--------------------------------------------------------------------------------
1 | Creative Commons Legal Code
2 |
3 | CC0 1.0 Universal
4 |
5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12 | HEREUNDER.
13 |
14 | Statement of Purpose
15 |
16 | The laws of most jurisdictions throughout the world automatically confer
17 | exclusive Copyright and Related Rights (defined below) upon the creator
18 | and subsequent owner(s) (each and all, an "owner") of an original work of
19 | authorship and/or a database (each, a "Work").
20 |
21 | Certain owners wish to permanently relinquish those rights to a Work for
22 | the purpose of contributing to a commons of creative, cultural and
23 | scientific works ("Commons") that the public can reliably and without fear
24 | of later claims of infringement build upon, modify, incorporate in other
25 | works, reuse and redistribute as freely as possible in any form whatsoever
26 | and for any purposes, including without limitation commercial purposes.
27 | These owners may contribute to the Commons to promote the ideal of a free
28 | culture and the further production of creative, cultural and scientific
29 | works, or to gain reputation or greater distribution for their Work in
30 | part through the use and efforts of others.
31 |
32 | For these and/or other purposes and motivations, and without any
33 | expectation of additional consideration or compensation, the person
34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35 | is an owner of Copyright and Related Rights in the Work, voluntarily
36 | elects to apply CC0 to the Work and publicly distribute the Work under its
37 | terms, with knowledge of his or her Copyright and Related Rights in the
38 | Work and the meaning and intended legal effect of CC0 on those rights.
39 |
40 | 1. Copyright and Related Rights. A Work made available under CC0 may be
41 | protected by copyright and related or neighboring rights ("Copyright and
42 | Related Rights"). Copyright and Related Rights include, but are not
43 | limited to, the following:
44 |
45 | i. the right to reproduce, adapt, distribute, perform, display,
46 | communicate, and translate a Work;
47 | ii. moral rights retained by the original author(s) and/or performer(s);
48 | iii. publicity and privacy rights pertaining to a person's image or
49 | likeness depicted in a Work;
50 | iv. rights protecting against unfair competition in regards to a Work,
51 | subject to the limitations in paragraph 4(a), below;
52 | v. rights protecting the extraction, dissemination, use and reuse of data
53 | in a Work;
54 | vi. database rights (such as those arising under Directive 96/9/EC of the
55 | European Parliament and of the Council of 11 March 1996 on the legal
56 | protection of databases, and under any national implementation
57 | thereof, including any amended or successor version of such
58 | directive); and
59 | vii. other similar, equivalent or corresponding rights throughout the
60 | world based on applicable law or treaty, and any national
61 | implementations thereof.
62 |
63 | 2. Waiver. To the greatest extent permitted by, but not in contravention
64 | of, applicable law, {{ author }} hereby overtly, fully, permanently,
65 | irrevocably and unconditionally waives, abandons, and surrenders all of
66 | {{ author }}'s Copyright and Related Rights and associated claims and causes
67 | of action, whether now known or unknown (including existing as well as
68 | future claims and causes of action), in the Work (i.e., {{ name }}) (i) in all
69 | territories worldwide, (ii) for the maximum duration provided by
70 | applicable law or treaty (including future time extensions), (iii) in any
71 | current or future medium and for any number of copies, and (iv) for any
72 | purpose whatsoever, including without limitation commercial, advertising,
73 | or promotional purposes (the "Waiver"). {{ author }} makes the Waiver for the
74 | benefit of each member of the public at large and to the detriment of
75 | {{ author }}'s heirs and successors, fully intending that such Waiver shall
76 | not be subject to revocation, rescission, cancellation, termination, or
77 | any other legal or equitable action to disrupt the quiet enjoyment of the
78 | Work by the public as contemplated by {{ author }}'s express Statement of
79 | Purpose.
80 |
81 | 3. Public License Fallback. Should any part of the Waiver for any reason
82 | be judged legally invalid or ineffective under applicable law, then the
83 | Waiver shall be preserved to the maximum extent permitted taking into
84 | account {{ author }}'s express Statement of Purpose. In addition, to the
85 | extent the Waiver is so judged, {{ author }} hereby grants to each affected
86 | person a royalty-free, non-transferable, non-sublicensable, non-exclusive,
87 | irrevocable and unconditional license to exercise {{ author }}'s Copyright and
88 | Related Rights in the Work (i.e., {{ name }}) (i) in all territories
89 | worldwide, (ii) for the maximum duration provided by applicable law or
90 | treaty (including future time extensions), (iii) in any current or future
91 | medium and for any number of copies, and (iv) for any purpose whatsoever,
92 | including without limitation commercial, advertising, or promotional
93 | purposes (the "License"). The License shall be deemed effective as of the
94 | date CC0 was applied by {{ author }} to the Work. Should any part of the
95 | License for any reason be judged legally invalid or ineffective under
96 | applicable law, such partial invalidity or ineffectiveness shall not
97 | invalidate the remainder of the License, and in such case {{ author }} hereby
98 | affirms that {{ author }} will not (i) exercise any of {{ author }}'s remaining
99 | Copyright and Related Rights in the Work or (ii) assert any associated
100 | claims and causes of action with respect to the Work, in either case
101 | contrary to {{ author }}'s express Statement of Purpose.
102 |
103 | 4. Limitations and Disclaimers.
104 |
105 | a. No trademark or patent rights held by {{ author }} are waived, abandoned,
106 | surrendered, licensed or otherwise affected by this document.
107 | b. {{ author }} offers the Work (i.e., {{ name }}) as-is and makes no representations or
108 | warranties of any kind concerning the Work, express, implied,
109 | statutory or otherwise, including without limitation warranties of
110 | title, merchantability, fitness for a particular purpose,
111 | non-infringement, or the absence of latent or other defects, accuracy,
112 | or the present or absence of errors, whether or not discoverable, all
113 | to the greatest extent permissible under applicable law.
114 | c. {{ author }} disclaims responsibility for clearing rights of other persons
115 | that may apply to the Work or any use thereof, including without
116 | limitation any person's Copyright and Related Rights in the Work.
117 | Further, {{ author }} disclaims responsibility for obtaining any necessary
118 | consents, permissions or other rights required for any use of the
119 | Work.
120 | d. {{ author }} understands and acknowledges that Creative Commons is not a
121 | party to this document and has no duty or obligation with respect to
122 | this CC0 or use of the Work.
123 |
--------------------------------------------------------------------------------
/templates/licenses/MPL-2.0:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------