-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to use pyproject.toml (#212)
- Loading branch information
1 parent
aabe79c
commit 84ceb73
Showing
6 changed files
with
90 additions
and
246 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
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,3 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pip >= 7.0.0 | ||
PyYAML >= 3.10 | ||
dfdatetime >= 20160814 | ||
dtfabric >= 20170524 | ||
|
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 |
---|---|---|
@@ -1,5 +1,39 @@ | ||
[metadata] | ||
license_files = LICENSE | ||
name = dfwinreg | ||
version = 20230506 | ||
description = Digital Forensics Windows Registry (dfWinReg). | ||
long_description = dfWinReg, or Digital Forensics Windows Registry, provides read-only access to Windows Registry objects. The goal of dfWinReg is to provide a generic interface for accessing Windows Registry objects that resembles the Registry key hierarchy as seen on a live Windows system. | ||
url = https://github.com/log2timeline/dfwinreg | ||
maintainer = Log2Timeline maintainers | ||
maintainer_email = [email protected] | ||
license = Apache License, Version 2.0 | ||
license_files = | ||
ACKNOWLEDGEMENTS | ||
AUTHORS | ||
LICENSE | ||
README | ||
classifiers = | ||
Development Status :: 3 - Alpha | ||
Programming Language :: Python | ||
|
||
[options] | ||
install_requires = file:requirements.txt | ||
package_dir = | ||
dfwinreg = dfwinreg | ||
packages = find: | ||
python_requires = >=3.7 | ||
|
||
[options.package_data] | ||
dfwinreg = | ||
*.yaml | ||
|
||
[options.packages.find] | ||
exclude = | ||
docs | ||
tests | ||
tests.* | ||
utils | ||
where = . | ||
|
||
[sdist] | ||
template = MANIFEST.in | ||
|
@@ -12,17 +46,18 @@ manifest = MANIFEST.test_data | |
[bdist_rpm] | ||
release = 1 | ||
packager = Log2Timeline maintainers <[email protected]> | ||
doc_files = ACKNOWLEDGEMENTS | ||
AUTHORS | ||
LICENSE | ||
README | ||
doc_files = | ||
ACKNOWLEDGEMENTS | ||
AUTHORS | ||
LICENSE | ||
README | ||
build_requires = python3-setuptools | ||
requires = libcreg-python3 >= 20210502 | ||
libregf-python3 >= 20201002 | ||
python3-dfdatetime >= 20160814 | ||
python3-dtfabric >= 20170524 | ||
python3-pyyaml >= 3.10 | ||
requires = | ||
libcreg-python3 >= 20210502 | ||
libregf-python3 >= 20201002 | ||
python3-dfdatetime >= 20160814 | ||
python3-dtfabric >= 20170524 | ||
python3-pyyaml >= 3.10 | ||
|
||
[bdist_wheel] | ||
universal = 1 | ||
|
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 |
---|---|---|
|
@@ -2,207 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
"""Installation and deployment script.""" | ||
|
||
import os | ||
import pkg_resources | ||
import sys | ||
from setuptools import setup | ||
|
||
try: | ||
from setuptools import find_packages, setup | ||
except ImportError: | ||
from distutils.core import find_packages, setup | ||
|
||
try: | ||
from distutils.command.bdist_rpm import bdist_rpm | ||
except ImportError: | ||
bdist_rpm = None | ||
|
||
try: | ||
from setuptools.commands.sdist import sdist | ||
except ImportError: | ||
from distutils.command.sdist import sdist | ||
|
||
version_tuple = (sys.version_info[0], sys.version_info[1]) | ||
if version_tuple < (3, 7): | ||
print(f'Unsupported Python version: {sys.version:s}, version 3.7 or higher ' | ||
f'required.') | ||
sys.exit(1) | ||
|
||
# Change PYTHONPATH to include dfwinreg so that we can get the version. | ||
sys.path.insert(0, '.') | ||
|
||
import dfwinreg # pylint: disable=wrong-import-position | ||
|
||
|
||
if not bdist_rpm: | ||
BdistRPMCommand = None | ||
else: | ||
class BdistRPMCommand(bdist_rpm): | ||
"""Custom handler for the bdist_rpm command.""" | ||
|
||
# pylint: disable=invalid-name | ||
def _make_spec_file(self): | ||
"""Generates the text of an RPM spec file. | ||
Returns: | ||
list[str]: lines of the RPM spec file. | ||
""" | ||
# Note that bdist_rpm can be an old style class. | ||
if issubclass(BdistRPMCommand, object): | ||
spec_file = super(BdistRPMCommand, self)._make_spec_file() | ||
else: | ||
spec_file = bdist_rpm._make_spec_file(self) | ||
|
||
python_package = 'python3' | ||
|
||
description = [] | ||
requires = '' | ||
summary = '' | ||
in_description = False | ||
|
||
python_spec_file = [] | ||
for line in iter(spec_file): | ||
if line.startswith('Summary: '): | ||
summary = line[9:] | ||
|
||
elif line.startswith('BuildRequires: '): | ||
line = (f'BuildRequires: {python_package:s}-setuptools, ' | ||
f'{python_package:s}-devel') | ||
|
||
elif line.startswith('Requires: '): | ||
requires = line[10:] | ||
continue | ||
|
||
elif line.startswith('%description'): | ||
in_description = True | ||
|
||
elif line.startswith('python setup.py build'): | ||
if python_package == 'python3': | ||
line = '%py3_build' | ||
else: | ||
line = '%py2_build' | ||
|
||
elif line.startswith('python setup.py install'): | ||
if python_package == 'python3': | ||
line = '%py3_install' | ||
else: | ||
line = '%py2_install' | ||
|
||
elif line.startswith('%files'): | ||
lines = [ | ||
f'%files -n {python_package:s}-%{{name}}', | ||
'%defattr(644,root,root,755)', | ||
'%license LICENSE', | ||
'%doc ACKNOWLEDGEMENTS AUTHORS README'] | ||
|
||
lines.extend([ | ||
'%{python3_sitelib}/dfwinreg/*.py', | ||
'%{python3_sitelib}/dfwinreg/*.yaml', | ||
'%{python3_sitelib}/dfwinreg*.egg-info/*', | ||
'', | ||
'%exclude %{_prefix}/share/doc/*', | ||
'%exclude %{python3_sitelib}/dfwinreg/__pycache__/*']) | ||
|
||
python_spec_file.extend(lines) | ||
break | ||
|
||
elif line.startswith('%prep'): | ||
in_description = False | ||
|
||
python_spec_file.append(f'%package -n {python_package:s}-%{{name}}') | ||
python_summary = f'Python 3 module of {summary:s}' | ||
|
||
if requires: | ||
python_spec_file.append(f'Requires: {requires:s}') | ||
|
||
python_spec_file.extend([ | ||
f'Summary: {python_summary:s}', | ||
'', | ||
f'%description -n {python_package:s}-%{{name}}']) | ||
|
||
python_spec_file.extend(description) | ||
|
||
elif in_description: | ||
# Ignore leading white lines in the description. | ||
if not description and not line: | ||
continue | ||
|
||
description.append(line) | ||
|
||
python_spec_file.append(line) | ||
|
||
return python_spec_file | ||
|
||
|
||
def parse_requirements_from_file(path): | ||
"""Parses requirements from a requirements file. | ||
Args: | ||
path (str): path to the requirements file. | ||
Returns: | ||
list[str]: name and optional version information of the required packages. | ||
""" | ||
requirements = [] | ||
if os.path.isfile(path): | ||
with open(path, 'r') as file_object: | ||
file_contents = file_object.read() | ||
|
||
for requirement in pkg_resources.parse_requirements(file_contents): | ||
try: | ||
name = str(requirement.req) | ||
except AttributeError: | ||
name = str(requirement) | ||
|
||
if not name.startswith('pip '): | ||
requirements.append(name) | ||
|
||
return requirements | ||
|
||
|
||
dfwinreg_description = ( | ||
'Digital Forensics Windows Registry (dfWinReg).') | ||
|
||
dfwinreg_long_description = ( | ||
'dfWinReg, or Digital Forensics Windows Registry, provides read-only ' | ||
'access to Windows Registry objects. The goal of dfWinReg is to provide a ' | ||
'generic interface for accessing Windows Registry objects that resembles ' | ||
'the Registry key hierarchy as seen on a live Windows system.') | ||
|
||
command_classes = {'sdist_test_data': sdist} | ||
if BdistRPMCommand: | ||
command_classes['bdist_rpm'] = BdistRPMCommand | ||
|
||
setup( | ||
name='dfwinreg', | ||
version=dfwinreg.__version__, | ||
description=dfwinreg_description, | ||
long_description=dfwinreg_long_description, | ||
long_description_content_type='text/plain', | ||
license='Apache License, Version 2.0', | ||
url='https://github.com/log2timeline/dfwinreg', | ||
maintainer='Log2Timeline maintainers', | ||
maintainer_email='[email protected]', | ||
cmdclass=command_classes, | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', | ||
'Environment :: Console', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
], | ||
packages=find_packages('.', exclude=[ | ||
'docs', 'tests', 'tests.*', 'utils']), | ||
package_dir={ | ||
'dfwinreg': 'dfwinreg' | ||
}, | ||
include_package_data=True, | ||
package_data={ | ||
'dfwinreg': ['*.yaml'] | ||
}, | ||
zip_safe=False, | ||
data_files=[ | ||
('share/doc/dfwinreg', [ | ||
'ACKNOWLEDGEMENTS', 'AUTHORS', 'LICENSE', 'README']), | ||
], | ||
install_requires=parse_requirements_from_file('requirements.txt'), | ||
tests_require=parse_requirements_from_file('test_requirements.txt'), | ||
) | ||
setup() |
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 |
---|---|---|
@@ -1,49 +1,54 @@ | ||
[tox] | ||
envlist = py3{7,8,9,10,11},coverage,docs,lint | ||
envlist = py3{7,8,9,10,11,12},coverage,docs,lint,wheel | ||
|
||
[testenv] | ||
allowlist_externals = ./run_tests.py | ||
pip_pre = True | ||
passenv = | ||
CFLAGS | ||
CPPFLAGS | ||
LDFLAGS | ||
CFLAGS | ||
CPPFLAGS | ||
LDFLAGS | ||
setenv = | ||
PYTHONPATH = {toxinidir} | ||
PYTHONPATH = {toxinidir} | ||
deps = | ||
-rrequirements.txt | ||
-rtest_requirements.txt | ||
coverage: coverage | ||
-rrequirements.txt | ||
-rtest_requirements.txt | ||
coverage: coverage | ||
wheel: | ||
build | ||
setuptools | ||
wheel | ||
commands = | ||
py3{7,8,9,10,11}: ./run_tests.py | ||
coverage: coverage erase | ||
coverage: coverage run --source=dfwinreg --omit="*_test*,*__init__*,*test_lib*" run_tests.py | ||
coverage: coverage xml | ||
py3{7,8,9,10,11,12}: ./run_tests.py | ||
coverage: coverage erase | ||
coverage: coverage run --source=dfwinreg --omit="*_test*,*__init__*,*test_lib*" run_tests.py | ||
coverage: coverage xml | ||
wheel: python -m build --no-isolation --wheel | ||
|
||
[testenv:docs] | ||
usedevelop = True | ||
deps = | ||
-rdocs/requirements.txt | ||
-rdocs/requirements.txt | ||
commands = | ||
sphinx-build -b html -d build/doctrees docs dist/docs | ||
sphinx-build -b linkcheck docs dist/docs | ||
sphinx-build -b html -d build/doctrees docs dist/docs | ||
sphinx-build -b linkcheck docs dist/docs | ||
|
||
[testenv:lint] | ||
skipsdist = True | ||
pip_pre = True | ||
passenv = | ||
CFLAGS | ||
CPPFLAGS | ||
LDFLAGS | ||
CFLAGS | ||
CPPFLAGS | ||
LDFLAGS | ||
setenv = | ||
PYTHONPATH = {toxinidir} | ||
PYTHONPATH = {toxinidir} | ||
deps = | ||
-rrequirements.txt | ||
-rtest_requirements.txt | ||
pylint >= 2.17.0, < 2.18.0 | ||
yamllint >= 1.26.0 | ||
-rrequirements.txt | ||
-rtest_requirements.txt | ||
pylint >= 2.17.0, < 2.18.0 | ||
yamllint >= 1.26.0 | ||
commands = | ||
pylint --version | ||
yamllint -v | ||
pylint --rcfile=.pylintrc dfwinreg tests | ||
yamllint -c .yamllint.yaml dfwinreg | ||
pylint --version | ||
yamllint -v | ||
pylint --rcfile=.pylintrc dfwinreg setup.py tests | ||
yamllint -c .yamllint.yaml dfwinreg |