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 and except several components (pre-commit, typeguard)
Notes for Windows host
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(f"--constraint={requirements.name}", *args, **kwargs)
pathlib.Path(requirements.name).unlink()
Run Nox sessions with pyenv's Python versions
Option A
Use Nox CLI argument --extra-pythons
and full paths to desired version of Python interpreter
Example:
nox --extra-pythons "C:\users\winfan\.pyenv\pyenv-win\versions\3.8.2\python.exe" "C:\users\winfan\.pyenv\pyenv-win\versions\3.9.2\python.exe"
will run all sessions with Python specified in noxfile.py (or skip if not found)
and with all Pythons passed in this command.
See detailed explanation how --extra-pythons
and --extra-python
works from Claudio Jolowicz himself
Option B
Create separate noxfile for local execution. Duplicate all sessions and change python versions like this:
# noxfile.local.py
@nox.session(
python=[
r"C:\users\winfan\.pyenv\pyenv-win\versions\3.8.2\python.exe",
r"C:\users\winfan\.pyenv\pyenv-win\versions\3.9.2\python.exe",
],
reuse_venv=True,
)
Then run command in your Terminal nox -f noxfile.local.py
Don't forget to add this file to .gitignore
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
Hashes for hotmodern_python-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca0ee312148d8a14c1d110ebfc0dc829816263fc2ddd9b39d6faa95af1633c0f |
|
MD5 | 9e0953505b0b1abde15e5be2131ba2d0 |
|
BLAKE2b-256 | d67927c88e294e96dbade612955bc5a6f3c6c433475720f34c36df7b77e7848a |