Skip to content

RyanSkraba/python-enchiridion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Python Enchiridion

Python Server CI

Enchiridion: A small manual or handbook. It's a bit like a tech cook book, but a bigger, fancier, SEO-optimizabler word.

Links to python resources, examples, setup and temporary scripts.

Building and running

# Setting up and using virtualenv.
python -m venv env/
source env/bin/activate
pip install --upgrade pip

./setup.py test

# Create a distribution
pip install wheel
./setup.py sdist bdist_wheel

# Install from repo
./setup.py install

# Or install from wheel
pip install dist/python_scripts-*.whl

# After installing, you can run the script.

# Print usage instructions
hello-world --help

# Run a server.
hello-world                 # prints Hello, World!
hello-world --name=comrade  # prints Hello, comrade!

Testing and automation

Black: The uncompromising code formatter

pip install black
black bin/* scanscan/ tests/ setup.py 

Flake8: Your Tool For Style Guide Enforcement

pip install flake8
flake8 bin/* scanscan/ tests/ setup.py

Nose is nicer testing for python

Nose appears to be unmaintained since 2016.

pip install nose
nosetests -v

pytest helps you write better programs

pip install pytest
pytest -v

Tox: standardize testing in Python

See tox.ini.

pip install tox
tox --skip-missing-interpreters

IntelliJ setup

Running in docker

docker run -it --volume $PWD:/opt/workdir --workdir /opt/workdir python:3.6 bash

Syntax and best practices

Standard modules

[PEP 557]: https://peps.python.org/pep-0557/ [PEP 557 - Data Classes]

Project packaging and setup

How do you set up a project again? What are all of those files for?

Files:

  • .gitignore: Lots of examples of temporary and build files generated during the software lifecycle.
  • LICENSE (ASL-2): How you want your software used and distributed. See also setup.py
  • MANIFEST.in: Files included in the source distribution
  • README.md: This file, used in github but also in the distributed package.
  • setup.py : Build python projects.
  • tox.ini : Used for coordinating builds and tests with tox.

PyPI (the Python package index)

You can create a PyPI mirror like this:

# In one virtual env, download a package and put it in the mirror.
pip install piprepo
pip download --destination-directory /tmp/cache avro-python3==1.9.2 # Fails
pip download --destination-directory /tmp/cache avro-python3==1.9.2.1 
pip download --destination-directory /tmp/cache avro-python3==1.10.0 
pip download --destination-directory /tmp/cache avro-python3==1.10.1 
pip download --destination-directory /tmp/cache avro-python3==1.10.2 
pip download --destination-directory /tmp/cache avro-python3
pip download --destination-directory /tmp/cache wheel
pip download --destination-directory /tmp/cache pycodestyle
piprepo build /tmp/cache/
# The directory is now a cache of all the Avro packages

# In any other virtualenv, use the mirror.
pip install -i file:///tmp/cache/simple --force-reinstall avro-python3

# Or use a docker to isolate the installation.
docker run -it -v /tmp/cache/:/tmp/cache --network none python:3 \
    pip install -i file:///tmp/cache/simple --force-reinstall avro-python3

About

Python links, examples and temporary scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages