Python learning project by blog posts series 'Hypermodern Python' (by Claudio Jolowicz)
Project description
hotmodern-python
My Python learning project by article series 'Hypermodern Python' (by Claudio Jolowicz)
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)
That's why I modified code like this:
# 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 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).
@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
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:
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:... 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 optionpyenv uninstall 3.12.4 pyenv install 3.12.4 --registerDon't forget to restart your Terminal window (or IDE) to apply these changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hotmodern_python-0.1.2.tar.gz
.
File metadata
- Download URL: hotmodern_python-0.1.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e36f0454e7ee946d3aa848182cbaf59c315ae58baeb0da0a8fca4952cef56d98 |
|
MD5 | 93320b3efb6b9c74c59413465ea1dbc0 |
|
BLAKE2b-256 | 908fa80fe7a145eca44707590f14be196f6f22e6de361c3f37ddb5e34d455b4e |
File details
Details for the file hotmodern_python-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: hotmodern_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de4456aa5af9bd9195ea43cd2f226cf9973d101536c5b900615831570b30e0cc |
|
MD5 | 865ef20233118a9cd8571716807c7c27 |
|
BLAKE2b-256 | ed138af61a2de08130a4524610533bc7f3abd109a185663ffef7265a1243d2c4 |