Skip to content

Commit

Permalink
refactor: remove setup.py and related infrastructure
Browse files Browse the repository at this point in the history
`poetry-core` >= 1.0.8 supporst PEP660 (editable installs)
  • Loading branch information
cpcloud committed Sep 30, 2022
1 parent 33770d8 commit adfcce1
Show file tree
Hide file tree
Showing 16 changed files with 11 additions and 326 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ conda-lock/*.lock linguist-generated=true
nix/sources.json linguist-generated=true
nix/sources.nix linguist-generated=true
poetry.lock linguist-generated=true
setup.py linguist-generated=true
requirements.txt linguist-generated=true
docs/**/*.ipynb linguist-generated=true
35 changes: 3 additions & 32 deletions .github/workflows/check-generated-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,24 @@ name: Check Generated Files
on:
push:
paths:
- ./dev/poetry2setup
- ./dev/poetry2setup.py
- README.md
- poetry.lock
- pyproject.toml
- requirements.txt
- setup.py
- .github/workflows/check-setup-py.yml
- .github/workflows/check-requirements-txt.yml
pull_request:
paths:
- ./dev/poetry2setup
- ./dev/poetry2setup.py
- README.md
- poetry.lock
- pyproject.toml
- requirements.txt
- setup.py
- .github/workflows/check-setup-py.yml
- .github/workflows/check-requirements-txt.yml

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
check_setup_py:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: install nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-unstable-small

- name: setup cachix
uses: cachix/cachix-action@v10
with:
name: ibis
extraPullNames: nix-community,poetry2nix

- name: generate setup.py
run: ./dev/poetry2setup -o setup.py

- name: check whether setup.py needs to be regenerated
run: git diff --exit-code setup.py

check_setuptools_install:
runs-on: ubuntu-latest
steps:
Expand All @@ -69,7 +40,7 @@ jobs:
run: sudo apt-get install -y -q build-essential graphviz krb5-config libkrb5-dev libgeos-dev

- name: install poetry
run: pip install 'poetry<1.2'
run: pip install 'poetry<1.2' 'poetry-core>=1.0.8'

- name: generate requirements.txt
run: poetry export --dev --extras all --without-hashes --no-ansi > requirements.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: Update setup.py
name: Update requirements.txt

on:
pull_request:
paths:
- ./dev/poetry2setup
- ./dev/poetry2setup.py
- pyproject.toml
- poetry.lock

jobs:
generate_setup_py:
generate_requirements_txt:
# this can only run on pull requests made from branches in the main ibis
# repository ano not forks, since the add-and-commit action requires the
# ability to push commits to the PR branch
Expand Down Expand Up @@ -43,9 +41,6 @@ jobs:
name: ibis
extraPullNames: nix-community,poetry2nix

- name: generate setup.py
run: ./dev/poetry2setup -o setup.py

- name: generate requirements.txt
run: nix run -f nix poetry -- export --dev --extras all --without-hashes --no-ansi > requirements.txt

Expand All @@ -57,13 +52,13 @@ jobs:
name: ibis-squawk-bot[bot]
email: ibis-squawk-bot[bot]@users.noreply.github.com

- name: commit setup.py and push to PR
- name: commit requirements.txt and push to PR
run: |
set -euo pipefail
git add setup.py requirements.txt
git add requirements.txt
if git commit -m 'chore(setuptools-files): regenerate'; then
if git commit -m 'chore(requirements.txt): regenerate'; then
# pull in case another commit happened in the meantime
#
# `ours` is actually the *other* changeset, not the current branch, per
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ repos:
rev: v2.38.2
hooks:
- id: pyupgrade
exclude: setup.py
entry: pyupgrade --py38-plus --keep-runtime-typing
types:
- python
Expand Down
1 change: 0 additions & 1 deletion .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ module.exports = {
assets: [
"pyproject.toml",
"docs/release_notes.md",
"setup.py",
"ibis/__init__.py",
],
message: "chore(release): ${nextRelease.version}",
Expand Down
2 changes: 0 additions & 2 deletions ci/release/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ version="${1}"
# set version
poetry version "$version"

./dev/poetry2setup -o setup.py

# build artifacts
poetry build

Expand Down
4 changes: 0 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ let
import ./poetry-overrides.nix
);

preConfigure = ''
rm setup.py
'';

inherit buildInputs checkInputs;

preCheck = ''
Expand Down
2 changes: 1 addition & 1 deletion dev/lockfile_diff.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=channel:nixos-unstable-small --pure -p dyff git poetry yj -i bash
#!nix-shell -I nixpkgs=channel:nixos-unstable --pure -p dyff git poetry yj -i bash
# shellcheck shell=bash

set -euo pipefail
Expand Down
15 changes: 0 additions & 15 deletions dev/poetry2setup

This file was deleted.

55 changes: 0 additions & 55 deletions dev/poetry2setup.py

This file was deleted.

3 changes: 1 addition & 2 deletions dev/update-lock-files.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=channel:nixos-unstable-small --pure -p poetry nix -i bash
#!nix-shell -I nixpkgs=channel:nixos-unstable --pure -p poetry nix -i bash
# shellcheck shell=bash
set -euo pipefail

Expand All @@ -10,5 +10,4 @@ TOP="${1:-$(dirname "$(dirname "$(readlink -f "$0")")")}"
pushd "${TOP}" > /dev/null || exit 1
poetry lock --no-update
poetry export --dev --without-hashes --no-ansi --extras all > "${TOP}/requirements.txt"
"${TOP}/dev/poetry2setup" -o "${TOP}/setup.py"
popd > /dev/null || exit 1
30 changes: 0 additions & 30 deletions docs/contribute/05_maintainers_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,6 @@ cases contributors do not have to remember to generate and commit these files.

1. Edit `pyproject.toml` as needed.
2. Run `poetry lock --no-update`
3. Regenerate `setup.py`:

!!! failure "Do not manually edit `setup.py`"

`setup.py` is [automatically
generated](https://github.com/ibis-project/ibis/blob/master/dev/poetry2setup.py)
from `pyproject.toml`

=== "Nix"

```sh
./dev/poetry2setup -o setup.py
```

=== "Without Nix"

Run the following command

```sh
PYTHONHASHSEED=0 python ./dev/poetry2setup.py -o setup.py
```

!!! question "Why do we need to set `PYTHONHASHSEED`?"

Dependencies' [`extras`](https://python-poetry.org/docs/pyproject/#extras) are stored
in-memory using a `frozenset`, the elements of which are arbitrarily ordered.

As of 2022-02-24 this is [fixed in the default
branch](https://github.com/python-poetry/poetry-core/pull/280) of
[`poetry-core`] but isn't yet released.

Updates of minor and patch versions of dependencies are handled automatically by
[`renovate`](https://github.com/renovatebot/renovate).
Expand Down
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ clean:
lock:
poetry lock --no-update
poetry export --dev --extras all --without-hashes --no-ansi > requirements.txt
PYTHONHASHSEED=0 python dev/poetry2setup.py -o setup.py

# show all backends
@list-backends:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,5 @@ channels = ["conda-forge"]
dask = ">=2021.10.0"

[build-system]
requires = ["poetry-core>=1", "poetry-dynamic-versioning"]
requires = ["poetry-core>=1.0.8", "poetry-dynamic-versioning"]
build-backend = "poetry.core.masonry.api"
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[flake8]
ignore = D202,D203,W503,E203
per-file-ignores =
dev/poetry2setup.py:E265,E501
setup.py:E501
max-line-length = 79

# universal = 1 is for projects that support py2 and py3, and do not have C
Expand Down
Loading

0 comments on commit adfcce1

Please sign in to comment.