[![PyPI](https://img.shields.io/pypi/v/hotmodern-python.svg)](https://pypi.org/project/hotmodern-python/)
[![Tests](https://github.com/hotenov/hotmodern-python/actions/workflows/tests.yml/badge.svg)](https://github.com/hotenov/hotmodern-python/actions/workflows/tests.yml)
[![codecov.io](https://codecov.io/github/hotenov/hotmodern-python/coverage.svg?branch=main)](https://codecov.io/github/hotenov/hotmodern-python/coverage.svg?branch=main)
[![Docs](https://readthedocs.org/projects/hotmodern-python/badge/?version=latest)](https://hotmodern-python.readthedocs.io/en/latest/?badge=latest)
[![Nox](https://img.shields.io/badge/%F0%9F%A6%8A-Nox-D85E00.svg)](https://github.com/wntrblm/nox)
# hotmodern-python
My Python learning project by article series '[Hypermodern Python](https://cjolowicz.github.io/posts/)' (by [Claudio Jolowicz](https://github.com/cjolowicz))
This repo 98% repeats code from these articles
with little improvements for Windows environment *(see below)*
and except several components
(pre-commit, pytype, typeguard, Release Drafter)
## Notes for Windows host
**Updated:** 2024-08-05
### Functions with temp file on Windows
Windows has security limitation for temp files:
OS does not allow processes other than the one used to create the NamedTemporaryFile to access the file
([from here](https://github.com/bravoserver/bravo/issues/111#issuecomment-826990))
That's why I modified code like this:
```python
# noxfile.py
import pathlib
def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None:
"""Install packages constrained by Poetry's lock file."""
with tempfile.NamedTemporaryFile(delete=False) as requirements:
session.run(
"poetry",
"export",
...
)
session.install("-r", f"{requirements.name}", *args, **kwargs)
pathlib.Path(requirements.name).unlink()
```
### Run Nox sessions with pyenv's Python versions
On Windows I use [pyenv-win](https://github.com/pyenv-win/pyenv-win)
for managing Python interpreter versions.
If you set up `pyenv-win` correctly,
it lets you run your session against multiple interpreters by specifying
`python` to `@nox.session`
(and run sessions the same way as on Linux machines).
```python
@nox.session(python=["3.11", "3.12"], reuse_venv=True)
def tests(session: Session) -> None:
...
```
**The main thing** you should do is setting paths to Python interpreters
in the right order in your `PATH` environment variable on Windows.
I wrote a detailed tutorial on their wiki page
[Configure the order in PATH variable](https://github.com/pyenv-win/pyenv-win/wiki#configure-the-order-in-path-variable)
But to avoid many problems related to discover a Python interpreter version,
**you also have to add paths for all installed versions of Python**
"below" *(after)* path to `...\pyenv-win\shims`
For example your PATH might look as:
```plain
D:\python_tools\.pyenv\pyenv-win\bin
D:\python_tools\.pyenv\pyenv-win\shims\
D:\python_tools\.pyenv\pyenv-win\versions\3.8.10
D:\python_tools\.pyenv\pyenv-win\versions\3.9.13
D:\python_tools\.pyenv\pyenv-win\versions\3.10.8
D:\python_tools\.pyenv\pyenv-win\versions\3.11.2
D:\python_tools\.pyenv\pyenv-win\versions\3.12.4
```
> [!IMPORTANT]
> If you encountered with Nox error:
>
> ```plain
> ... failed with exit code 1:
> PEP-514 violation in Windows Registry at HKEY_CURRENT_USER/PythonCore/...
> ```
>
> for modern Python 3.12+ you must reinstall this version with `--register` CLI option
>
> ```plain
> pyenv uninstall 3.12.4
> pyenv install 3.12.4 --register
> ```
>
> Don't forget to restart your Terminal window (or IDE) to apply these changes.
Raw data
{
"_id": null,
"home_page": "https://github.com/hotenov/hotmodern-python",
"name": "hotmodern-python",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "hypermodern",
"author": "Artem Hotenov",
"author_email": "artem@hotenov.com",
"download_url": "https://files.pythonhosted.org/packages/90/8f/a80fe7a145eca44707590f14be196f6f22e6de361c3f37ddb5e34d455b4e/hotmodern_python-0.1.2.tar.gz",
"platform": null,
"description": "[![PyPI](https://img.shields.io/pypi/v/hotmodern-python.svg)](https://pypi.org/project/hotmodern-python/)\n[![Tests](https://github.com/hotenov/hotmodern-python/actions/workflows/tests.yml/badge.svg)](https://github.com/hotenov/hotmodern-python/actions/workflows/tests.yml)\n[![codecov.io](https://codecov.io/github/hotenov/hotmodern-python/coverage.svg?branch=main)](https://codecov.io/github/hotenov/hotmodern-python/coverage.svg?branch=main)\n[![Docs](https://readthedocs.org/projects/hotmodern-python/badge/?version=latest)](https://hotmodern-python.readthedocs.io/en/latest/?badge=latest)\n[![Nox](https://img.shields.io/badge/%F0%9F%A6%8A-Nox-D85E00.svg)](https://github.com/wntrblm/nox)\n\n# hotmodern-python\n\nMy Python learning project by article series '[Hypermodern Python](https://cjolowicz.github.io/posts/)' (by [Claudio Jolowicz](https://github.com/cjolowicz))\n\nThis repo 98% repeats code from these articles\nwith little improvements for Windows environment *(see below)*\nand except several components\n(pre-commit, pytype, typeguard, Release Drafter)\n\n## Notes for Windows host\n\n**Updated:** 2024-08-05\n\n### Functions with temp file on Windows\n\nWindows has security limitation for temp files:\nOS does not allow processes other than the one used to create the NamedTemporaryFile to access the file\n([from here](https://github.com/bravoserver/bravo/issues/111#issuecomment-826990))\n\nThat's why I modified code like this:\n\n```python\n# noxfile.py\nimport pathlib\n\ndef install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None:\n \"\"\"Install packages constrained by Poetry's lock file.\"\"\"\n with tempfile.NamedTemporaryFile(delete=False) as requirements:\n session.run(\n \"poetry\",\n \"export\",\n ...\n )\n session.install(\"-r\", f\"{requirements.name}\", *args, **kwargs)\n pathlib.Path(requirements.name).unlink()\n```\n\n### Run Nox sessions with pyenv's Python versions\n\nOn Windows I use [pyenv-win](https://github.com/pyenv-win/pyenv-win)\nfor managing Python interpreter versions.\n\nIf you set up `pyenv-win` correctly,\nit lets you run your session against multiple interpreters by specifying\n`python` to `@nox.session`\n(and run sessions the same way as on Linux machines).\n\n```python\n@nox.session(python=[\"3.11\", \"3.12\"], reuse_venv=True)\ndef tests(session: Session) -> None:\n...\n```\n\n**The main thing** you should do is setting paths to Python interpreters\nin the right order in your `PATH` environment variable on Windows. \nI wrote a detailed tutorial on their wiki page\n[Configure the order in PATH variable](https://github.com/pyenv-win/pyenv-win/wiki#configure-the-order-in-path-variable) \nBut to avoid many problems related to discover a Python interpreter version,\n**you also have to add paths for all installed versions of Python**\n\"below\" *(after)* path to `...\\pyenv-win\\shims`\nFor example your PATH might look as:\n\n```plain\nD:\\python_tools\\.pyenv\\pyenv-win\\bin\nD:\\python_tools\\.pyenv\\pyenv-win\\shims\\\nD:\\python_tools\\.pyenv\\pyenv-win\\versions\\3.8.10\nD:\\python_tools\\.pyenv\\pyenv-win\\versions\\3.9.13\nD:\\python_tools\\.pyenv\\pyenv-win\\versions\\3.10.8\nD:\\python_tools\\.pyenv\\pyenv-win\\versions\\3.11.2\nD:\\python_tools\\.pyenv\\pyenv-win\\versions\\3.12.4\n```\n\n> [!IMPORTANT] \n> If you encountered with Nox error:\n>\n> ```plain\n> ... failed with exit code 1: \n> PEP-514 violation in Windows Registry at HKEY_CURRENT_USER/PythonCore/...\n> ```\n>\n> for modern Python 3.12+ you must reinstall this version with `--register` CLI option\n>\n> ```plain\n> pyenv uninstall 3.12.4\n> pyenv install 3.12.4 --register\n> ```\n>\n> Don't forget to restart your Terminal window (or IDE) to apply these changes.\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Python learning project by blog posts series 'Hypermodern Python' (by Claudio Jolowicz)",
"version": "0.1.2",
"project_urls": {
"Documentation": "https://hotmodern-python.readthedocs.io",
"Homepage": "https://github.com/hotenov/hotmodern-python",
"Repository": "https://github.com/hotenov/hotmodern-python"
},
"split_keywords": [
"hypermodern"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ed138af61a2de08130a4524610533bc7f3abd109a185663ffef7265a1243d2c4",
"md5": "865ef20233118a9cd8571716807c7c27",
"sha256": "de4456aa5af9bd9195ea43cd2f226cf9973d101536c5b900615831570b30e0cc"
},
"downloads": -1,
"filename": "hotmodern_python-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "865ef20233118a9cd8571716807c7c27",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 5563,
"upload_time": "2024-08-05T14:03:05",
"upload_time_iso_8601": "2024-08-05T14:03:05.570329Z",
"url": "https://files.pythonhosted.org/packages/ed/13/8af61a2de08130a4524610533bc7f3abd109a185663ffef7265a1243d2c4/hotmodern_python-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "908fa80fe7a145eca44707590f14be196f6f22e6de361c3f37ddb5e34d455b4e",
"md5": "93320b3efb6b9c74c59413465ea1dbc0",
"sha256": "e36f0454e7ee946d3aa848182cbaf59c315ae58baeb0da0a8fca4952cef56d98"
},
"downloads": -1,
"filename": "hotmodern_python-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "93320b3efb6b9c74c59413465ea1dbc0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 4847,
"upload_time": "2024-08-05T14:03:06",
"upload_time_iso_8601": "2024-08-05T14:03:06.897059Z",
"url": "https://files.pythonhosted.org/packages/90/8f/a80fe7a145eca44707590f14be196f6f22e6de361c3f37ddb5e34d455b4e/hotmodern_python-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-05 14:03:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hotenov",
"github_project": "hotmodern-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hotmodern-python"
}