Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to dependency writers #1229

Merged
merged 6 commits into from
Mar 30, 2024
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
2 changes: 1 addition & 1 deletion config/docker/plaso-dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:jammy
FROM ubuntu:noble
MAINTAINER Log2Timeline <[email protected]>

# Create container with:
Expand Down
35 changes: 12 additions & 23 deletions data/templates/github_actions/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['39']
version: ['39', '40']
container:
image: registry.fedoraproject.org/fedora:$${{ matrix.version }}
steps:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
dnf copr -y enable @gift/dev
dnf install -y @development-tools python3 python3-devel ${rpm_dependencies}
dnf install -y @development-tools ${rpm_dependencies}
- name: Run tests
env:
LANG: C.utf8
Expand All @@ -27,21 +27,17 @@ jobs:
- name: Run end-to-end tests
run: |
if test -f tests/end-to-end.py; then PYTHONPATH=. python3 ./tests/end-to-end.py --debug -c config/end-to-end.ini; fi
- name: Build source distribution
- name: Build source distribution (sdist)
run: |
python3 ./setup.py sdist
- name: Build binary distribution
python3 -m build --no-isolation --sdist
- name: Build binary distribution (wheel)
run: |
python3 ./setup.py bdist
- name: Run build and install test
run: |
python3 ./setup.py build
python3 ./setup.py install
python3 -m build --no-isolation --wheel
test_ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['22.04']
version: ['24.04']
container:
image: ubuntu:$${{ matrix.version }}
steps:
Expand All @@ -58,7 +54,7 @@ jobs:
run: |
add-apt-repository -y ppa:gift/dev
apt-get update -q
apt-get install -y build-essential python3 python3-dev ${dpkg_dependencies}
apt-get install -y build-essential ${dpkg_dependencies}
- name: Run tests
env:
LANG: en_US.UTF-8
Expand All @@ -69,16 +65,9 @@ jobs:
LANG: en_US.UTF-8
run: |
if test -f tests/end-to-end.py; then PYTHONPATH=. python3 ./tests/end-to-end.py --debug -c config/end-to-end.ini; fi
- name: Update setuptools
run: |
python3 -m pip install -U setuptools
- name: Build source distribution
run: |
python3 ./setup.py sdist
- name: Build binary distribution
- name: Build source distribution (sdist)
run: |
python3 ./setup.py bdist
- name: Run build and install test
python3 -m build --no-isolation --sdist
- name: Build binary distribution (wheel)
run: |
python3 ./setup.py build
python3 ./setup.py install
python3 -m build --no-isolation --wheel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PYTHONPATH=. python3 ./utils/check_dependencies.py

# Start the end-to-end tests in the background so we can capture the PID of
# the process while the script is running.
PYTHONPATH=. python3 ./tests/end-to-end.py --config $${CONFIGURATION_FILE} --sources-directory $${SOURCES_DIRECTORY} ${scripts_directory_option} --results-directory $${RESULTS_DIRECTORY} --references-directory $${REFERENCES_DIRECTORY} &
PYTHONPATH=. python3 ./tests/end-to-end.py --config $${CONFIGURATION_FILE} --sources-directory $${SOURCES_DIRECTORY} --scripts-directory ${scripts_directory} --results-directory $${RESULTS_DIRECTORY} --references-directory $${REFERENCES_DIRECTORY} &

PID_COMMAND=$$!;

Expand Down
112 changes: 0 additions & 112 deletions data/templates/macos_make_dist.sh

This file was deleted.

4 changes: 4 additions & 0 deletions data/templates/setup.cfg/options_entry_points
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[options.entry_points]
console_scripts =
${console_scripts}
8 changes: 0 additions & 8 deletions data/templates/setup.cfg/sdist_test_data

This file was deleted.

6 changes: 5 additions & 1 deletion l2tdevtools/dependency_writers/github_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ def Write(self):
dpkg_dependencies = self._GetDPKGPythonDependencies()
test_dependencies = self._GetDPKGTestDependencies(dpkg_dependencies)
dpkg_dependencies.extend(test_dependencies)
dpkg_dependencies.extend(['python3-pip', 'python3-wheel'])
dpkg_dependencies.extend([
'python3', 'python3-build', 'python3-dev', 'python3-pip',
'python3-wheel'])

rpm_dependencies = self._GetRPMPythonDependencies()
test_dependencies = self._GetRPMTestDependencies(rpm_dependencies)
rpm_dependencies.extend(test_dependencies)
rpm_dependencies.extend([
'python3', 'python3-build', 'python3-devel', 'python3-wheel'])

template_mappings = {
'dpkg_dependencies': ' '.join(sorted(set(dpkg_dependencies))),
Expand Down
14 changes: 7 additions & 7 deletions l2tdevtools/dependency_writers/jenkins_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class LinuxRunEndToEndTestsScriptWriter(interface.DependencyFileWriter):

def Write(self):
"""Writes a Linux run_end_to_end_tests.sh file."""
if self._project_definition.name == 'dfvfs':
scripts_directory_option = '--scripts-directory ./examples'
elif self._project_definition.name == 'plaso':
scripts_directory_option = '--tools-directory ./tools'
else:
scripts_directory_option = '--scripts-directory ./scripts'
python_module_name = self._project_definition.name

if self._project_definition.name.endswith('-kb'):
python_module_name = ''.join([python_module_name[:-3], 'rc'])

scripts_directory = os.path.join(python_module_name, 'scripts')

template_mappings = {
'project_name': self._project_definition.name,
'scripts_directory_option': scripts_directory_option}
'scripts_directory': scripts_directory}

template_file = os.path.join(self._l2tdevtools_path, self._TEMPLATE_FILE)
file_content = self._GenerateFromTemplate(template_file, template_mappings)
Expand Down
35 changes: 21 additions & 14 deletions l2tdevtools/dependency_writers/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class SetupCfgWriter(interface.DependencyFileWriter):
'artifacts-kb', 'dfvfs', 'dfwinreg', 'dtformats', 'esedb-kb', 'olecf-kb',
'plaso', 'winreg-kb', 'winsps-kb')

_PROJECTS_WITH_SDIST_TEST_DATA = (
'dfimagetools', 'dfvfs', 'dfwinreg', 'plaso', 'winevt-kb', 'winreg-kb',
'winsps-kb')

_TEMPLATE_DIRECTORY = os.path.join('data', 'templates', 'setup.cfg')

def _DetermineSubmoduleLevels(self, python_module_name):
Expand Down Expand Up @@ -136,11 +132,11 @@ def Write(self):
formatted_package_data = [
f' {data_file:s}' for data_file in sorted(package_data)]

scripts_directory = None
if os.path.isdir('scripts'):
scripts_directory = 'scripts'
elif os.path.isdir('tools'):
scripts_directory = 'scripts'
if not os.path.isdir(scripts_directory):
scripts_directory = 'tools'
if not os.path.isdir(scripts_directory):
scripts_directory = None

scripts = []
if scripts_directory:
Expand All @@ -149,15 +145,26 @@ def Write(self):
formatted_scripts = [
f' {script:s}' for script in sorted(scripts)]

# TODO: add support for entry points
scripts_directory = None
if os.path.isdir(os.path.join(python_module_name, 'scripts')):
scripts_directory = None
console_scripts_directory = os.path.join(python_module_name, 'scripts')
if not os.path.isdir(console_scripts_directory):
console_scripts_directory = None

console_scripts = []
if console_scripts_directory:
console_scripts = glob.glob(f'{console_scripts_directory:s}/[a-z]*.py')

entry_points_console_scripts = []
for console_script in sorted(console_scripts):
console_script = console_script.replace('.py', '')
module_name = console_script.replace(os.path.sep, '.')
name = os.path.basename(console_script)
entry_points_console_scripts.append(f' {name:s} = {module_name:s}:Main')

date_time = datetime.datetime.now()
version = date_time.strftime('%Y%m%d')

template_mappings = {
'console_scripts': '\n'.join(entry_points_console_scripts),
'description_long': description_long,
'description_short': self._project_definition.description_short,
'development_status': development_status,
Expand Down Expand Up @@ -190,9 +197,9 @@ def Write(self):
'options_packages_find', template_mappings)
file_content.append(template_data)

if self._project_definition.name in self._PROJECTS_WITH_SDIST_TEST_DATA:
if entry_points_console_scripts:
template_data = self._GenerateFromTemplate(
'sdist_test_data', template_mappings)
'options_entry_points', template_mappings)
file_content.append(template_data)

template_data = self._GenerateFromTemplate('bdist_wheel', template_mappings)
Expand Down
2 changes: 1 addition & 1 deletion l2tdevtools/lib/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
DEFAULT_FEDORA_DISTRIBUTION = '39'

# The default Ubuntu distribution
DEFAULT_UBUNTU_DISTRIBUTION = 'jammy'
DEFAULT_UBUNTU_DISTRIBUTION = 'noble'
2 changes: 1 addition & 1 deletion tests/download_helpers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Log2TimelineGitHubReleasesDownloadHelperTest(test_lib.BaseTestCase):

_PROJECT_ORGANIZATION = 'log2timeline'
_PROJECT_NAME = 'dfvfs'
_PROJECT_VERSION = '20240115'
_PROJECT_VERSION = '20240317'

@classmethod
def setUpClass(cls):
Expand Down
2 changes: 1 addition & 1 deletion tests/download_helpers/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PyPIDownloadHelperTest(test_lib.BaseTestCase):
_GIT_URL = 'https://github.com/log2timeline/dfvfs.git'

_PROJECT_NAME = 'dfvfs'
_PROJECT_VERSION = '20240115'
_PROJECT_VERSION = '20240317'
_PYPI_VERSION = '20240115'

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions tests/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GithubRepoDownloadHelperTest(test_lib.BaseTestCase):
_DOWNLOAD_URL = 'https://github.com/ForensicArtifacts/artifacts/releases'

_PROJECT_NAME = 'artifacts'
_PROJECT_VERSION = '20240303'
_PROJECT_VERSION = '20240317'

def testGetPackageDownloadURLs(self):
"""Tests the GetPackageDownloadURLs function."""
Expand Down Expand Up @@ -50,7 +50,7 @@ class DependencyUpdaterTest(test_lib.BaseTestCase):
# pylint: disable=protected-access

_PROJECT_NAME = 'dfvfs'
_PROJECT_VERSION = '20240115'
_PROJECT_VERSION = '20240317'

def testGetAvailableWheelPackages(self):
"""Tests the _GetAvailableWheelPackages function."""
Expand Down
2 changes: 1 addition & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ProjectBuilder(object):
"""

# The distributions to build dpkg-source packages for.
_DPKG_SOURCE_DISTRIBUTIONS = frozenset(['jammy'])
_DPKG_SOURCE_DISTRIBUTIONS = frozenset(['noble'])

def __init__(self, build_target, l2tdevtools_path, downloads_directory):
"""Initializes the project builder.
Expand Down
Loading