Repository navigation
docs(examples): migrate to uv and PEP 723 inline script metadata #705
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
Open
hasansezertasan
wants to merge
15
commits into
python-escpos:master
Choose a base branch
from
hasansezertasan:migrate/uv/examples
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
15b8a29
migrate(uv): migrate examples to use uv and PEP 723 Python Scripts
hasansezertasan ea00355
Update Dockerfile and project files for UV migration
hasansezertasan fe00280
migrate(flask-example): create new example application with Flask and…
hasansezertasan 7b070af
Update examples/barcodes.py
hasansezertasan b714349
Update examples/codepage_tables.py
hasansezertasan db298be
Update examples/qr_code.py
hasansezertasan 84595e9
Update examples/software_barcode.py
hasansezertasan 0dbe43e
Update examples/software_columns.py
hasansezertasan c4a6e8b
Update examples/weather.py
hasansezertasan 3db0931
Merge remote-tracking branch 'origin/master' into pr/hasansezertasan/705
patkan 6538159
format with black
patkan 93cbed9
Merge remote-tracking branch 'origin/master' into migrate/uv/examples
hasansezertasan 1777f07
docs(examples): align flask-example deps with master versions
hasansezertasan 5c06ffe
fix(examples): pass bytes to _raw in codepage_tables
hasansezertasan 0d980b4
ci: re-trigger CI (transient Codecov GPG failure)
hasansezertasan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,23 @@ | ||
| # /// script | ||
| # requires-python = ">=3.12" | ||
| # dependencies = ["python-escpos"] | ||
| # [tool.uv.sources] | ||
| # python-escpos = { path = "../", editable = true } | ||
| # /// | ||
| """Example for printing barcodes.""" | ||
| from escpos.printer import Usb | ||
|
|
||
| # Adapt to your needs | ||
| p = Usb(0x0416, 0x5011, profile="TM-T88II") | ||
|
|
||
| # Print software and then hardware barcode with the same content | ||
| p.barcode("123456", "CODE39", width=2, force_software=True) | ||
| p.text("\n") | ||
| p.text("\n") | ||
| p.barcode("123456", "CODE39") | ||
| def main() -> None: | ||
| """Main function.""" | ||
| p = Usb(0x0416, 0x5011, profile="TM-T88II") | ||
|
|
||
| # Print software and then hardware barcode with the same content | ||
| p.barcode("123456", "CODE39", width=2, force_software=True) | ||
| p.text("\n") | ||
| p.text("\n") | ||
| p.barcode("123456", "CODE39") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Use the official UV image | ||
| FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim | ||
| ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy | ||
|
|
||
| # Set the working directory to /app | ||
| WORKDIR /app | ||
|
|
||
| # Copy the uv.lock file and the pyproject.toml file | ||
| COPY uv.lock pyproject.toml /app/ | ||
|
|
||
| # Install the libcups library and Git, then clean up apt lists | ||
| RUN apt-get update -y && \ | ||
| apt-get install -y libcups2-dev git && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install the dependencies | ||
| RUN uv sync --frozen --no-install-project --no-dev | ||
|
|
||
| # Copy the rest of the application code to the container | ||
| COPY . /app | ||
|
|
||
| # Expose the port the application will run on | ||
| EXPOSE 8080 | ||
|
|
||
| # Set the default command to run the application | ||
| CMD ["uv", "run", "app.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Flask and Python-ESC/POS example | ||
|
|
||
| Simple example on how to use it inside a web service | ||
|
|
||
| ```sh | ||
| docker build . -t flask-example | ||
| docker run --network=host -p 9999:9999 flask-example | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [project] | ||
| name = "flask-example" | ||
| version = "0.1.0" | ||
| description = "Flask and Python-ESC/POS example" | ||
| readme = "README.md" | ||
| requires-python = ">=3.9" | ||
| dependencies = [ | ||
| "platformdirs==4.3.8", | ||
| "argcomplete==3.0.8", | ||
| "blinker==1.6.2", | ||
| "click==8.1.3", | ||
| "Flask==2.3.2", | ||
| "itsdangerous==2.1.2", | ||
| "Jinja2==3.1.6", | ||
| "MarkupSafe==2.1.2", | ||
| "Pillow==10.3.0", | ||
| "pycups==2.0.1", | ||
| "pypng==0.20220715.0", | ||
| "pyserial==3.5", | ||
| "python-barcode==0.14.0", | ||
| "python-escpos==3.0a9", | ||
| "pyusb==1.2.1", | ||
| "PyYAML==6.0", | ||
| "qrcode==7.4.2", | ||
| "six==1.16.0", | ||
| "typing_extensions==4.5.0", | ||
| "Werkzeug==3.0.6", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.