Skip to content

Commit

Permalink
Better version management through PDM, also leverage PDM to install d…
Browse files Browse the repository at this point in the history
…eps in workflows
  • Loading branch information
BastienFaure committed Jun 11, 2024
1 parent a99f092 commit 0e8431e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 132 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ jobs:
run: sudo apt-get install -y libkrb5-dev

- name: Installs dev deps and package
run : |
pdm export -f requirements --without-hashes --dev > requirements.txt
python3.12 -m pip install -r requirements.txt
run : PDM_BUILD_SCM_VERSION=$(cat VERSION) pdm install --dev

- name: Build binary release
run: |
python3.12 -m nuitka --standalone --onefile --output-filename=ldeep.bin ldeep/__main__.py
pdm run python3.12 -m nuitka --standalone --onefile --output-filename=ldeep.bin ldeep/__main__.py
mv ldeep.bin ldeep_linux-amd64
- name: Build Source Distribution
run: pdm build -d sdist --no-wheel
run: PDM_BUILD_SCM_VERSION=$(cat VERSION) pdm build -d sdist --no-wheel

- name: Upload Artifacts (binary)
uses: actions/upload-artifact@v4
Expand All @@ -65,13 +63,11 @@ jobs:
run: python3 -m pip install pdm

- name: Installs dev deps and package
run: |
pdm export -f requirements --without-hashes --dev > requirements.txt
python3 -m pip install -r requirements.txt
run: PDM_BUILD_SCM_VERSION=$(cat VERSION) pdm install --dev

- name: Build
run: |
python3 -m nuitka --standalone --assume-yes-for-downloads --output-filename=ldeep.exe --onefile ldeep/__main__.py
pdm run python3 -m nuitka --standalone --assume-yes-for-downloads --output-filename=ldeep.exe --onefile ldeep/__main__.py
mv ldeep.exe ldeep_windows-amd64.exe
- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand All @@ -92,13 +88,11 @@ jobs:
run: python3.12 -m pip install pdm

- name: Installs dev deps and package
run: |
pdm export -f requirements --without-hashes --dev > requirements.txt
python3.12 -m pip install -r requirements.txt
run: PDM_BUILD_SCM_VERSION=$(cat VERSION) pdm install --dev

- name: Build
run: |
python3.12 -m nuitka --standalone --onefile --output-filename=ldeep.bin ldeep/__main__.py
pdm run python3.12 -m nuitka --standalone --onefile --output-filename=ldeep.bin ldeep/__main__.py
mv ldeep.bin ldeep_macos-arm64
- name: Upload Artifacts
Expand All @@ -120,13 +114,11 @@ jobs:
run: python3.12 -m pip install pdm

- name: Installs dev deps and package
run: |
pdm export -f requirements --without-hashes --dev > requirements.txt
python3.12 -m pip install -r requirements.txt
run: PDM_BUILD_SCM_VERSION=$(cat VERSION) pdm install --dev

- name: Build
run: |
python3.12 -m nuitka --standalone --onefile --output-filename=ldeep.bin ldeep/__main__.py
pdm run python3.12 -m nuitka --standalone --onefile --output-filename=ldeep.bin ldeep/__main__.py
mv ldeep.bin ldeep_macos-amd64
- name: Upload Artifacts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ __pycache__
.venv
.pdm-python
.pdm-build/
ldeep/_version.py
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
EXEC = ldeep.bin

SRC = $(wildcard ./ldeep/*.py)

all: $(EXEC)
all: build

$(EXEC): $(SRC)
pdm build --no-sdist
pex -r requirements.txt --disable-cache -f dist/ -o $@ -e ldeep.__main__ ldeep
build:
pdm build -d sdist

pypi: $(SRC)
pdm build -d sdist --no-wheel
twine upload sdist/*

pypi-test: $(SRC)
pdm build -d sdist --no-wheel
twine upload --repository testpypi sdist/*

clean:
Expand All @@ -28,4 +23,4 @@ export:
pdm export -f requirements --without-hashes --prod > requirements.txt
pdm export -f requirements --without-hashes --dev > requirements-dev.txt

.PHONY: clean mrproper
.PHONY: clean mrproper build
7 changes: 0 additions & 7 deletions ldeep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
import os

__version__ = open(os.path.join(os.path.dirname(__file__), "../VERSION")).read().strip()


def get_version():
return __version__
9 changes: 2 additions & 7 deletions ldeep/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
FILETIME_TIMESTAMP_FIELDS,
FOREST_LEVELS,
)
from ldeep import __version__
from ldeep._version import __version__
from ldeep.views.ldap_activedirectory import LdapActiveDirectoryView
from ldeep.views.cache_activedirectory import CacheActiveDirectoryView

Expand Down Expand Up @@ -1756,12 +1756,7 @@ def action_create_user(self, kwargs):


def main():
parser = ArgumentParser()
parser.add_argument(
"--version",
action="version",
version="%(prog)s {version}".format(version=__version__),
)
parser = ArgumentParser(f"ldeep - {__version__}")
parser.add_argument(
"-o", "--outfile", default="", help="Store the results in a file"
)
Expand Down
11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ classifiers = [
"Topic :: Security",
]

[tool.pdm.build]
includes = [
"ldeep/**/*.py",
"VERSION",
]

[tool.pdm.version]
source = "call"
getter = "ldeep:get_version"
source = "scm"
write_to = "ldeep/_version.py"
write_template = "__version__ = '{}'"

[project.urls]
Homepage = "https://github.com/franc-pentest/ldeep"
Expand Down
61 changes: 0 additions & 61 deletions requirements-dev.txt

This file was deleted.

21 changes: 0 additions & 21 deletions requirements.txt

This file was deleted.

0 comments on commit 0e8431e

Please sign in to comment.