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

Switch Dependency Management to pyproject.toml + Bonus Changes #1406

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
python-version: "3.11"
cache: pip
- run: pip install wheel
- run: pip install -r requirements-dev.txt
- run: pip install ".[dev]"
- name: Gather a list of Python files in the pull request branch
run: |
(cd pr && git ls-files) | grep -E '\.(py|pyw)$' | sed s:^:pr/: | tee filelist.txt
Expand All @@ -46,4 +46,4 @@ jobs:
- uses: stefanzweifel/git-auto-commit-action@v4
with:
repository: ./pr
commit_message: "Run pycln, pyupgrade, black and isort"
commit_message: "Run pycln, pyupgrade, black, and isort"
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
python-version: "3.11"
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install ".[dev]"
- run: |
time mypy --platform linux --python-version 3.8 porcupine docs/extensions.py
time mypy --platform linux --python-version 3.9 porcupine docs/extensions.py
Expand All @@ -42,7 +42,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install ".[dev]"
- if: matrix.os == 'ubuntu-latest'
# Make sure that it doesn't crash with Noto Color Emoji installed
run: sudo apt install --no-install-recommends fonts-noto-color-emoji tkdnd
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- if: matrix.python-version != '3.8'
run: brew install python-tk@${{ matrix.python-version }}
- run: $PYTHON --version
- run: $PYTHON -m pip install -r requirements.txt -r requirements-dev.txt
- run: $PYTHON -m pip install ".[dev]"
- run: $PYTHON scripts/download-tkdnd.py
- run: $PYTHON -m pytest --durations=10

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-builds.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

on:
push:
tags:
Expand All @@ -14,7 +15,7 @@ jobs:
python-version: "3.8" # last version supporting windows 7
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install ".[dev]"
- uses: egor-tensin/setup-clang@v1
with:
platform: x64
Expand All @@ -34,7 +35,7 @@ jobs:
python-version: "3.11"
cache: pip
- run: pip install wheel
- run: pip install -r requirements.txt -r requirements-dev.txt
- run: pip install ".[dev]"
- run: python3 -m sphinx ./docs ./build
- if: startsWith(github.ref, 'refs/tags/v')
uses: JamesIves/[email protected]
Expand Down
74 changes: 40 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

If you want to do something to Porcupine, that's awesome!
I have tried to make contributing easy:

- Some issues are labeled as "good first issue".
- If you don't understand what I meant in an issue, please ask me to clarify it.
I have written most issues so that I understand what I wrote,
and if you are new to Porcupine, you likely need a longer explanation to understand what the problem is.
I have written most issues so that I understand what I wrote,
and if you are new to Porcupine, you likely need a longer explanation to understand what the problem is.
- Don't worry about asking too many questions!
It's not annoying. I like interacting with other programmers.
It's not annoying. I like interacting with other programmers.
- There is not much boilerplate involved in the contributing process.
You just create a pull request and that's it.
You can choose an issue and start working on it, without prior permission.
Instead of working on an issue, you can also create something that you would
like to have in an editor.
You just create a pull request and that's it.
You can choose an issue and start working on it, without prior permission.
Instead of working on an issue, you can also create something that you would
like to have in an editor.
- You don't need to read anything before you can get started.
I recommend having a look at [the Porcupine plugin API docs](https://akuli.github.io/porcupine/),
but that's not required.
I recommend having a look at [the Porcupine plugin API docs](https://akuli.github.io/porcupine/),
but that's not required.
- Don't worry too much about whether your code is good or not.
I will review the pull requests and try to help you out.
There are also checks running on GitHub Actions.
I will review the pull requests and try to help you out.
There are also checks running on GitHub Actions.

To get started, make a fork of Porcupine with the button in the top right corner of this page.
Then install Python 3.8 or newer and [git](https://git-scm.com/), and run these commands:
Expand All @@ -27,21 +28,21 @@ Then install Python 3.8 or newer and [git](https://git-scm.com/), and run these
cd porcupine
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -e ".[dev]"
benjamin-kirkbride marked this conversation as resolved.
Show resolved Hide resolved
python3 -m porcupine

This should run Porcupine. If you change some of Porcupine's
code in the `porcupine` directory and you run `python3 -m porcupine` again, your changes
should be visible right away.

Windows-specific notes:

- You need to use `py` instead of `python3` when creating the venv,
and `env\Scripts\activate` instead of `source env/bin/activate` to activate it.
and `env\Scripts\activate` instead of `source env/bin/activate` to activate it.
- If creating the venv fails with an error message like `Error: [Errno 13] Permission denied: ...\\python.exe`,
try creating the venv into a different folder.
It is created into whatever folder you are currently `cd`'d to
(i.e. the folder that shows up on the command prompt before the `>`).
try creating the venv into a different folder.
It is created into whatever folder you are currently `cd`'d to
(i.e. the folder that shows up on the command prompt before the `>`).

Porcupine uses `mypy`, which is a tool that type-checks the code without running it.
For small pull requests, you probably don't need to run it on your computer as GitHub Actions runs it on your pull request anyway.
Expand All @@ -64,21 +65,27 @@ place and running `source env/bin/activate` again. You can run `deactivate` to u
the `source env/bin/activate`.

Other commands you may find useful:

- `python3 -m pytest` runs tests. You will see lots of weird stuff happening
while testing, and that's expected.
A good way to debug a test to see what is actually going on is to add traces.
It pauses the test to show you the current state of the program.
- Use `import pdb` and `pdb.set_trace()` to set the pause points in the test. You can
set as many as you like, and it can conveniently be done on one line: `import pdb; pdb.set_trace()`.
- When the test pauses, type `cont` in terminal to continue the test.
- If you at any time need to interact with the program during the pause,
type `interact` in terminal. Exit interactive mode with `ctrl + D`.
A good way to debug a test to see what is actually going on is to add traces.
It pauses the test to show you the current state of the program.
- Use `breakpoint()` to set the pause points in the test. You can
set as many as you like.
- When the test pauses, type `cont` in terminal to continue the test.
- If you at any time need to interact with the program during the pause,
type `interact` in terminal. Exit interactive mode with `ctrl + D`.
- To see a report of test coverage, add `--cov=porcupine` to the above pytest
command and then run `coverage html`. Open `htmlcov/index.html` in your favorite
browser to view it.
- `cd docs` followed by `python3 -m sphinx . build` creates HTML documentation.
Open `docs/build/index.html` in your favorite browser to view it.

- `xvfb-run pytest` (on most Linux systems) will run the tests in a headless mode.
benjamin-kirkbride marked this conversation as resolved.
Show resolved Hide resolved
This means that you will not see a window as the tests are running.
- `pytest --capture=fd` will prevent `print` statements and logs to print until
all tests are finished. This will change from the default behavior of porcupine
where the output is printed as soon as it is generated while executing the tests.
Instead output will be printed after all tests are finished (for tests that failed).

## Where to talk to us

Expand All @@ -91,24 +98,23 @@ and we often discuss things that have nothing to do with Porcupine.
To join ##learnpython, you can e.g. go to https://kiwiirc.com/nextclient/irc.libera.chat/##learnpython
or run [Akuli's mantaray program](https://github.com/Akuli/mantaray).


## Releasing Porcupine

These instructions are meant for Porcupine maintainers.
Other people shouldn't need them.

1. Update `CHANGELOG.md` based on Git logs (e.g. `git log --all --oneline --graph`).
You should add a new section to the beginning with `Unreleased` instead of a version number.
Don't split the text to multiple lines any more than is necessary,
as that won't show up correctly on GitHub's releases page.
You should add a new section to the beginning with `Unreleased` instead of a version number.
Don't split the text to multiple lines any more than is necessary,
as that won't show up correctly on GitHub's releases page.
2. Make a pull request of your changelog edits. Review carefully:
changing the changelog afterwards is difficult, as the text gets copied into the releases page.
changing the changelog afterwards is difficult, as the text gets copied into the releases page.
3. Merge the pull request and pull the merge commit to your local `main` branch.
4. Run `python3 scripts/release.py` from the `main` branch.
The script pushes a tag named e.g. `v2022.08.28`,
which triggers the parts of `.github/workflows/release-builds.yml`
that have `if: startsWith(github.ref, 'refs/tags/v')` in them.
They build and deploy docs, copy the changelog to the releases page, and so on.
The script pushes a tag named e.g. `v2022.08.28`,
which triggers the parts of `.github/workflows/release-builds.yml`
that have `if: startsWith(github.ref, 'refs/tags/v')` in them.
They build and deploy docs, copy the changelog to the releases page, and so on.
5. Update `porcupine.wiki` if you added new features that are likely not obvious to users.

If you want, you can also do a release from a branch named `bugfix-release` instead of `main`.
Expand Down
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ highlighting.
![Screenshot.](screenshot.png)

Most important features:

- Syntax highlighting (supports many programming languages
and color themes, extensible)
- Autocompletions when pressing tab
Expand All @@ -27,9 +28,9 @@ Most important features:
- Multiple files can be opened at the same time like tabs in a web browser
- The tabs can be dragged out of the window to open a new Porcupine window conveniently

[Pygments]: https://pygments.org/
[Langserver]: https://langserver.org/
[Editorconfig]: https://editorconfig.org/
[pygments]: https://pygments.org/
[langserver]: https://langserver.org/
[editorconfig]: https://editorconfig.org/
benjamin-kirkbride marked this conversation as resolved.
Show resolved Hide resolved

Porcupine also has [a very powerful plugin
API](https://akuli.github.io/porcupine/), and most of the above features are
Expand Down Expand Up @@ -57,7 +58,7 @@ Open a terminal and run these commands:
porcu

To easily run porcupine again later,
go to *Settings* --> *Porcupine Settings*
go to _Settings_ --> _Porcupine Settings_
and check "Show Porcupine in the desktop menu system".
This makes Porcupine show up in the menu just like any other application.

Expand All @@ -70,19 +71,27 @@ Install Python 3.8 or newer with pip and tkinter somehow.
If you want drag and drop support, also install tkdnd for the Tcl interpreter that tkinter uses.
Then run these commands:

python3 -m venv porcupine-venv
source porcupine-venv/bin/activate
pip install wheel
pip install https://github.com/Akuli/porcupine/archive/v2023.06.27.zip
porcu
```bash
python3 -m pip install -u pipx # if you don't have `pipx` already
pipx install git+https://github.com/Akuli/porcupine.git
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Why do we use pipx for "Other Linux distributions" but not for "Debian-based Linux distributions"?
  • Why pipx install? I thought the whole point of pipx is that you just tell it to run a thing, and you don't have to install anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use pipx for "Other Linux distributions" but not for "Debian-based Linux distributions"?

I didn't notice the Debian section 😅

I thought the whole point of pipx is that you just tell it to run a thing

The point of pipx is it handles the venv for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Akuli AFAIK this is the last thing that needs decided to move on this. Have your concerns been addressed in the other discussions?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to pipx install still feels like a downgrade to me. It isn't any less effort to run Porcupine this way with pipx, but you end up with a venv in a weird / non-obvious place. This means that after trying Porcupine for a few minutes, if you dislike it, you don't know what to delete to undo whatever pipx did. With an explicit venv creation, everything is neatly in one place and it's very obvious how to get rid of Porcupine.

However, the pipx command is useful for people who already have/use/like pipx. Maybe we could show both ways to do this?

porcu # or `porcupine` if you prefer
```

To easily run porcupine again later,
go to *Settings* --> *Porcupine Settings*
go to _Settings_ --> _Porcupine Settings_
and check "Show Porcupine in the desktop menu system".
benjamin-kirkbride marked this conversation as resolved.
Show resolved Hide resolved
This makes Porcupine show up in the menu just like any other application.

To update Porcupine to the latest version:

```bash
pipx install --force git+https://github.com/Akuli/porcupine.git
```

This may nuke your configs, so be sure to back them up if you care about them.
benjamin-kirkbride marked this conversation as resolved.
Show resolved Hide resolved

You can uninstall Porcupine by unchecking "Show Porcupine in the desktop menu system" in the settings
and then deleting `porcupine-venv`.
and then running `pipx uninstall porcupine`.
benjamin-kirkbride marked this conversation as resolved.
Show resolved Hide resolved

### MacOS

Expand Down Expand Up @@ -111,11 +120,13 @@ When installed, you will find Porcupine from the start menu.
See [CHANGELOG.md](CHANGELOG.md).

### Does Porcupine support programming language X?

You will likely get syntax highlighting without any configuring
and autocompletions with a few lines of configuration file editing.
See [the instructions on Porcupine wiki](https://github.com/Akuli/porcupine/wiki/Getting-Porcupine-to-work-with-a-programming-language).

### Help! Porcupine doesn't work.

Please install the latest version.
If it still doesn't work, [let me know by creating an issue on
GitHub](http://github.com/Akuli/porcupine/issues/new).
Expand All @@ -130,25 +141,32 @@ I think because I didn't find other projects named porcupine, but I don't rememb
Originally, Porcupine was named "Akuli's Editor".

### I want an editor that does X, but X is not in the feature list above. Does Porcupine do X?

You can run Porcupine and find out,
or [create an issue on GitHub](https://github.com/Akuli/porcupine/issues/new) and ask.
If you manage to make me excited about X, I might implement it.

### Why did you create a new editor?

Because I can.

### Why did you create a new editor in tkinter?

Because I can.

### How does feature X work?

See [porcupine/](porcupine/)X.py or [porcupine/plugins/](porcupine/plugins/)X.py.

### Why not use editor X?

Because Porcupine is better.

### Is Porcupine based on IDLE?

Of course not. IDLE is an awful mess that you should stay far away from.

### Is Porcupine a toy project or is it meant to be a serious editor?

Porcupine is meant to be a serious editor, in fact you might regret even touching it.
https://www.youtube.com/watch?v=Y3iUoFkDKjU
Loading