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
0dcee561
Unverified
Commit
0dcee561
authored
Oct 25, 2022
by
René Helmke
Committed by
GitHub
Oct 25, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21 from fkie-cad/installation-bugfix
switched to pyproject.toml setup
parents
199365e8
67b31422
Hide 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 @
0dcee561
include fact_helper_file/bin/custommime.mgc
include custommime.mgc
include *.mgc
pyproject.toml
View file @
0dcee561
[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]
[tool.black]
line-length
=
120
line-length
=
120
skip-string-normalization
=
true
skip-string-normalization
=
true
target-version
=
[
'py37'
]
target-version
=
[
"py37"
]
[tool.pylint.main]
[tool.pylint.main]
init-hook
=
'import
sys;
sys.path.append(
"./src"
)'
init-hook
=
'import
sys;
sys.path.append(
"./src"
)'
...
...
setup.py
View file @
0dcee561
#!/usr/bin/env python
#!/usr/bin/env python
from
__future__
import
annotations
import
os
import
os
import
sys
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
run
,
STDOUT
from
setuptools
import
setup
from
setuptools
import
setup
MODULE_NAME
=
'fact_helper_file'
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
:
class
OperateInDirectory
:
def
__init__
(
self
,
target_directory
:
str
):
def
__init__
(
self
,
target_directory
:
str
|
Path
):
self
.
_current_working_dir
=
None
self
.
_current_working_dir
=
None
self
.
_target_directory
=
target_directory
self
.
_target_directory
=
target_directory
def
__enter__
(
self
):
def
__enter__
(
self
):
self
.
_current_working_dir
=
os
.
get
cwd
()
self
.
_current_working_dir
=
Path
.
cwd
()
os
.
chdir
(
self
.
_target_directory
)
os
.
chdir
(
self
.
_target_directory
)
def
__exit__
(
self
,
*
_
):
def
__exit__
(
self
,
*
_
):
os
.
chdir
(
self
.
_current_working_dir
)
os
.
chdir
(
self
.
_current_working_dir
)
def
execute_shell_command
(
shell_command
):
BIN_DIR
.
mkdir
(
exist_ok
=
True
)
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
with
OperateInDirectory
(
MIME_DIR
):
os
.
makedirs
(
str
(
MIME_DIR
.
parent
/
'bin'
),
exist_ok
=
True
)
process
=
run
(
with
OperateInDirectory
(
str
(
MIME_DIR
)):
FILE_OUTPUT
,
FILE_CODE
=
execute_shell_command
(
'(cat custom_* > custommime)'
'(cat custom_* > custommime)'
' && file -C -m custommime'
' && file -C -m custommime'
' && mv -f custommime.mgc ../bin/'
' && mv -f custommime.mgc ../bin/'
' && rm custommime'
' && rm custommime'
,
shell
=
True
,
stderr
=
STDOUT
,
)
)
if
FILE_CODE
!=
0
:
if
process
.
returncode
!=
0
:
sys
.
exit
(
'Failed to properly compile magic file
\n
{}'
.
format
(
FILE_OUTPUT
))
sys
.
stderr
.
write
(
f
'Failed to properly compile magic file
\n
{process.stdout}
\n
'
)
sys
.
exit
(
1
)
setup
(
name
=
MODULE_NAME
,
setup
()
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'
),
]}
)
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