-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Import extraction with Rust (#581)
Adds Rust functionality to deptry. For now, the only part that is handled by Rust is the reading for .py files, parsing their AST and extracting the import statements. This PR also gives us a good starting point to potentially replace more parts of deptry with Rust. List of changes: - Adds maturin to build a Python/Rust hybrid project. - Move from Poetry to PDM, so we have PEP-621 compatible metadata. Change backend to maturin. - Adds a 'get_imports_from_py_files' that can be imported in Python as from deptry.rust import get_imports_from_py_files - Minimal changes in the unit tests; most changes are an improvement in the 'column' of detected imports; earlier the column was 0 now it is 8. - We use ABI to build and publish wheels. For an example of a CI/CD run, see here and for the files on test PyPi see [here](the files on test pypi) - Rewrote the entire CI/CD pipeline --------- Co-authored-by: Mathieu Kniewallner <mathieu.kniewallner@gmail.com>
- Loading branch information
1 parent
d25dbde
commit a13add1
Showing
79 changed files
with
2,234 additions
and
805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: 'Setup Python and Rust Environment' | ||
description: 'Set up Python and Rust environment for PDM projects with matrix support' | ||
|
||
inputs: | ||
python-version: | ||
description: 'Python version for setup-python' | ||
required: true | ||
default: 3.11 | ||
target: | ||
description: 'Target architecture for maturin' | ||
required: true | ||
default: 'x86_64' | ||
python-target: | ||
description: 'Target architecture for python installation' | ||
required: true | ||
default: 'x64' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
architecture: ${{ matrix.python-target }} | ||
|
||
- name: Setup Rust toolchain | ||
run: rustup component add clippy rustfmt | ||
shell: bash | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install PDM and dependencies | ||
run: | | ||
python -m pip install pdm | ||
python -m venv .venv | ||
if [ "${{ runner.os }}" = "Windows" ]; then | ||
source .venv/Scripts/Activate | ||
else | ||
source .venv/bin/activate | ||
fi | ||
python -m pip install --upgrade pip | ||
pdm config python.use_venv true | ||
pdm install | ||
shell: bash | ||
|
||
- name: Build and install the project using Maturin | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ inputs.target }} | ||
command: develop | ||
sccache: 'true' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.