Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teresa Weßels
empyre
Commits
e471a8c9
Commit
e471a8c9
authored
5 years ago
by
Jan Caron
Browse files
Options
Downloads
Patches
Plain Diff
Streamlined setup.py,
put most options into setup.cfg
parent
a9c22581
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup.cfg
+88
-8
88 additions, 8 deletions
setup.cfg
setup.py
+30
-150
30 additions, 150 deletions
setup.py
with
118 additions
and
158 deletions
setup.cfg
+
88
−
8
View file @
e471a8c9
...
...
@@ -23,7 +23,83 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO: Check if everything is taylored to pyramid!
# CONFIGURATION FOR SETUP.PY:
[metadata]
name
=
pyramid
version
=
0.1.0.dev0
author
=
Jan Caron
author-email
=
j.caron@fz-juelich.de
description
=
PYthon based Reconstruction Algorithm for MagnetIc Distributions
long-description
=
file: README.md
url
=
https://jugit.fz-juelich.de/j.caron/pyramid
license
=
GPLv3
classifiers
=
Development
Status
::
3
-
alpha
Intended
Audience
::
Developers
Intended
Audience
::
Science/Research
License
::
OSI
Approved
::
GNU
General
Public
License
v3
(GPLv3)
Programming
Language
::
Python
::
3.7
Topic
::
Scientific/Engineering
Operating
System
::
OS
Independen
[options]
zip_safe
=
False
include_package_data
=
True
packages
=
find:
python_requires
=
>=3.7
# TODO: Check (Comment out everything and test what's really needed)!
setup_requires
=
setuptools
numpy>=1.6
pytest
pytest-runner
# TODO: Check!
tests_require
=
coverage
pytest
pytest-cov
pytest-flake8
pytest-runner
# TODO: Check!
install_requires
=
numpy>=1.6
tqdm
scipy
matplotlib
Pillow
h5py
hyperspy
cmocean
# jutil # TODO: How to handle this??? Ask Jörn!
[options.extras_require]
# TODO: necessary? Does it work with pip/conda?
3Dplot
=
qt
=
=4.8
mayavi
=
=4.5
# TODO: Pillow and such?
io
=
hyperspy
fftw
=
pyfftw
# TODO: Notebooks and stuff
# demos =
# TODO: Add? How?
# snippets =
# TODO: make this optional? Or silent fallback to matplotlib? stylesheet?
colors
=
cmocean
# TODO: Don't use too many!
# TODO: What about jupyter notebooks?
# TODO: Check all submodules if anything should be optional or is missing?
# TODO: in general, make CI test THESE requirements (maybe in addition to the environment.yml)
# TODO: more for mayavi (plotting in general) and hyperspy, etc (see below)...
# TODO: what about demos? see Hyperspy?
# CONFIGURATION FOR TESTING:
[aliases]
test
=
pytest
...
...
@@ -34,12 +110,16 @@ source = pyramid
omit
=
tests/*
[tool:pytest]
addopts
=
--cov --flake8
[tool:pytest]
# TODO: Check if everything is taylored to pyramid!
#
addopts = --cov --flake8
flake8-max-line-length
=
100
flake8-ignore
=
ALL
# TODO: PEP8 deactivated by this line (remove at a later point)!
E402
E124
E125
pyramid/__init__.py
F401
doc/conf.py
ALL
scripts/*.py
ALL
#ALL # TODO: PEP8 deactivated by this line (remove at a later point)!
E402
# module import not at top of file
E124
# closing bracket does not match visual indentation
E125
# continuation line with same indent as next logical line
E226
# missing whitespace around arithmetic operator
W503
# line break before binary operator
E741
# do not use variables named ‘l’, ‘O’, or ‘I’
pyramid/__init__.py
F401
# module imported but unused
#doc/conf.py ALL
This diff is collapsed.
Click to expand it.
setup.py
+
30
−
150
View file @
e471a8c9
...
...
@@ -3,172 +3,52 @@
"""
Setup for testing, building, distributing and installing the
'
Pyramid
'
-package
"""
import
os
import
re
import
subprocess
import
sys
import
itertools
#from distutils.command.build import build
from
setuptools
import
setup
from
setuptools.config
import
read_configuration
#import numpy
from
setuptools
import
setup
,
find_packages
DISTNAME
=
'
pyramid
'
DESCRIPTION
=
'
PYthon based Reconstruction Algorithm for MagnetIc Distributions
'
MAINTAINER
=
'
Jan Caron
'
MAINTAINER_EMAIL
=
'
j.caron@fz-juelich.de
'
URL
=
''
VERSION
=
'
0.1.0.dev0
'
# TODO: Better way?
PYTHON_VERSION
=
(
2
,
7
)
# TODO: get rid of!!!
DEPENDENCIES
=
{
'
numpy
'
:
(
1
,
10
)}
# TODO: get rid of!!!
LONG_DESCRIPTION
=
'
long description (TODO!)
'
# TODO: Long description! put in (Readme?) file!
# TODO: get rid of superfluous functions!
def
get_package_version
(
package
):
"""
Return the package version of the specified package.
Parameters
----------
package: basestring
Name of the package whic should be checked.
Returns
-------
version: tuple (N=3)
Version number as a tuple.
"""
version
=
[]
for
version_attr
in
(
'
version
'
,
'
VERSION
'
,
'
__version__
'
):
if
(
hasattr
(
package
,
version_attr
)
and
isinstance
(
getattr
(
package
,
version_attr
),
str
)):
version_info
=
getattr
(
package
,
version_attr
,
''
)
for
part
in
re
.
split
(
'
\D+
'
,
version_info
):
try
:
version
.
append
(
int
(
part
))
except
ValueError
:
pass
return
tuple
(
version
)
def
check_requirements
():
"""
Checks the requirements of the Pyramid package.
"""
if
sys
.
version_info
<
PYTHON_VERSION
:
raise
SystemExit
(
'
You need Python version %d.%d or later.
'
%
PYTHON_VERSION
)
for
package_name
,
min_version
in
DEPENDENCIES
.
items
():
dep_error
=
False
try
:
package
=
__import__
(
package_name
)
except
ImportError
:
dep_error
=
True
else
:
package_version
=
get_package_version
(
package
)
if
min_version
>
package_version
:
dep_error
=
True
if
dep_error
:
raise
ImportError
(
'
You need `%s` version %d.%d or later.
'
%
((
package_name
,)
+
min_version
))
def
hg_version
():
# TODO: Replace with GIT! Also check build output on GitLab! See numpy setup.py!
"""
Get the Mercurial reference identifier.
Returns
-------
hg_ref: basestring
The Mercurial reference identifier.
"""
def
git_version
():
'''
Get current git revision.
'''
try
:
h
g_rev
=
subprocess
.
check_output
([
'
h
g
'
,
'
id
'
,
'
--id
'
]).
strip
()
except
:
h
g_rev
=
"
???
"
return
h
g_rev
g
it
_rev
=
subprocess
.
check_output
([
'
g
it
'
,
'
rev-parse
'
,
'
HEAD
'
]).
strip
()
.
decode
()
except
Exception
:
g
it
_rev
=
"
???
"
return
g
it
_rev
def
write_version_py
(
filename
=
'
pyramid/version.py
'
):
"""
Write the version.py file.
Parameters
----------
filename: basestring, optional
Write the version and hg_revision into the specified python file.
Defaults to
'
pyramid/version.py
'
.
"""
def
write_version_py
(
version
,
git_version
,
filename
=
'
pyramid/version.py
'
):
'''
Write version.py file.
'''
version_string
=
'
# -*- coding: utf-8 -*-
\n
'
+
\
'""""
This file
is generated
automatically
by the Pyramid
`setup.py`
"""
\n
'
+
\
'
version =
"
{
}
"
\n
'
.
format
(
VERSION
)
+
\
'
hg
_revision =
"
{
}
"
\n
'
.
format
(
hg
_version
())
'""""
This file
was
automatically
generated by
`setup.py`
"""
\n
'
+
\
f
'
version =
"
{
version
}
"
\n
'
+
\
f
'
git
_revision =
"
{
git
_version
}
"
\n
'
with
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
filename
),
'
w
'
)
as
vfile
:
vfile
.
write
(
version_string
)
def
get_files
(
rootdir
):
"""
Returns a list of .py-files inside rootdir.
Parameters
----------
rootdir: basestring
Root directory in which to search for ``.py``-files.
Returns
-------
filepaths: list
List of filepaths which were found.
# Read setup.cfg (setup() would auto-read it, but we want to read the version and modify it here):
conf_dict
=
read_configuration
(
'
setup.cfg
'
)
metadata_dict
=
conf_dict
[
'
metadata
'
]
options_dict
=
conf_dict
[
'
options
'
]
"""
filepaths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
rootdir
):
for
filename
in
files
:
if
filename
.
endswith
(
'
.py
'
):
filepaths
.
append
(
os
.
path
.
join
(
root
,
filename
))
return
filepaths
# Read version and write to version.py:
version
=
metadata_dict
[
'
version
'
]
write_version_py
(
version
,
git_version
())
# Add 'full' convenience option to extras_require for full install: python setup.py install .[full]
full_list
=
list
(
itertools
.
chain
(
*
list
(
options_dict
[
'
extras_require
'
].
values
())))
options_dict
[
'
extras_require
'
][
'
full
'
]
=
full_list
# TODO: Outsource stuff to setup.cfg? See https://github.com/pypa/setuptools/pull/862
# Run setup:
setup
(
**
metadata_dict
,
**
options_dict
)
# TODO: Is this overwritten by setup.cfg again?
# TODO: Use requirements.txt? extras_require for optional stuff (hyperspy, plotting)?
# TODO: After split of Pyramid, comment out and see what really is used (is e.g. scipy?)!
install_requires
=
[
'
numpy>=1.6
'
,
'
tqdm
'
,
'
scipy
'
,
'
matplotlib
'
,
'
Pillow
'
,
'
h5py
'
,
'
hyperspy
'
,
'
jutil
'
,
'
cmocean
'
]
# TODO: extend extras_require for plotting and IO:
# TODO: extra: 'pyfftw', 'mayavi' (not easy to install... find a way!)
# TODO: See https://stackoverflow.com/a/28842733 for extras_require...
# TODO: ...replace [dev] with [IO] (hyperspy) and [plotting] (separate plotting library)!
extras_require
=
{
# TODO: Test all if really needed! don't use nose, if possible (pure pytest)!
'
tests
'
:
[
'
pytest
'
,
'
pytest-runner
'
,
'
pytest-cov
'
,
'
pytest-flake8
'
,
'
coverage
'
],
'
3Dplot
'
:
[
'
qt==4.8
'
,
'
mayavi==4.5
'
]
# TODO: not current!
# TODO: in general, make CI test THESE requirements (maybe in addition to the environment.yml)
# TODO: more for mayavi (plotting in general) and hyperspy, etc (see below)...
}
# TODO: Currently does not work, find out why!
extras_require
[
"
all
"
]
=
list
(
itertools
.
chain
(
*
list
(
extras_require
.
values
())))
# TODO: What about the demo?
# TODO: HOW TO GET JUTIL???
print
(
'
\n
-------------------------------------------------------------------------------
'
)
# print('checking requirements') # TODO: Get rid of!
# check_requirements()
print
(
'
write version.py
'
)
write_version_py
()
setup
(
name
=
DISTNAME
,
description
=
DESCRIPTION
,
long_description
=
LONG_DESCRIPTION
,
maintainer
=
MAINTAINER
,
maintainer_email
=
MAINTAINER_EMAIL
,
url
=
URL
,
download_url
=
URL
,
version
=
VERSION
,
packages
=
find_packages
(
exclude
=
[
'
tests
'
,
'
doc
'
]),
# TODO: necessary?
#include_dirs=[numpy.get_include()], # TODO: Maybe used for sphinx?!
#setup_requires=['numpy>=1.6', 'pytest', 'pytest-runner'],
#tests_require=['pytest', 'pytest-cov', 'pytest-flake8'],
install_requires
=
install_requires
,
extras_require
=
extras_require
,
#cmdclass={'build': build} # TODO: necessary?
)
print
(
'
-------------------------------------------------------------------------------
\n
'
)
# TODO: Also create conda recipe!
# TODO: Handle extras via metapackage (depends on pyramid-base that holds the core code and extras?)
# TODO: https://docs.conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-pkgs.html
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment