Skip to content

Commit 653486f

Browse files
authored
Pixi (#164)
<!-- ⚠️ This is an open-source repository. Do not share sensitive information. -->
1 parent 5f55ca5 commit 653486f

17 files changed

+14587
-219
lines changed

.flake8

-10
This file was deleted.

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GitHub syntax highlighting
2+
pixi.lock linguist-language=YAML linguist-generated=true

.github/dependabot.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "github-actions"
4-
directory: "/"
3+
- package-ecosystem: github-actions
4+
directory: /
55
schedule:
6-
interval: "weekly"
6+
interval: monthly
77
reviewers:
8-
- "quantco/ci"
8+
- quantco/ci
9+
groups:
10+
gh-actions:
11+
patterns:
12+
- "*"

.github/workflows/ci.yaml

+47-43
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,73 @@ name: CI
22
on: [push]
33

44
jobs:
5-
5+
66
pre-commit-checks:
7-
name: "Linux - pre-commit checks - Python 3.8"
7+
name: "Pre-commit checks"
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout branch
1111
uses: actions/checkout@v4
12+
- name: Set up pixi
13+
uses: prefix-dev/[email protected]
1214
with:
13-
ref: ${{ github.head_ref }}
14-
- name: Install Python 3.8
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: 3.8
18-
- name: Run pre-commit checks
19-
uses: pre-commit/[email protected]
20-
15+
environments: default lint
16+
- name: pre-commit
17+
run: pixi run pre-commit-run --color=always --show-diff-on-failure
2118

2219
unit-tests:
23-
name: "Unit tests - ${{ matrix.OS }} - Python ${{ matrix.PYTHON_VERSION }}"
24-
runs-on: ubuntu-latest
20+
name: "Unit tests"
21+
runs-on: ${{ matrix.os }}
2522
env:
2623
CI: True
2724
strategy:
2825
fail-fast: true
2926
matrix:
30-
PYTHON_VERSION: ['3.9', '3.10', '3.11', '3.12', '3.13']
31-
OS: ['ubuntu-latest', 'windows-latest']
27+
env:
28+
- py39
29+
- py310
30+
- py311
31+
- py312
32+
- py313
33+
- antlr410
34+
- antlr411
35+
- antlr412
36+
- antlr413
37+
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
3238
steps:
3339
- name: Checkout branch
3440
uses: actions/checkout@v4
3541
with:
36-
ref: ${{ github.head_ref }}
37-
- uses: conda-incubator/setup-miniconda@v3
42+
fetch-depth: 0
43+
- name: Set up pixi
44+
uses: prefix-dev/[email protected]
3845
with:
39-
python-version: ${{ matrix.PYTHON_VERSION }}
40-
miniforge-variant: Mambaforge
41-
miniforge-version: 4.11.0-2
42-
use-mamba: true
43-
environment-file: environment.yml
44-
activate-environment: pytsql
45-
- name: Run Unit Tests
46-
shell: bash -l {0}
46+
environments: ${{ matrix.env }}
47+
- name: Run unit tests
4748
run: |
48-
pip install . --no-build-isolation --no-deps --disable-pip-version-check
49-
pytest tests/unit
49+
pixi run -e ${{ matrix.env }} postinstall
50+
pixi run -e ${{ matrix.env }} pytest tests/unit
5051
5152
linux-integration_tests-sqlserver:
52-
name: "Linux - integration tests - Python ${{ matrix.PYTHON_VERSION }} - mssql"
53+
name: "Integration tests"
5354
runs-on: ubuntu-latest
5455
env:
5556
CI: True
5657
strategy:
5758
fail-fast: false
5859
matrix:
59-
PYTHON_VERSION: ['3.9', '3.10', '3.11', '3.12', '3.13']
60+
env:
61+
- py39
62+
- py310
63+
- py311
64+
- py312
65+
- py313
66+
- antlr410
67+
- antlr411
68+
- antlr412
69+
- antlr413
70+
- sa1
71+
- sa2
6072
services:
6173
DB:
6274
image: mcr.microsoft.com/mssql/server:2019-latest
@@ -69,27 +81,19 @@ jobs:
6981
- name: Checkout branch
7082
uses: actions/checkout@v4
7183
with:
72-
ref: ${{ github.head_ref }}
73-
- name: Fetch full git history
74-
run: git fetch --prune --unshallow
75-
- uses: conda-incubator/setup-miniconda@v3
84+
fetch-depth: 0
85+
- name: Set up pixi
86+
uses: prefix-dev/[email protected]
7687
with:
77-
python-version: ${{ matrix.PYTHON_VERSION }}
78-
miniforge-variant: Mambaforge
79-
miniforge-version: 4.11.0-2
80-
use-mamba: true
81-
environment-file: environment.yml
82-
activate-environment: pytsql
88+
environments: ${{ matrix.env }}
8389
- name: Install msodbcsql17 driver
84-
shell: bash -l {0}
8590
run: |
8691
wget https://packages.microsoft.com/ubuntu/20.04/prod/pool/main/m/msodbcsql17/msodbcsql17_17.10.1.1-1_amd64.deb
8792
ACCEPT_EULA=Y sudo apt install ./msodbcsql17_17.10.1.1-1_amd64.deb --allow-downgrades
8893
- name: Wait for SQL Server
8994
timeout-minutes: 1
9095
run: until docker logs "${{ job.services.db.id }}" 2>&1 | grep -q "SQL Server is now ready"; do sleep 10; done
91-
- name: Run Unit Tests
92-
shell: bash -l {0}
96+
- name: Run integration tests
9397
run: |
94-
pip install . --no-build-isolation --no-deps --disable-pip-version-check
95-
pytest --backend=mssql tests/integration
98+
pixi run -e ${{ matrix.env }} postinstall
99+
pixi run -e ${{ matrix.env }} pytest --backend=mssql tests/integration

.github/workflows/update_grammar.yml

+8-16
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,23 @@ jobs:
99
update-grammar:
1010
name: Update TSQL grammar based on antlr4's grammar
1111
runs-on: ubuntu-latest
12-
defaults:
13-
run:
14-
shell: bash -el {0}
1512
steps:
1613
- name: Checkout branch
1714
uses: actions/checkout@v4
1815
with:
19-
ref: ${{ github.head_ref }}
20-
- name: Set up Miniconda
21-
uses: conda-incubator/setup-miniconda@v3
16+
fetch-depth: 0
17+
- name: Set up pixi
18+
uses: prefix-dev/setup-[email protected]
2219
with:
23-
python-version: 3.11
24-
miniforge-variant: Mambaforge
25-
miniforge-version: 4.11.0-2
26-
use-mamba: true
27-
environment-file: environment.yml
20+
environments: grammar
2821
- name: Download ANTLR
2922
working-directory: src/pytsql/grammar
3023
run: wget https://repo1.maven.org/maven2/org/antlr/antlr4/4.13.1/antlr4-4.13.1-complete.jar
3124
- name: Download latest grammar definition and re-generate grammar targets
32-
working-directory: src/pytsql/grammar
33-
run: |
34-
bash helper_generate_grammar_targets.sh antlr4-4.13.1-complete.jar -d
35-
- name: Install package
36-
run: pip install .
25+
run: pixi run update-grammar
26+
- name: Install package (test compilation)
27+
run:
28+
pixi run -e grammar pip install .
3729
- name: Create Pull Request
3830
uses: peter-evans/create-pull-request@v7
3931
with:

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,7 @@ cython_debug/
153153
# and can be added to the global gitignore or merged into this file. For a more nuclear
154154
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
155155
#.idea/
156+
157+
# pixi environments
158+
.pixi
159+
*.egg-info

.pre-commit-config.yaml

+60-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,61 @@
1+
exclude: (^\.pixi)|(^src\/pytsql\/grammar\/)
12
repos:
2-
- repo: https://github.com/Quantco/pre-commit-mirrors-black
3-
rev: 24.4.2
4-
hooks:
5-
- id: black-conda
6-
args:
7-
- --safe
8-
- --target-version=py38
9-
exclude: ^src/pytsql/grammar/
10-
- repo: https://github.com/Quantco/pre-commit-mirrors-ruff
11-
rev: 0.6.2
12-
hooks:
13-
- id: ruff-conda
14-
exclude: ^src/pytsql/grammar/
15-
- repo: https://github.com/Quantco/pre-commit-mirrors-mypy
16-
rev: "1.10.1"
17-
hooks:
18-
- id: mypy-conda
19-
additional_dependencies: [ -c, conda-forge, types-setuptools ]
20-
exclude: ^src/pytsql/grammar/
3+
- repo: local
4+
hooks:
5+
# ensure pixi environments are up to date
6+
# workaround for https://github.com/prefix-dev/pixi/issues/1482
7+
- id: pixi-install
8+
name: pixi-install
9+
entry: pixi install -e default -e lint
10+
language: system
11+
always_run: true
12+
require_serial: true
13+
pass_filenames: false
14+
- id: ruff
15+
name: ruff
16+
entry: pixi run -e lint ruff check --fix --exit-non-zero-on-fix --force-exclude
17+
language: system
18+
types_or: [python, pyi]
19+
require_serial: true
20+
- id: ruff-format
21+
name: ruff-format
22+
entry: pixi run -e lint ruff format --force-exclude
23+
language: system
24+
types_or: [python, pyi]
25+
require_serial: true
26+
- id: mypy
27+
name: mypy
28+
entry: pixi run -e default mypy
29+
language: system
30+
types: [python]
31+
args: ["--ignore-missing-imports", "--scripts-are-modules"]
32+
require_serial: true
33+
# taplo
34+
- id: taplo
35+
name: taplo
36+
entry: pixi run -e lint taplo format
37+
language: system
38+
types: [toml]
39+
# pre-commit-hooks
40+
- id: trailing-whitespace-fixer
41+
name: trailing-whitespace-fixer
42+
entry: pixi run -e lint trailing-whitespace-fixer
43+
language: system
44+
types: [text]
45+
- id: end-of-file-fixer
46+
name: end-of-file-fixer
47+
entry: pixi run -e lint end-of-file-fixer
48+
language: system
49+
types: [text]
50+
- id: check-merge-conflict
51+
name: check-merge-conflict
52+
entry: pixi run -e lint check-merge-conflict --assume-in-merge
53+
language: system
54+
types: [text]
55+
# typos
56+
- id: typos
57+
name: typos
58+
entry: pixi run -e lint typos --force-exclude
59+
language: system
60+
types: [text]
61+
require_serial: true

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,
88

99
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1010

11-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@ Please also have a look at our documentation sections on [usage](https://pytsql.
5757
## Credits
5858

5959
Grammar is based on [antlr4/grammars-v4](https://github.com/antlr/grammars-v4/tree/master/sql/tsql).
60-

docs/source/development.rst

+15-23
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,21 @@ Development
22
===========
33

44

5-
The repository comes with a development environment file. We suggest to use ``conda``
6-
and ``mamba``.
5+
The repository relies on ``pixi`` to manage dependencies. Please make sure you have a running version of `pixi <https://pixi.sh/latest/>`_.
76

8-
In order to get going, you can run
7+
In order to get going, you can run the following
98

10-
::
9+
.. code-block:: bash
1110
1211
# Clone the repository
13-
git clone [email protected]:Quantco/pytsql.git
14-
cd pytsql
15-
16-
# Set up a conda environment with name "pytsql" and activate it.
17-
mamba env create
18-
conda activate pytsql
12+
$ git clone [email protected]:Quantco/pytsql.git
13+
$ cd pytsql
1914
20-
# Set up our pre-commit hooks for black, mypy, isort and flake8.
21-
pre-commit install
15+
# Set up our pre-commit hooks for e.g. black, mypy and ruff.
16+
$ pixi run pre-commit-install
2217
2318
# Install this package in editable mode.
24-
pip install --no-build-isolation -e .
19+
$ pixi run postinstall
2520
2621
2722
Unit tests
@@ -30,11 +25,9 @@ Unit tests
3025
``pytsql`` comes with some unit tests. Provided that the environment has been set
3126
up as illustrated in the previous step, they can be run as such:
3227

33-
::
28+
.. code-block:: bash
3429
35-
conda activate pytsql
36-
cd pytsql
37-
pytest tests/unit/
30+
$ pixi run pytest tests/unit/
3831
3932
4033
Integration tests
@@ -46,18 +39,17 @@ just execute the ``start_mssql.sql`` script provided.
4639

4740
Once the docker container is up and running, you can run the tests:
4841

49-
::
42+
.. code-block:: bash
43+
44+
$ pixi run pytest tests/integration/
5045
51-
conda activate pytsql
52-
cd pytsql
53-
pytest tests/integration/
5446
5547
Add the option ``--backend=mssql-freetds`` to the test command to run the tests using
5648
the ``freetds`` driver.
5749

5850

5951
Grammar
60-
------------------
52+
-------
6153

6254
``pytsql`` relies on parsing the sql script at hand. In order to do so, it uses
6355
`antlr <https://www.antlr.org>`_, a parser generator. ``antlr`` expects grammar files
@@ -71,7 +63,7 @@ To keep the package structure lean, ``pytql`` aims to be in sync with the refere
7163
Therefore, if you want to extend or modify the grammar please consider contributing to the external repository instead.
7264

7365
Update targets
74-
^^^^^^^^^^^^^^^^^
66+
^^^^^^^^^^^^^^
7567

7668
All files in ``pytsql/src/pytsql/grammar/cpp_src/antlr4-cpp-runtime`` are taken directly from
7769
the `ANTLR repository release 4.11.1

0 commit comments

Comments
 (0)