Skip to content

Commit 744e771

Browse files
authored
uversion (#6)
* Preparing files for V2 using uv and taskipy instead of poetry and poe * fix docs * Fix main return type
1 parent c5389c6 commit 744e771

File tree

11 files changed

+877
-1465
lines changed

11 files changed

+877
-1465
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
Python template with some awesome tools to quickstart a Python project with the industry best practices.
6464
It includes automatic generation of API documentation, tests using PyTest, code coverage,
65-
ruff linting to enforce standardized Python coding, virtual environments using Poetry, workflow automation using Poe the Poet,
65+
ruff linting to enforce standardized Python coding, virtual environments using UV, workflow automation using Taskipy,
6666
code formatting using black and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers.
6767

6868
You only need to install [Cookiecutter](https://cookiecutter.readthedocs.io/en/1.7.2/usage.html)!
@@ -91,15 +91,15 @@ This Project depends on the following projects.
9191
cookiecutter https://github.com/nullhack/python-project-template
9292
# move into your newly created project folder
9393
```
94-
2. Install Poe the Poet and Poetry
94+
2. Install UV and Taskipy
9595
```sh
96-
pip install --user --upgrade poethepoet poetry
96+
pip install --user --upgrade uv taskipy
9797
```
98-
3. Let Poe do it's magic
98+
3. Let Taskipy do it's magic
9999
```sh
100-
poe install-dev
101-
poe test
102-
poe run
100+
uv pip install .[dev]
101+
uv task test
102+
uv task run
103103
```
104104

105105
<p align="right">(<a href="#top">back to top</a>)</p>
@@ -162,6 +162,7 @@ This project was heavily based on some great references.
162162
* [Best practices for Python projects in 2021](https://mitelman.engineering/blog/python-best-practice/automating-python-best-practices-for-a-new-project/)
163163
* [5 Pytest Best Practices for Writing Great Python Tests](https://www.nerdwallet.com/blog/engineering/5-pytest-best-practices/)
164164
* [Best-README-Template](https://github.com/othneildrew/Best-README-Template)
165+
* [Beyond Hypermodern: Python is easy now](https://rdrn.me/postmodern-python/)
165166

166167
<p align="right">(<a href="#top">back to top</a>)</p>
167168

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
11
ARG BUILDPLATFORM=linux/amd64
2-
ARG BUILDTAG=3-alpine
32

4-
FROM --platform=$BUILDPLATFORM python:$BUILDTAG as test
3+
FROM --platform=$BUILDPLATFORM python:3-alpine as test
54

65
WORKDIR /home/user/app
76

87
ENV PATH=$PATH:/home/user/.local/bin
98

10-
RUN pip install --no-cache poetry poethepoet
11-
RUN poetry config --no-cache
12-
COPY pyproject.toml .
13-
COPY poetry.lock .
14-
RUN poetry install --no-root
9+
RUN apk add --no-cache build-base linux-headers
10+
RUN pip install --no-cache uv taskipy
1511

1612
COPY ./ ./
17-
RUN poetry install
13+
14+
RUN pip install -e '.[dev]'
1815

1916
ARG TESTBUILD=True
2017
ENV TESTBUILD=$TESTBUILD
21-
RUN if [ "$TESTBUILD" = 'True' ]; then poe lint; fi
22-
RUN if [ "$TESTBUILD" = 'True' ]; then poe test; fi
18+
RUN if [ "$TESTBUILD" = 'True' ]; then task lint; fi
19+
RUN if [ "$TESTBUILD" = 'True' ]; then task test; fi
2320

24-
RUN poetry build --format=wheel
25-
RUN poetry export --only main -f requirements.txt --without-hashes --output requirements.txt
21+
RUN uv build --wheel --out-dir dist
2622

27-
ENTRYPOINT ["poe", "-q"]
28-
CMD ["test"]
23+
CMD ["task", "test"]
2924

30-
FROM --platform=$BUILDPLATFORM python:$BUILDTAG as prod
25+
FROM --platform=$BUILDPLATFORM python:3-alpine as prod
3126

3227
RUN addgroup --system user && adduser --system user --ingroup user
3328
USER user
3429

3530
WORKDIR /home/user/app
3631

37-
COPY --chown=user:user --from=test /home/user/app/requirements.txt requirements.txt
3832
COPY --chown=user:user --from=test /home/user/app/dist dist
3933

40-
USER root
41-
RUN pip install --no-cache -r requirements.txt dist/*.whl
42-
USER user
34+
RUN pip install --no-cache dist/*.whl
4335

44-
ENTRYPOINT ["python", "-m", "{{cookiecutter.package_name}}.{{cookiecutter.module_name}}"]
36+
CMD ["python", "-m", "{{cookiecutter.package_name}}.{{cookiecutter.module_name}}"]
4537

{{cookiecutter.project_slug}}/README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ To run this project locally, you will need to install the prerequisites and foll
7676
### Prerequisites
7777

7878
This Project depends on the following projects.
79-
* Poetry
79+
* UV
8080
```sh
81-
pip install --user --upgrade poetry
81+
pip install --user --upgrade uv
8282
```
8383

84-
* Poe the Poet
84+
* Taskipy
8585
```sh
86-
pip install --user --upgrade poethepoet
86+
pip install --user --upgrade taskipy
8787
```
8888

8989
### Installation
@@ -93,17 +93,17 @@ This Project depends on the following projects.
9393
git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}
9494
cd {{cookiecutter.project_slug}}
9595
```
96-
2. Install Poe the Poet and Poetry
96+
2. Install UV and taskipy
9797
```sh
98-
pip install --user --upgrade poethepoet poetry
98+
pip install --user --upgrade uv taskipy
9999
```
100100
3. Install requirements for development
101101
```sh
102-
poe install-dev
102+
uv pip install '.[dev]'
103103
```
104104
4. Run tests
105105
```sh
106-
poe test
106+
uv run task test
107107
```
108108

109109
<p align="right">(<a href="#top">back to top</a>)</p>
@@ -117,34 +117,34 @@ Some useful examples of how this project can be used:
117117

118118
* Install requirements
119119
```sh
120-
poe install-dev
120+
uv run task '.[dev]'
121121
```
122122

123123
* Run tests
124124
```sh
125-
poe test
125+
uv run task test
126126
```
127127

128128
* Run the project
129129
```sh
130-
poe run
130+
uv run main.py
131131
```
132132

133133
* Generate API documentation
134134
```sh
135-
poe doc
135+
uv run task doc-html
136136
```
137137

138138
* Build a docker image for tests
139139
```sh
140-
poe docker-build --target test --build-tag 3.10-alpine
141-
docker run -ti --rm {{cookiecutter.package_name}}:test-3.10-alpine
140+
docker build --target test -t {{cookiecutter.package_name}}:test
141+
docker run -ti --rm {{cookiecutter.package_name}}:test
142142
```
143143

144144
* Build a docker image to run the root files only without running any test
145145
```sh
146-
poe docker-build --target prod --build-tag 3.10-alpine --no-test
147-
docker run -ti --rm {{cookiecutter.package_name}}:prod-3.10-alpine
146+
docker build --target prod -t {{cookiecutter.package_name}}:prod
147+
docker run -ti --rm {{cookiecutter.package_name}}:prod
148148
```
149149

150150

@@ -160,7 +160,7 @@ _For more examples, please refer to the [Documentation](https://{{cookiecutter.g
160160
- [x] Add tests
161161
- [x] Add code coverage
162162
- [x] Improve documentation
163-
- [ ] Include more tests
163+
- [ ] Watch for new best standards
164164

165165
See the [open issues](https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/issues) for a full list of proposed features (and known issues).
166166

@@ -198,7 +198,7 @@ Project Link: [https://github.com/{{cookiecutter.github_username}}/{{cookiecutte
198198
<!-- ACKNOWLEDGMENTS -->
199199
## Acknowledgments
200200

201-
This project was created using cookiecutter and NullHack's python-project-template:
201+
This project was created using cookiecutter and Nullhack's python-project-template:
202202

203203
* [NullHack's python-project-template](https://github.com/nullhack/python-project-template/)
204204

{{cookiecutter.project_slug}}/docs/docs/tests.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

{{cookiecutter.project_slug}}/docs/mkdocs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ nav:
4444
- ... | glob=readme.md
4545
- reference.md
4646
- ... | regex=scenarios/.+.md
47-
- tests.md

{{cookiecutter.project_slug}}/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Test main file."""
2+
3+
import logging
4+
5+
logger = logging.Logger(__name__)
6+
sh = logging.StreamHandler()
7+
sh.setLevel(logging.INFO)
8+
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
9+
sh.setFormatter(formatter)
10+
logger.addHandler(sh)
11+
12+
13+
def main() -> None:
14+
"""Just a main function."""
15+
logger.info("Hello from python-project-uv!")
16+
17+
18+
if __name__ == "__main__":
19+
main()

0 commit comments

Comments
 (0)