Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
workflow
pypushflow
Commits
caa7591f
Commit
caa7591f
authored
Apr 02, 2020
by
payno
Browse files
update setup.py
parent
74db1727
Changes
1
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
caa7591f
...
...
@@ -32,29 +32,12 @@ __license__ = "MIT"
import
sys
import
os
import
logging
from
setuptools
import
setup
,
find_packages
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logger
=
logging
.
getLogger
(
__name__
)
from
setuptools
import
find_packages
try
:
from
setuptools
import
Command
from
setuptools.command.build_py
import
build_py
as
_build_py
from
setuptools.command.build_ext
import
build_ext
from
setuptools.command.sdist
import
sdist
logger
.
info
(
"Use setuptools"
)
except
ImportError
:
try
:
from
numpy.distutils.core
import
Command
except
ImportError
:
from
distutils.core
import
Command
from
distutils.command.build_py
import
build_py
as
_build_py
from
distutils.command.build_ext
import
build_ext
from
distutils.command.sdist
import
sdist
logger
.
info
(
"Use distutils"
)
try
:
import
sphinx
import
sphinx.util.console
...
...
@@ -162,284 +145,25 @@ classifiers = ["Development Status :: 4 - Beta",
"Topic :: Software Development :: Libraries :: Python Modules"
,
]
########
# Test #
########
class
PyTest
(
Command
):
"""Command to start tests running the script: run_tests.py -i"""
user_options
=
[]
def
initialize_options
(
self
):
pass
def
finalize_options
(
self
):
pass
def
run
(
self
):
import
subprocess
errno
=
subprocess
.
call
([
sys
.
executable
,
'run_tests.py'
])
if
errno
!=
0
:
raise
SystemExit
(
errno
)
# ################### #
# build_doc command #
# ################### #
if
sphinx
is
None
:
class
SphinxExpectedCommand
(
Command
):
"""Command to inform that sphinx is missing"""
user_options
=
[]
def
initialize_options
(
self
):
pass
def
finalize_options
(
self
):
pass
def
run
(
self
):
raise
RuntimeError
(
'Sphinx is required to build or test the documentation.
\n
'
'Please install Sphinx (http://www.sphinx-doc.org).'
)
class
BuildMan
(
Command
):
"""Command to build man pages"""
user_options
=
[]
def
initialize_options
(
self
):
pass
def
finalize_options
(
self
):
pass
def
entry_points_iterator
(
self
):
"""Iterate other entry points available on the project."""
entry_points
=
self
.
distribution
.
entry_points
console_scripts
=
entry_points
.
get
(
'console_scripts'
,
[])
gui_scripts
=
entry_points
.
get
(
'gui_scripts'
,
[])
scripts
=
[]
scripts
.
extend
(
console_scripts
)
scripts
.
extend
(
gui_scripts
)
for
script
in
scripts
:
# Remove ending extra dependencies
script
=
script
.
split
(
"["
)[
0
]
elements
=
script
.
split
(
"="
)
target_name
=
elements
[
0
].
strip
()
elements
=
elements
[
1
].
split
(
":"
)
module_name
=
elements
[
0
].
strip
()
function_name
=
elements
[
1
].
strip
()
yield
target_name
,
module_name
,
function_name
def
run_targeted_script
(
self
,
target_name
,
script_name
,
env
,
log_output
=
False
):
"""Execute targeted script using --help and --version to help checking
errors. help2man is not very helpful to do it for us.
:return: True is both return code are equal to 0
:rtype: bool
"""
import
subprocess
if
log_output
:
extra_args
=
{}
else
:
try
:
# Python 3
from
subprocess
import
DEVNULL
except
ImportError
:
# Python 2
import
os
DEVNULL
=
open
(
os
.
devnull
,
'wb'
)
extra_args
=
{
'stdout'
:
DEVNULL
,
'stderr'
:
DEVNULL
}
succeeded
=
True
command_line
=
[
sys
.
executable
,
script_name
,
"--help"
]
if
log_output
:
logger
.
info
(
"See the following execution of: %s"
,
" "
.
join
(
command_line
))
p
=
subprocess
.
Popen
(
command_line
,
env
=
env
,
**
extra_args
)
status
=
p
.
wait
()
if
log_output
:
logger
.
info
(
"Return code: %s"
,
status
)
succeeded
=
succeeded
and
status
==
0
command_line
=
[
sys
.
executable
,
script_name
,
"--version"
]
if
log_output
:
logger
.
info
(
"See the following execution of: %s"
,
" "
.
join
(
command_line
))
p
=
subprocess
.
Popen
(
command_line
,
env
=
env
,
**
extra_args
)
status
=
p
.
wait
()
if
log_output
:
logger
.
info
(
"Return code: %s"
,
status
)
succeeded
=
succeeded
and
status
==
0
return
succeeded
def
run
(
self
):
build
=
self
.
get_finalized_command
(
'build'
)
path
=
sys
.
path
path
.
insert
(
0
,
os
.
path
.
abspath
(
build
.
build_lib
))
env
=
dict
((
str
(
k
),
str
(
v
))
for
k
,
v
in
os
.
environ
.
items
())
env
[
"PYTHONPATH"
]
=
os
.
pathsep
.
join
(
path
)
import
subprocess
status
=
subprocess
.
call
([
"mkdir"
,
"-p"
,
"build/man"
])
if
status
!=
0
:
raise
RuntimeError
(
"Fail to create build/man directory"
)
import
tempfile
import
stat
script_name
=
None
entry_points
=
self
.
entry_points_iterator
()
for
target_name
,
module_name
,
function_name
in
entry_points
:
logger
.
info
(
"Build man for entry-point target '%s'"
%
target_name
)
# help2man expect a single executable file to extract the help
# we create it, execute it, and delete it at the end
py3
=
sys
.
version_info
>=
(
3
,
0
)
try
:
# create a launcher using the right python interpreter
script_fid
,
script_name
=
tempfile
.
mkstemp
(
prefix
=
"%s_"
%
target_name
,
text
=
True
)
script
=
os
.
fdopen
(
script_fid
,
'wt'
)
script
.
write
(
"#!%s
\n
"
%
sys
.
executable
)
script
.
write
(
"import %s as app
\n
"
%
module_name
)
script
.
write
(
"app.%s()
\n
"
%
function_name
)
script
.
close
()
# make it executable
mode
=
os
.
stat
(
script_name
).
st_mode
os
.
chmod
(
script_name
,
mode
+
stat
.
S_IEXEC
)
# execute help2man
man_file
=
"build/man/%s.1"
%
target_name
command_line
=
[
"help2man"
,
script_name
,
"-o"
,
man_file
]
if
not
py3
:
# Before Python 3.4, ArgParser --version was using
# stderr to print the version
command_line
.
append
(
"--no-discard-stderr"
)
# Then we dont know if the documentation will contains
# durtty things
succeeded
=
self
.
run_targeted_script
(
target_name
,
script_name
,
env
,
False
)
if
not
succeeded
:
logger
.
info
(
"Error while generating man file for target '%s'."
,
target_name
)
self
.
run_targeted_script
(
target_name
,
script_name
,
env
,
True
)
raise
RuntimeError
(
"Fail to generate '%s' man documentation"
%
target_name
)
p
=
subprocess
.
Popen
(
command_line
,
env
=
env
)
status
=
p
.
wait
()
if
status
!=
0
:
logger
.
info
(
"Error while generating man file for target '%s'."
,
target_name
)
self
.
run_targeted_script
(
target_name
,
script_name
,
env
,
True
)
raise
RuntimeError
(
"Fail to generate '%s' man documentation"
%
target_name
)
finally
:
# clean up the script
if
script_name
is
not
None
:
os
.
remove
(
script_name
)
if
sphinx
is
not
None
:
class
BuildDocCommand
(
BuildDoc
):
"""Command to build documentation using sphinx.
Project should have already be built.
"""
def
run
(
self
):
# make sure the python path is pointing to the newly built
# code so that the documentation is built on this and not a
# previously installed version
build
=
self
.
get_finalized_command
(
'build'
)
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
build
.
build_lib
))
# Build the Users Guide in HTML and TeX format
for
builder
in
[
'html'
,
'htmlhelp'
]:
self
.
builder
=
builder
self
.
builder_target_dir
=
os
.
path
.
join
(
self
.
build_dir
,
builder
)
self
.
mkpath
(
self
.
builder_target_dir
)
BuildDoc
.
run
(
self
)
sys
.
path
.
pop
(
0
)
class
BuildDocAndGenerateScreenshotCommand
(
BuildDocCommand
):
def
run
(
self
):
old
=
os
.
environ
.
get
(
'DIRECTIVE_SNAPSHOT_QT'
)
os
.
environ
[
'DIRECTIVE_SNAPSHOT_QT'
]
=
'True'
BuildDocCommand
.
run
(
self
)
if
old
is
not
None
:
os
.
environ
[
'DIRECTIVE_SNAPSHOT_QT'
]
=
old
else
:
del
os
.
environ
[
'DIRECTIVE_SNAPSHOT_QT'
]
else
:
BuildDocCommand
=
SphinxExpectedCommand
BuildDocAndGenerateScreenshotCommand
=
SphinxExpectedCommand
# ################### #
# test_doc command #
# ################### #
if
sphinx
is
not
None
:
class
TestDocCommand
(
BuildDoc
):
"""Command to test the documentation using sphynx doctest.
http://www.sphinx-doc.org/en/1.4.8/ext/doctest.html
"""
def
run
(
self
):
# make sure the python path is pointing to the newly built
# code so that the documentation is built on this and not a
# previously installed version
build
=
self
.
get_finalized_command
(
'build'
)
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
build
.
build_lib
))
# Build the Users Guide in HTML and TeX format
for
builder
in
[
'doctest'
]:
self
.
builder
=
builder
self
.
builder_target_dir
=
os
.
path
.
join
(
self
.
build_dir
,
builder
)
self
.
mkpath
(
self
.
builder_target_dir
)
BuildDoc
.
run
(
self
)
sys
.
path
.
pop
(
0
)
else
:
TestDocCommand
=
SphinxExpectedCommand
# ############################# #
# numpy.distutils Configuration #
# ############################# #
def
configuration
(
parent_package
=
''
,
top_path
=
None
):
"""Recursive construction of package info to be used in setup().
See http://docs.scipy.org/doc/numpy/reference/distutils.html#numpy.distutils.misc_util.Configuration
"""
try
:
from
numpy.distutils.misc_util
import
Configuration
except
ImportError
:
raise
ImportError
(
"To install this package, you must install numpy first
\n
"
"(See https://pypi.python.org/pypi/numpy)"
)
config
=
Configuration
(
None
,
parent_package
,
top_path
)
config
.
set_options
(
ignore_setup_xxx_py
=
True
,
assume_default_configuration
=
True
,
delegate_options_to_subpackages
=
True
,
quiet
=
True
)
config
.
add_subpackage
(
PROJECT
)
return
config
# ##### #
# setup #
# ##### #
NAMESPACE_PACKAGES
=
[
"orangecontrib"
]
PACKAGES
=
find_packages
()
def
setup_package
():
"""Run setup(**kwargs)
Depending on the command, it either runs the complete setup which depends on numpy,
or a *dry run* setup with no dependency on numpy.
"""
# Check if action requires build/install
dry_run
=
len
(
sys
.
argv
)
==
1
or
(
len
(
sys
.
argv
)
>=
2
and
(
'--help'
in
sys
.
argv
[
1
:]
or
sys
.
argv
[
1
]
in
(
'--help-commands'
,
'egg_info'
,
'--version'
,
'clean'
,
'--name'
)))
def
get_project_configuration
(
dry_run
):
"""Returns project arguments for setup"""
from
setuptools
import
setup
install_requires
=
[
# for the script launcher
"setuptools"
,
...
...
@@ -460,73 +184,21 @@ def get_project_configuration(dry_run):
}
cmdclass
=
dict
(
test
=
PyTest
,
build_doc
=
BuildDocCommand
,
build_screenshots
=
BuildDocAndGenerateScreenshotCommand
,
test_doc
=
TestDocCommand
,
build_man
=
BuildMan
)
if
dry_run
:
# DRY_RUN implies actions which do not require NumPy
#
# And they are required to succeed without Numpy for example when
# pip is used to install pypushflow when Numpy is not yet present in
# the system.
setup_kwargs
=
{}
else
:
config
=
configuration
()
setup_kwargs
=
config
.
todict
()
setup_kwargs
.
update
(
name
=
PROJECT
,
version
=
get_version
(),
url
=
"https://gitlab.esrf.fr/workflow/pypushflow"
,
author
=
"data analysis unit"
,
author_email
=
"henri.payno@esrf.fr"
,
classifiers
=
classifiers
,
description
=
"Workflow engine"
,
long_description
=
get_readme
(),
namespace_packages
=
NAMESPACE_PACKAGES
,
packages
=
PACKAGES
,
install_requires
=
install_requires
,
setup_requires
=
setup_requires
,
cmdclass
=
cmdclass
,
package_data
=
package_data
,
zip_safe
=
False
,
entry_points
=
entry_points
,
)
return
setup_kwargs
def
setup_package
():
"""Run setup(**kwargs)
Depending on the command, it either runs the complete setup which depends on numpy,
or a *dry run* setup with no dependency on numpy.
"""
# Check if action requires build/install
dry_run
=
len
(
sys
.
argv
)
==
1
or
(
len
(
sys
.
argv
)
>=
2
and
(
'--help'
in
sys
.
argv
[
1
:]
or
sys
.
argv
[
1
]
in
(
'--help-commands'
,
'egg_info'
,
'--version'
,
'clean'
,
'--name'
)))
if
dry_run
:
# DRY_RUN implies actions which do not require dependancies, like NumPy
try
:
from
setuptools
import
setup
logger
.
info
(
"Use setuptools.setup"
)
except
ImportError
:
from
distutils.core
import
setup
logger
.
info
(
"Use distutils.core.setup"
)
else
:
try
:
from
setuptools
import
setup
except
ImportError
:
from
numpy.distutils.core
import
setup
logger
.
info
(
"Use numpydistutils.setup"
)
setup_kwargs
=
get_project_configuration
(
dry_run
)
setup
(
**
setup_kwargs
)
return
setup
(
name
=
PROJECT
,
version
=
get_version
(),
packages
=
find_packages
(),
url
=
"https://gitlab.esrf.fr/workflow/pypushflow"
,
author
=
"data analysis unit"
,
author_email
=
"henri.payno@esrf.fr"
,
classifiers
=
classifiers
,
description
=
"Workflow engine"
,
long_description
=
get_readme
(),
install_requires
=
install_requires
,
setup_requires
=
setup_requires
,
package_data
=
package_data
,
zip_safe
=
False
,
entry_points
=
entry_points
,
)
DATA_FILES
=
[
...
...
Write
Preview
Supports
Markdown
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