Skip to content

Commit 848ea03

Browse files
committed
fixes and feedback
1 parent 5a0facc commit 848ea03

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
pip install -e ".[develop]"
3333
- name: Lint
3434
run: |
35-
pytest . --pylint -m pylint --pylint-rcfile=.python_starter_pylintrc
35+
pytest . --pylint -m pylint --pylint-rcfile=.pylintrc
3636
static-type-checking:
3737
runs-on: ubuntu-latest
3838
strategy:

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,30 @@ A basic template for building Python packages.
2121
2. **Clone this repository** and give it the name of your repository: `git clone [email protected]:tomsilver/python-starter.git <NAME>`. You should now have a directory called NAME. **Enter** that directory: `cd <NAME>`.
2222
3. **Configure the repository:** Make changes to `config.json` and then save.
2323
4. **Apply the configuration**: Run `python apply_configuration.py`.
24+
5. **Push your changes**: For example, run `git add . && git commit -m "First commit" && git push -u origin main`.
2425

2526
:tada: **That's it! Your code is ready to use** :tada: You should see your code back on GitHub where you previously had an empty repository.
2627

2728
### Common Next Steps
28-
5. **Make changes** to `pyproject.toml`, especially in the dependencies section.
29-
6. **Install your repository**: `pip install -e .` (recommended: use a virtualenv).
30-
7. **Replace the starter files** (`README.md`, `LICENSE`, `config.json`, `apply_configuration.py`, `structs.py`, `utils.py` and the analogous files in `tests/`) with some of your own.
29+
6. **Make changes** to `pyproject.toml`, especially in the dependencies section.
30+
7. **Install your repository**: `pip install -e .` (recommended: use a virtualenv).
31+
8. **Replace the starter files** (`README.md`, `LICENSE`, `config.json`, `apply_configuration.py`, `structs.py`, `utils.py` and the analogous files in `tests/`) with some of your own.
3132

3233
### Configure GitHub (Optional but Recommended)
33-
8. **Set up branch protections** to prevent accidental changes to your main branch. In `https://github.com/<USER>/<NAME>/settings/branches`:
34+
9. **Set up branch protections** to prevent accidental changes to your main branch. In `https://github.com/<USER>/<NAME>/settings/branches`:
3435
- Click `Add classic branch protection rule`.
3536
- The branch pattern name is `main`.
3637
- Check "Require a pull request before merging (optionally: uncheck "Require approvals").
3738
- Check "Require status checks to pass before merging".
3839
- Check "Require branches to be up to date before merging".
3940
- Then type in `autoformat`, `static-type-checking`, `linting`, `unit-tests`.
4041
- Check "Do not allow bypassing the above settings".
41-
9. **Set up repository settings** in `https://github.com/<USER>/<NAME>/settings`:
42+
10. **Set up repository settings** in `https://github.com/<USER>/<NAME>/settings`:
4243
- Check "Allow auto-merge".
4344
- Check "Automatically delete head branches".
4445
- Uncheck "Allow merge commits".
4546
- Uncheck "Allow rebase merging".
46-
10. **Set up contributor settings** to lower the barrier for external contributions. In `https://github.com/<USER>/<NAME>/settings/actions`:
47+
11. **Set up contributor settings** to lower the barrier for external contributions. In `https://github.com/<USER>/<NAME>/settings/actions`:
4748
- Update "Fork pull request workflows from outside collaborators" to "Require approval for first-time contributors who are new to GitHub".
4849

4950

apply_configuration.py

+18-20
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _replace_all_occurences(
2323
["git", "ls-files"], encoding="utf-8", stdout=subprocess.PIPE, check=True
2424
)
2525
for line in proc.stdout.split("\n"):
26-
known_files.add(outer_dir / line)
26+
known_files.add((outer_dir / line).resolve())
2727
known_files -= exclude
2828
for file_path in known_files:
2929
if file_path.is_dir():
@@ -38,7 +38,8 @@ def _replace_all_occurences(
3838

3939
def _main() -> None:
4040
# Parse the config.
41-
config_file = Path(".").parent / "config.json"
41+
outer_dir = Path(".").parent.resolve()
42+
config_file = outer_dir / "config.json"
4243
assert config_file.exists(), "Missing config file"
4344
with open(config_file, "r", encoding="utf-8") as fp:
4445
config = json.load(fp)
@@ -64,10 +65,10 @@ def _main() -> None:
6465
assert python_subversion.isdigit()
6566

6667
# Get the repository name from this directory.
67-
repo_name = Path(".").parent.resolve().name
68+
repo_name = outer_dir.name
6869

6970
# Delete the existing git files if they are from the starter repo.
70-
git_repo = Path(".").parent / ".git"
71+
git_repo = outer_dir / ".git"
7172
if git_repo.exists():
7273
git_config_file = git_repo / "config"
7374
with open(git_config_file, "r", encoding="utf-8") as fp:
@@ -78,6 +79,16 @@ def _main() -> None:
7879
# Initialize the repo anew.
7980
subprocess.run(["git", "init", "-b", "main"], check=True)
8081
subprocess.run(["git", "add", "."], check=True)
82+
subprocess.run(
83+
[
84+
"git",
85+
"remote",
86+
"add",
87+
"origin",
88+
f"[email protected]:{github_username}/{repo_name}.git",
89+
],
90+
check=True,
91+
)
8192

8293
# Replace all occurrences of default names.
8394
substitutions = {
@@ -89,26 +100,13 @@ def _main() -> None:
89100
"310": f"3{python_subversion}",
90101
}
91102
for old, new in substitutions.items():
92-
_replace_all_occurences(old, new, exclude={Path("."), config_file})
103+
_replace_all_occurences(
104+
old, new, exclude={outer_dir / "apply_configuration.py", config_file}
105+
)
93106

94107
# Rename the package repo.
95108
subprocess.run(["mv", "src/python_starter", f"src/{package_name}"], check=True)
96109

97-
# Commit and push.
98-
subprocess.run(["git", "add", "."], check=True)
99-
subprocess.run(["git", "commit", "-m", "First commit"], check=True)
100-
subprocess.run(
101-
[
102-
"git",
103-
"remote",
104-
"add",
105-
"origin",
106-
f"[email protected]:{github_username}/{repo_name}.git",
107-
],
108-
check=True,
109-
)
110-
subprocess.run(["git", "push", "-u", "origin", "main"], check=True)
111-
112110

113111
if __name__ == "__main__":
114112
_main()

0 commit comments

Comments
 (0)