Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fact_helper_file
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
fact_helper_file
Commits
3d7b64cc
Commit
3d7b64cc
authored
Oct 25, 2022
by
Jörg Stucke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switched to pyproject.toml setup
parent
f35022e1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
29 deletions
+51
-29
MANIFEST.in
MANIFEST.in
+3
-0
pyproject.toml
pyproject.toml
+29
-1
setup.py
setup.py
+19
-28
No files found.
MANIFEST.in
0 → 100644
View file @
3d7b64cc
include fact_helper_file/bin/custommime.mgc
include custommime.mgc
include *.mgc
pyproject.toml
View file @
3d7b64cc
[build-system]
requires
=
[
"setuptools >= 61.0.0"
,
"wheel"
,
]
build-backend
=
"setuptools.build_meta"
[project]
name
=
"fact_helper_file"
version
=
"0.2.13"
authors
=
[
{name
=
"Johannes vom Dorp"
}
]
license
=
{file
=
"LICENSE"
}
urls
=
{homepage
=
"https://github.com/fkie-cad/fact_helper_file"
}
dependencies
=
[
"python-magic"
,
]
requires-python
=
">=3.7"
[tool.setuptools.packages.find]
where
=
["."]
include
=
["fact_helper_file"]
exclude
=
["test"]
[tool.setuptools.package-data]
mypkg
=
["*.mgc"]
[tool.black]
line-length
=
120
skip-string-normalization
=
true
target-version
=
[
'py37'
]
target-version
=
[
"py37"
]
[tool.pylint.main]
init-hook
=
'import
sys;
sys.path.append(
"./src"
)'
...
...
setup.py
View file @
3d7b64cc
#!/usr/bin/env python
from
__future__
import
annotations
import
os
import
sys
from
pathlib
import
Path
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
run
,
STDOUT
from
setuptools
import
setup
MODULE_NAME
=
'fact_helper_file'
MIME_DIR
=
Path
(
__file__
)
.
parent
/
MODULE_NAME
/
'mime'
MODULE_DIR
=
Path
(
__file__
)
.
parent
/
MODULE_NAME
MIME_DIR
=
MODULE_DIR
/
'mime'
BIN_DIR
=
MODULE_DIR
/
'bin'
class
OperateInDirectory
:
def
__init__
(
self
,
target_directory
:
str
):
def
__init__
(
self
,
target_directory
:
str
|
Path
):
self
.
_current_working_dir
=
None
self
.
_target_directory
=
target_directory
def
__enter__
(
self
):
self
.
_current_working_dir
=
os
.
get
cwd
()
self
.
_current_working_dir
=
Path
.
cwd
()
os
.
chdir
(
self
.
_target_directory
)
def
__exit__
(
self
,
*
_
):
os
.
chdir
(
self
.
_current_working_dir
)
def
execute_shell_command
(
shell_command
):
with
Popen
(
shell_command
,
shell
=
True
,
stdout
=
PIPE
,
stderr
=
PIPE
)
as
pl
:
output
=
pl
.
communicate
()[
0
]
.
decode
(
'utf-8'
,
errors
=
'replace'
)
return
output
,
pl
.
returncode
BIN_DIR
.
mkdir
(
exist_ok
=
True
)
os
.
makedirs
(
str
(
MIME_DIR
.
parent
/
'bin'
),
exist_ok
=
True
)
with
OperateInDirectory
(
str
(
MIME_DIR
)):
FILE_OUTPUT
,
FILE_CODE
=
execute_shell_command
(
with
OperateInDirectory
(
MIME_DIR
):
process
=
run
(
'(cat custom_* > custommime)'
' && file -C -m custommime'
' && mv -f custommime.mgc ../bin/'
' && rm custommime'
' && rm custommime'
,
shell
=
True
,
stderr
=
STDOUT
,
)
if
FILE_CODE
!=
0
:
sys
.
exit
(
'Failed to properly compile magic file
\n
{}'
.
format
(
FILE_OUTPUT
))
setup
(
name
=
MODULE_NAME
,
version
=
'0.2.12'
,
description
=
'Helper functions for file type generation'
,
author
=
'Johannes vom Dorp'
,
url
=
'https://github.com/fkie-cad/fact_helper_file'
,
install_requires
=
[
'python-magic'
],
python_requires
=
'>=3.5'
,
packages
=
[
MODULE_NAME
,
],
package_data
=
{
MODULE_NAME
:
[
str
(
MIME_DIR
.
parent
/
'bin'
/
'custommime.mgc'
),
]}
)
if
process
.
returncode
!=
0
:
sys
.
stderr
.
write
(
f
'Failed to properly compile magic file
\n
{process.stdout}
\n
'
)
sys
.
exit
(
1
)
setup
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment