Skip to content

Commit

Permalink
python: Remove pipenv (#45)
Browse files Browse the repository at this point in the history
* FIX: cucumber-tag-expression in some places.

* Makefile mechanism currently patch only the version in "setup.py"
* Other file locations are described in ".bumpversion.cfg" file.

* PYTHON: Simplify project environment setup with "direnv".

If "dotenv" is setup for the shell:

* On entering this directory: Setup environemnt variables.
* On leaving  this directory: Restore the former environemnt state.

PREPARED (but: .envrc.*.disabled):
* use_venv: Auto-create virtual-environment and activate it.
* use_pep0528: Use PEP-0528 "__pypackages__/$(PYTHON_VERSION)/" directory.

To enable each part, just removed the ".disabled" suffix.
EXAMPLE: Rename ".envrc.use_venv.disabled" to ".envrc.use_venv".

* PYTHON: setup: Fix some hyperlinks

* FIX: Old, broken hyperlinks
* Update Python package dependencies
* Cleanup and reorganize some stuff

* PYTHON: Remove the use of "pipenv"

* Use "pip" instead of "pipenv"
  HINT: "pipenv" caused multiple problems in the CI build in the past.
* Newer versions of "pip" support install under $HOME directory.
  NOTE: This works without "sudo" and is currently preferred.
* If an virtual-environment was activated, before using "make",
  the Python packages are installed into the virtual-environemnt.

REFACTORING AND CLEANUP (of: Makefile)
* Improve readability and simplify functionality.

* PYTHON: Fix the CI build badge

github-actions is used as CI build system.
Therefore, use the badge for tests passing from this CI.
WAS: Still using the CircleCI badge before.

* PYTHON: Update the developer docs.

Update the "DEVELOPMENT.rst" file to reflect the changed
build procedures and workflow steps.

* PYTHON: Try to fix "tox" for Python 2.7

* Seems to broken due to "pip"
* Remove "py27" from "envlist" for now.

NOTES:
* Can still create a virtual-environment for Python 2.7
* Can still run the tests in virtual-environment
* Added more scripts to simplify setup of virtual-environment

CLEANUP: In Makefile, invoke
* Remove get-pip.py

* PYTHON: FIX dependency for "bandit"

* Only support for python.version >= 3.7

* PYTHON: Use invoke_cleanup

* Improved version of "tasks/_tasklet_cleanup.py"
* On cleanup/cleanup.all:
  Skips SUICIDE of own virtual-encironment should be deleted.
  • Loading branch information
jenisys authored Mar 14, 2022
1 parent 3283468 commit aa66050
Show file tree
Hide file tree
Showing 26 changed files with 871 additions and 473 deletions.
2 changes: 1 addition & 1 deletion python/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.0.2
current_version = 4.1.0
files = setup.py cucumber_tag_expressions/__init__.py .bumpversion.cfg pytest.ini
commit = False
tag = False
Expand Down
28 changes: 28 additions & 0 deletions python/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ===========================================================================
# PROJECT ENVIRONMENT SETUP: tag-expressions/python/.envrc
# ===========================================================================
# SHELL: bash (or similiar)
# USAGE:
# # -- BETTER: Use direnv (requires: Setup in bash -- $HOME/.bashrc)
# # BASH PROFILE NEEDS: eval "$(direnv hook bash)"
# direnv allow .
#
# SIMPLISTIC ALTERNATIVE (without cleanup when directory scope is left again):
# source .envrc
#
# SEE ALSO:
# * https://direnv.net/
# * https://peps.python.org/pep-0582/ Python local packages directory
# ===========================================================================
# MAYBE: HERE="${PWD}"

# -- USE OPTIONAL PARTS (if exist/enabled):
dotenv_if_exists .env
source_env_if_exists .envrc.use_venv
source_env_if_exists .envrc.use_pep0582

# -- SETUP-PYTHON: Prepend ${HERE} to PYTHONPATH (as PRIMARY search path)
# SIMILAR TO: export PYTHONPATH="${HERE}:${PYTHONPATH}"
path_add PYTHONPATH .

source_env_if_exists .envrc.override
25 changes: 25 additions & 0 deletions python/.envrc.use_pep0582.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ===========================================================================
# PROJECT ENVIRONMENT SETUP: tag-expressions/python/.envrc.use_pep0582
# ===========================================================================
# DESCRIPTION:
# Setup Python search path to use the PEP-0582 sub-directory tree.
#
# SEE ALSO:
# * https://direnv.net/
# * https://peps.python.org/pep-0582/ Python local packages directory
# ===========================================================================

if [ -z "${PYTHON_VERSION}" ]; then
# -- AUTO-DETECT: Default Python3 version
# EXAMPLE: export PYTHON_VERSION="3.9"
export PYTHON_VERSION=$(python3 -c "import sys; print('.'.join([str(x) for x in sys.version_info[:2]]))")
fi
echo "USE: PYTHON_VERSION=${PYTHON_VERSION}"

# -- HINT: Support PEP-0582 Python local packages directory (supported by: pdm)
path_add PATH __pypackages__/${PYTHON_VERSION}/bin
path_add PYTHONPATH __pypackages__/${PYTHON_VERSION}/lib

# -- SIMILAR-TO:
# export PATH="${HERE}/__pypackages__/${PYTHON_VERSION}/bin:${PATH}"
# export PYTHONPATH="${HERE}:${HERE}/__pypackages__/${PYTHON_VERSION}/lib:${PYTHONPATH}"
17 changes: 17 additions & 0 deletions python/.envrc.use_venv.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ===========================================================================
# PROJECT ENVIRONMENT SETUP: tag-expressions/python/.envrc.use_venv
# ===========================================================================
# DESCRIPTION:
# Setup and use a Python virtual environment (venv).
# On entering the directory: Creates and activates a venv for a python version.
# On leaving the directory: Deactivates the venv (virtual environment).
#
# SEE ALSO:
# * https://direnv.net/
# * https://github.com/direnv/direnv/wiki/Python
# * https://direnv.net/man/direnv-stdlib.1.html#codelayout-python-ltpythonexegtcode
# ===========================================================================

# -- VIRTUAL ENVIRONMENT SUPPORT: layout python python3
# VENV LOCATION: .direnv/python-$(PYTHON_VERSION)
layout python python3
4 changes: 3 additions & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.egg-info
*.log
*.lock
*.pyc
*.pyo
*$py.class
Expand All @@ -9,6 +10,7 @@ downloads/
__pycache__/
__*/
.cache/
.direnv/
.eggs/
.hypothesis/
.idea/
Expand All @@ -18,5 +20,5 @@ __*/
.DS_Store
.coverage
.deps
.pdm.toml
.tested
Pipfile.lock
Loading

0 comments on commit aa66050

Please sign in to comment.