Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
logilab-mtconverter
Commits
35c0f6eb461e
Commit
625e01cd
authored
Aug 06, 2015
by
Julien Cristau
Browse files
[pkg] Always use setuptools (closes #487330)
parent
af1d69fcf218
Changes
5
Show whitespace changes
Inline
Side-by-side
logilab/mtconverter/
__pkginfo__.py
→
__pkginfo__.py
View file @
35c0f6eb
...
...
@@ -26,7 +26,6 @@ version = '.'.join([str(num) for num in numversion])
license
=
'LGPL'
web
=
"http://www.logilab.org/project/%s"
%
distname
ftp
=
"ftp://ftp.logilab.org/pub/%s"
%
modname
mailinglist
=
"mailto://python-projects@lists.logilab.org"
description
=
"a library to convert from a MIME type to another"
...
...
debian/rules
View file @
35c0f6eb
...
...
@@ -11,8 +11,6 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export NO_SETUPTOOLS=1
include /usr/share/python/python.mk
# don't build the python3 package if python3 is < 3.3
py3k = $(subst python3.,,$(shell py3versions -d))
...
...
logilab/mtconverter/__init__.py
View file @
35c0f6eb
...
...
@@ -29,8 +29,6 @@ from __future__ import print_function
__docformat__
=
"restructuredtext en"
from
logilab.mtconverter.__pkginfo__
import
version
as
__version__
import
locale
import
mimetypes
import
re
...
...
@@ -44,6 +42,9 @@ from io import BytesIO
from
six
import
text_type
,
binary_type
,
int2byte
,
unichr
from
six.moves.html_entities
import
name2codepoint
import
pkg_resources
__version__
=
pkg_resources
.
get_distribution
(
'logilab-mtconverter'
).
version
try
:
import
chardet
except
ImportError
:
...
...
python-logilab-mtconverter.spec
View file @
35c0f6eb
...
...
@@ -44,7 +44,7 @@ find . -name '*.py' -type f -print0 | xargs -0 sed -i '1,3s;^#!.*python.*$;#! /
%install
rm -rf $RPM_BUILD_ROOT
NO_SETUPTOOLS=1
%{__python} setup.py install -O1 --skip-build --root="$RPM_BUILD_ROOT"
%{__python} setup.py install -O1 --skip-build --root="$RPM_BUILD_ROOT"
rm -rf $RPM_BUILD_ROOT%{_python_sitelib}/logilab/__init__.py*
%clean
...
...
setup.py
View file @
35c0f6eb
...
...
@@ -25,120 +25,45 @@ __docformat__ = "restructuredtext en"
import
os
import
sys
import
shutil
from
os.path
import
isdir
,
exists
,
join
from
os.path
import
isdir
,
exists
,
join
,
dirname
,
abspath
try
:
if
os
.
environ
.
get
(
'NO_SETUPTOOLS'
):
raise
ImportError
()
from
setuptools
import
setup
from
setuptools.command
import
install_lib
USE_SETUPTOOLS
=
1
except
ImportError
:
from
distutils.core
import
setup
from
distutils.command
import
install_lib
USE_SETUPTOOLS
=
0
from
setuptools
import
setup
,
find_packages
here
=
abspath
(
dirname
(
__file__
))
# import optional features
__pkginfo__
=
__import__
(
"logilab.mtconverter.__pkginfo__"
).
mtconverter
.
__pkginfo__
pkginfo
=
{}
with
open
(
join
(
here
,
'__pkginfo__.py'
))
as
f
:
exec
(
f
.
read
(),
pkginfo
)
# import required features
modname
=
__
pkginfo
__
.
modname
version
=
__
pkginfo
__
.
version
license
=
__
pkginfo
__
.
license
description
=
__
pkginfo
__
.
description
web
=
__
pkginfo
__
.
web
author
=
__
pkginfo
__
.
author
author_email
=
__
pkginfo
__
.
author_email
modname
=
pkginfo
[
'
modname
'
]
version
=
pkginfo
[
'
version
'
]
license
=
pkginfo
[
'
license
'
]
description
=
pkginfo
[
'
description
'
]
web
=
pkginfo
[
'
web
'
]
author
=
pkginfo
[
'
author
'
]
author_email
=
pkginfo
[
'
author_email
'
]
distname
=
getattr
(
__pkginfo__
,
'distname'
,
modname
)
scripts
=
getattr
(
__pkginfo__
,
'scripts'
,
[])
data_files
=
getattr
(
__pkginfo__
,
'data_files'
,
None
)
subpackage_of
=
getattr
(
__pkginfo__
,
'subpackage_of'
,
None
)
include_dirs
=
getattr
(
__pkginfo__
,
'include_dirs'
,
[])
ext_modules
=
getattr
(
__pkginfo__
,
'ext_modules'
,
None
)
install_requires
=
getattr
(
__pkginfo__
,
'install_requires'
,
None
)
dependency_links
=
getattr
(
__pkginfo__
,
'dependency_links'
,
[])
distname
=
pkginfo
.
get
(
'distname'
,
modname
)
data_files
=
pkginfo
.
get
(
'data_files'
,
None
)
subpackage_of
=
pkginfo
.
get
(
'subpackage_of'
,
None
)
include_dirs
=
pkginfo
.
get
(
'include_dirs'
,
[])
ext_modules
=
pkginfo
.
get
(
'ext_modules'
,
None
)
install_requires
=
pkginfo
.
get
(
'install_requires'
,
None
)
dependency_links
=
pkginfo
.
get
(
'dependency_links'
,
[])
STD_BLACKLIST
=
(
'CVS'
,
'.svn'
,
'.hg'
,
'debian'
,
'dist'
,
'build'
)
IGNORED_EXTENSIONS
=
(
'.pyc'
,
'.pyo'
,
'.elc'
,
'~'
)
if
exists
(
'README'
):
long_description
=
open
(
'README'
).
read
()
if
exists
(
join
(
here
,
'README'
)
)
:
long_description
=
open
(
join
(
here
,
'README'
)
)
.
read
()
else
:
long_description
=
''
def
ensure_scripts
(
linux_scripts
):
"""Creates the proper script names required for each platform
(taken from 4Suite)
"""
from
distutils
import
util
if
util
.
get_platform
()[:
3
]
==
'win'
:
scripts_
=
[
script
+
'.bat'
for
script
in
linux_scripts
]
else
:
scripts_
=
linux_scripts
return
scripts_
def
get_packages
(
directory
,
prefix
):
"""return a list of subpackages for the given directory"""
result
=
[]
for
package
in
os
.
listdir
(
directory
):
absfile
=
join
(
directory
,
package
)
if
isdir
(
absfile
):
if
exists
(
join
(
absfile
,
'__init__.py'
))
or
\
package
in
(
'test'
,
'tests'
):
if
prefix
:
result
.
append
(
'%s.%s'
%
(
prefix
,
package
))
else
:
result
.
append
(
package
)
result
+=
get_packages
(
absfile
,
result
[
-
1
])
return
result
EMPTY_FILE
=
'''"""generated file, don't modify or your data will be lost"""
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
pass
'''
class
MyInstallLib
(
install_lib
.
install_lib
):
"""extend install_lib command to handle package __init__.py and
include_dirs variable if necessary
"""
def
run
(
self
):
"""overridden from install_lib class"""
install_lib
.
install_lib
.
run
(
self
)
# create Products.__init__.py if needed
if
subpackage_of
:
product_init
=
join
(
self
.
install_dir
,
subpackage_of
,
'__init__.py'
)
if
not
exists
(
product_init
):
self
.
announce
(
'creating %s'
%
product_init
)
stream
=
open
(
product_init
,
'w'
)
stream
.
write
(
EMPTY_FILE
)
stream
.
close
()
# manually install included directories if any
if
include_dirs
:
if
subpackage_of
:
base
=
join
(
subpackage_of
,
modname
)
else
:
base
=
modname
for
directory
in
include_dirs
:
dest
=
join
(
self
.
install_dir
,
base
,
directory
)
shutil
.
rmtree
(
dest
,
ignore_errors
=
True
)
shutil
.
copytree
(
directory
,
dest
)
def
install
(
**
kwargs
):
"""setup entry point"""
if
USE_SETUPTOOLS
:
if
'--force-manifest'
in
sys
.
argv
:
sys
.
argv
.
remove
(
'--force-manifest'
)
package
=
subpackage_of
+
'.'
+
modname
packages
=
get_packages
(
os
.
getcwd
(),
''
)
if
USE_SETUPTOOLS
:
kwargs
[
'namespace_packages'
]
=
[
subpackage_of
]
kwargs
[
'install_requires'
]
=
install_requires
kwargs
[
'dependency_links'
]
=
dependency_links
kwargs
[
'packages'
]
=
packages
return
setup
(
name
=
distname
,
version
=
version
,
license
=
license
,
...
...
@@ -147,10 +72,11 @@ def install(**kwargs):
author
=
author
,
author_email
=
author_email
,
url
=
web
,
scripts
=
ensure_scripts
(
scripts
),
packages
=
find_packages
(
exclude
=
[
'test*'
]
),
data_files
=
data_files
,
ext_modules
=
ext_modules
,
cmdclass
=
{
'install_lib'
:
MyInstallLib
},
namespace_packages
=
[
subpackage_of
],
install_requires
=
install_requires
,
**
kwargs
)
...
...
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