Skip to content

Commit

Permalink
Use .python-version
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jun 6, 2023
1 parent 5064df1 commit 66eb2b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
31 changes: 21 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,40 @@ Please report any harm to [Hynek Schlawack] in any way you find appropriate.

You can (and should) run our test suite using [Nox].
However, you’ll probably want a more traditional environment as well.
We highly recommend to develop using the latest Python release because we try to take advantage of modern features whenever possible.

First create a [virtual environment](https://virtualenv.pypa.io/) so you don't break your system-wide Python installation.
It’s out of scope for this document to list all the ways to manage virtual environments in Python, but if you don’t already have a pet way, take some time to look at tools like [*direnv*](https://hynek.me/til/python-project-local-venvs/), [*virtualfish*](https://virtualfish.readthedocs.io/), and [*virtualenvwrapper*](https://virtualenvwrapper.readthedocs.io/).
First, create a [virtual environment](https://virtualenv.pypa.io/) so you don't break your system-wide Python installation.
We recommend using the Python version from the `.python-version` file in project's root directory.

Next, get an up to date checkout of the *environ-config* repository:
If you're using [*direnv*](https://direnv.net), you can automate the creation of a virtual environment with the correct Python version by adding the following `.envrc` to the project root after cloning it:

```bash
layout python python$(cat .python-version)
```

[Create a fork](https://github.com/hynek/environ-config/fork) of the *structlog* repository and clone it:

```console
$ git clone git@github.com:hynek/environ-config.git
$ git clone git@github.com:YOU/environ-config.git
```

or if you prefer to use *Git* via `https`:
Or if you prefer to use Git via HTTPS:

```console
$ git clone https://github.com/hynek/environ-config.git
$ git clone https://github.com/YOU/environ-config.git
```

Change into the newly created directory and **after activating your virtual environment** install an editable version of *environ-config* along with its tests and docs requirements:
> **Warning**
> - **Before** you start working on a new pull request, use the "*Sync fork*" button in GitHub's web UI to ensure your fork is up to date.
> - **Always create a new branch off `main` for each new pull request.**
> Yes, you can work on `main` in your fork and submit pull requests.
> But this will *inevitably* lead to you not being able to synchronize your fork with upstream and having to start over.
Change into the newly created directory and after activating a virtual environment, install an editable version of *environ-config* along with its tests and docs requirements:

```console
$ cd environ-config
$ pip install --upgrade pip wheel setuptools # PLEASE don't skip this step
$ pip install -e '.[dev]'
$ python -Im pip install --upgrade pip wheel # PLEASE don't skip this step
$ python -Im pip install -e '.[dev]'
```

At this point,
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ env:
FORCE_COLOR: "1" # Make tools pretty.
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
PYTHON_LATEST: "3.11"
SETUPTOOLS_SCM_PRETEND_VERSION: "1.0" # avoid warnings about shallow checkout

# For re-actors/checkout-python-sdist
sdist-artifact: python-package-distributions
sdist-name: environ_config-1.0.tar.gz

# N.B. default Python version for setup-python comes from the .python-version
# file at the root of the project.


permissions:
contents: read

Expand All @@ -30,8 +33,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_LATEST }}
- run: python -Im pip install build

- run: python -Im build --sdist
Expand Down Expand Up @@ -105,9 +106,6 @@ jobs:
source-tarball-name: ${{ env.sdist-name }}
workflow-artifact-name: ${{ env.sdist-artifact }}
- uses: actions/setup-python@v4
with:
# Use latest Python, so it understands all syntax.
python-version: ${{ env.PYTHON_LATEST }}

- run: python -Im pip install --upgrade coverage[toml]

Expand Down Expand Up @@ -188,8 +186,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_LATEST }}

- run: python -Im pip install -e .[dev]
- run: python -c 'import environ; print(environ.__version__)'
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11

0 comments on commit 66eb2b4

Please sign in to comment.