Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
FROM mcr.microsoft.com/devcontainers/python:3.13-bullseye@sha256:735ecc489de65d36b6ac4e8e5e37287cb30711bac0dd292770bf5347228c438e
FROM mcr.microsoft.com/devcontainers/python:3.13-trixie@sha256:c3a082525f51bb81e3d952d5ec12c2bed3525179a45ef3a09d48993ebc871133

# Install dependencies
# pv is required for asciicasts
RUN apt-get update && apt-get install --no-install-recommends -y \
ccache=4.2-1 \
pv=1.6.6-1+b1 \
patchelf=0.12-1 \
subversion=1.14.1-3+deb11u2 && \
ccache=4.11.2-2 \
pv=1.9.31-1 \
patchelf=0.18.0-1.4 \
subversion=1.14.5-3 && \
rm -rf /var/lib/apt/lists/*

# Install ruby gem FPM for packaging
RUN apt-get update && apt-get install --no-install-recommends -y \
ruby=1:3.3+b1 \
ruby-dev=1:3.3+b1 \
build-essential=12.12 \
rpm=4.20.1+dfsg-3 \
git=1:2.47.3-0+deb13u1 \
curl=8.14.1-2+deb13u2 \
ca-certificates=20250419 && \
gem install --no-document fpm --version 1.17.0 && \
rm -rf /var/lib/apt/lists/*

WORKDIR /workspaces/dfetch
Expand All @@ -22,7 +34,7 @@ ENV PYTHONUSERBASE="/home/dev/.local"

COPY --chown=dev:dev . .

RUN pip install --no-cache-dir --root-user-action=ignore --upgrade pip==25.2 \
RUN pip install --no-cache-dir --root-user-action=ignore --upgrade pip==25.3 \
&& pip install --no-cache-dir --root-user-action=ignore -e .[development,docs,test,casts,build] \
&& pre-commit install --install-hooks

Expand Down
72 changes: 50 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ jobs:
with:
python-version: '3.13'

- name: Set up Ruby
if: ${{ matrix.platform != 'windows-latest' }}
uses: ruby/setup-ruby@d354de180d0c9e813cfddfcbdc079945d4be589b #v1.275.0
with:
ruby-version: 3.3 # See also devcontainer

- name: Install fpm
if: ${{ matrix.platform != 'windows-latest' }}
run: |
gem install --no-document fpm --version 1.17.0
fpm --version

- name: Add msbuild to PATH
if: ${{ matrix.platform == 'windows-latest' }}
uses: microsoft/setup-msbuild@767f00a3f09872d96a0cb9fcd5e6a4ff33311330 # v2
- name: Install WiX
if: ${{ matrix.platform == 'windows-latest' }}
run: |
dotnet tool install --global wix --version 6.0.2
echo "$env:USERPROFILE\.dotnet\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
wix --version

- name: ccache
uses: hendrikmuhs/ccache-action@5ebbd400eff9e74630f759d94ddd7b6c26299639 # v1.2
if: ${{ matrix.platform != 'windows-latest' }}
Expand All @@ -59,12 +81,17 @@ jobs:
run: |
pip install .[build]
python script/build.py
python script/package.py

- name: Store the distribution packages
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: binary-distribution-${{ matrix.platform }}
path: build/dfetch-*
path: |
build/dfetch-package/*.deb
build/dfetch-package/*.rpm
build/dfetch-package/*.pkg
build/dfetch-package/*.msi

test-binary:
name: test binary
Expand All @@ -82,36 +109,37 @@ jobs:
name: binary-distribution-${{ matrix.platform }}
path: .

- name: Prepare binary
- name: Install binary
if: matrix.platform == 'ubuntu-latest'
run: |
binary=$(ls dfetch-*-x86_64)
ln -sf "$binary" dfetch
chmod +x dfetch
ls -la .
sudo dpkg -i dfetch*.deb
sudo dpkg -L dfetch
echo "/opt/dfetch" >> $GITHUB_PATH
shell: bash

- name: Prepare binary
- name: Install binary
if: matrix.platform == 'macos-latest'
run: |
binary=$(ls dfetch-*-osx)
ln -sf "$binary" dfetch
chmod +x dfetch
ls -la .
sudo installer -pkg dfetch*.pkg -target / -verboseR
echo "/opt/dfetch/opt/dfetch" >> $GITHUB_PATH
shell: bash

- name: Prepare binary on Windows
- name: Install binary
if: matrix.platform == 'windows-latest'
run: |
$binary = Get-ChildItem dfetch-*.exe | Select-Object -First 1
Copy-Item $binary -Destination dfetch.exe -Force
Get-ChildItem
$file = "dfetch.msi"
$log = "install.log"
$procMain = Start-Process "msiexec" "/i `"$file`" /qn /l*! `"$log`"" -NoNewWindow -PassThru
$procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru
$procMain.WaitForExit()
$procLog.Kill()
echo "C:\Program Files (x86)\dfetch" >> $env:GITHUB_PATH
shell: pwsh

- run: ./dfetch init
- run: ./dfetch environment
- run: ./dfetch validate
- run: ./dfetch check
- run: ./dfetch update
- run: ./dfetch update
- run: ./dfetch report -t sbom
- run: dfetch init
- run: dfetch environment
- run: dfetch validate
- run: dfetch check
- run: dfetch update
- run: dfetch update
- run: dfetch report -t sbom
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ pip install dfetch
pip install git+https://github.com/dfetch-org/dfetch.git#egg=dfetch
```

### Binary distributions

The [build.yml](https://github.com/dfetch-org/dfetch/actions/workflows/build.yml) produces installers for all major platforms.
See the artifacts in the run.

- Linux `.deb` & `.rpm`
- macOS `.pkg`
- Windows `.msi`

## Github Action

You can use DFetch in your Github Actions workflow to check your dependencies.
Expand Down
7 changes: 6 additions & 1 deletion dfetch/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

def _resource_path(filename: str) -> ContextManager[Path]:
"""Get the path to the resource."""
return importlib_resources.as_file(importlib_resources.files(resources) / filename)
return importlib_resources.as_file(
importlib_resources.files(
"resources" if "__compiled__" in globals() else resources
)
/ filename
)


def schema_path() -> ContextManager[Path]:
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "dfetch"
authors = [{ name = "Ben Spoor", email = "[email protected]" }]
description = "Dependency fetcher"
description = "A vendoring tool for fetching and managing external dependencies."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.9"
keywords = [
Expand Down Expand Up @@ -190,21 +190,22 @@ reportMissingModuleSource = false
pythonVersion = "3.9"

[tool.nuitka]
mode = "onefile" # Switch this between standalone and onefile as needed
mode = "standalone"
# jobs = "4" # Can be used to reduce memory usage, in case of compilation issues
# Enable below for debugging
# show-progress = true
assume-yes-for-downloads = true

include-package-data="dfetch,infer_license"
include-data-dir="dfetch/resources=resources"
include-package-data="infer_license"
include-module="infer_license.licenses"

# python-flag = ["-OO"] # Cannot optimize (yet) commands rely on __doc__ being present

output-dir = "build"
output-filename-win = "dfetch-{VERSION}.exe"
output-filename-linux = "dfetch-{VERSION}-x86_64"
output-filename-macos = "dfetch-{VERSION}-osx"
output-filename-win = "dfetch.exe"
output-filename-linux = "dfetch"
output-filename-macos = "dfetch"

# windows-icon-from-ico = "static/favicon.ico"
# windows-company-name = "dfetch-org"
Loading
Loading