Skip to content

Commit

Permalink
feat: move private file .upgraded into .venv/ folder (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenstroeger authored Jul 11, 2022
1 parent ba77a96 commit 2a24e24
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@ jobs:
uses: actions/setup-python@d09bd5e6005b175076f227b13d9730d56e9dcfcb
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: make setup
- name: Create and activate virtual environment
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: |
make venv
source .venv/bin/activate
env:
PYTHON: python
- name: Create and activate virtual environment (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
make venv
.venv/Scripts/Activate.ps1
env:
PYTHON: python
- name: Install dependencies
run: make setup
- name: Build the package
# We don't need to check and test the package separately
# because `make dist` runs those targets first and only
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
language: [python]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
python: ['3.9', '3.10']
python: ['3.10']

steps:
- name: Harden Runner
Expand All @@ -46,11 +46,15 @@ jobs:
uses: actions/setup-python@98f2ad02fd48d057ee3b4d4f66525b231c3e52b6
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: make setup
- name: Create and activate virtual environment
run: |
make venv
source .venv/bin/activate
env:
PYTHON: python

- name: Install dependencies
run: make setup
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@c0982d28099e3cb8fd8b37cfd6c2cdfea4531853
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,3 @@ dmypy.json

# Pyre type checker
.pyre/

# Makefile generated
.upgraded
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# whether this current run of `make` requires a Python virtual environment.
NEED_VENV := $(or \
$(findstring setup,$(MAKECMDGOALS)), \
$(findstring upgrade-quiet,$(MAKECMDGOALS)), \
$(findstring upgrade,$(MAKECMDGOALS)), \
$(findstring requirements,$(MAKECMDGOALS)), \
$(findstring all,$(MAKECMDGOALS)), \
Expand All @@ -20,12 +21,19 @@ else
ifeq ($(origin VIRTUAL_ENV),undefined)
$(warning No Python virtual environment found, proceeding anyway)
else
ifeq ($(wildcard .upgraded),)
ifeq ($(wildcard .venv/upgraded-on),)
$(warning Python virtual environment not yet set up, proceeding anyway)
endif
endif
endif

# If the project configuration file has been updated (package deps or
# otherwise) then warn the user and suggest resolving the conflict.
ifeq ($(shell test pyproject.toml -nt .venv/upgraded-on; echo $$?),0)
$(warning pyproject.toml was updated, consider `make upgrade` if your packages have changed)
$(warning If this is not correct then run `make upgrade-quiet`)
endif

# Create a virtual environment, either for Python3.10 (default) or using
# the Python interpreter specified in the PYTHON environment variable.
.PHONY: venv
Expand Down Expand Up @@ -53,14 +61,16 @@ setup: force-upgrade
# Install or upgrade an existing virtual environment based on the
# package dependencies declared in pyproject.toml.
.PHONY: upgrade force-upgrade
upgrade: .upgraded
.upgraded: pyproject.toml
upgrade: .venv/upgraded-on
.venv/upgraded-on: pyproject.toml
python -m pip install --upgrade pip
python -m pip install --upgrade --upgrade-strategy eager --editable .[hooks,dev,test,docs]
echo "Automatically generated by Python Package Makefile." > .upgraded
$(MAKE) upgrade-quiet
force-upgrade:
rm -f .upgraded
rm -f .venv/upgraded-on
$(MAKE) upgrade
upgrade-quiet:
echo "Automatically generated by Python Package Makefile on `date --rfc-3339=seconds`." > .venv/upgraded-on

# Generate a requirements.txt file containing version and integrity
# hashes for all packages currently installed in the virtual environment.
Expand Down Expand Up @@ -96,7 +106,7 @@ test:

# Build a source distribution package and a binary wheel distribution artifact.
.PHONY: dist
ifeq ($(wildcard .upgraded),)
ifeq ($(wildcard .venv/upgraded-on),)
PACKAGE_VERSION=unknown
else
PACKAGE_VERSION=$(shell python -c 'import package; print(package.__version__)')
Expand Down Expand Up @@ -133,4 +143,4 @@ nuke: nuke-caches
rm -fr $(VIRTUAL_ENV); \
fi
rm -fr src/package.egg-info/
rm -f requirements.txt .upgraded
rm -f requirements.txt

0 comments on commit 2a24e24

Please sign in to comment.