Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
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
Chen Yisong
lxc
Commits
8c041c2f
Commit
8c041c2f
authored
May 27, 2016
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1031 from GreatFruitOmsk/pypi
python-lxc: enable standalone builds
parents
95ca286d
f2fec475
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
125 additions
and
30 deletions
+125
-30
.gitignore
.gitignore
+0
-1
configure.ac
configure.ac
+0
-1
Makefile.am
src/python-lxc/Makefile.am
+9
-5
lxc.c
src/python-lxc/lxc.c
+80
-3
setup.py
src/python-lxc/setup.py
+36
-20
No files found.
.gitignore
View file @
8c041c2f
...
@@ -66,7 +66,6 @@ src/lxc/lxc-wait
...
@@ -66,7 +66,6 @@ src/lxc/lxc-wait
src/lxc/lxc-user-nic
src/lxc/lxc-user-nic
src/lxc/version.h
src/lxc/version.h
src/python-lxc/setup.py
src/python-lxc/build/
src/python-lxc/build/
src/python-lxc/lxc/__pycache__/
src/python-lxc/lxc/__pycache__/
...
...
configure.ac
View file @
8c041c2f
...
@@ -847,7 +847,6 @@ AC_CONFIG_FILES([
...
@@ -847,7 +847,6 @@ AC_CONFIG_FILES([
src/lxc/lxc.functions
src/lxc/lxc.functions
src/lxc/version.h
src/lxc/version.h
src/python-lxc/Makefile
src/python-lxc/Makefile
src/python-lxc/setup.py
src/lua-lxc/Makefile
src/lua-lxc/Makefile
...
...
src/python-lxc/Makefile.am
View file @
8c041c2f
...
@@ -6,21 +6,25 @@ else
...
@@ -6,21 +6,25 @@ else
DISTSETUPOPTS
=
DISTSETUPOPTS
=
endif
endif
INSTALL_OPTS
:=
install
--prefix
=
$(prefix)
--no-compile
$(DISTSETUPOPTS)
CALL_SETUP_PY
:=
cd
@srcdir@
&&
$(PYTHON)
setup.py build
-b
@abs_builddir@/build
all
:
all
:
$(
PYTHON)
setup.py build
$(
CALL_SETUP_PY)
build_ext
-I
@abs_top_srcdir@/src
-L
@abs_top_builddir@/src/lxc
--no-pkg-config
install
:
install
:
if
[
"
$(DESTDIR)
"
=
"
"
]
;
then
\
if
[
-z
"
$(DESTDIR)
"
]
;
then
\
$(
PYTHON)
setup.py
install
--prefix
=
$(prefix)
--no-compile
$(DISTSETUP
OPTS)
;
\
$(
CALL_SETUP_PY)
$(INSTALL_
OPTS)
;
\
else
\
else
\
$(
PYTHON)
setup.py
install
--root
=
$(DESTDIR)
--prefix
=
$(prefix)
--no-compile
$(DISTSETUPOPTS
)
;
\
$(
CALL_SETUP_PY)
$(INSTALL_OPTS)
--root
=
$(DESTDIR
)
;
\
fi
fi
clean-local
:
clean-local
:
rm
-rf
build
rm
-rf
@builddir@/
build
endif
endif
EXTRA_DIST
=
\
EXTRA_DIST
=
\
setup.py
\
lxc.c
\
lxc.c
\
lxc/__init__.py
\
lxc/__init__.py
\
examples/api_test.py
\
examples/api_test.py
\
...
...
src/python-lxc/lxc.c
View file @
8c041c2f
...
@@ -25,14 +25,91 @@
...
@@ -25,14 +25,91 @@
#include <Python.h>
#include <Python.h>
#include "structmember.h"
#include "structmember.h"
#include <lxc/lxccontainer.h>
#include <lxc/lxccontainer.h>
#include "lxc/utils.h"
#include "lxc/namespace.h"
#include "lxc/confile.h"
#include <stdio.h>
#include <stdio.h>
#include <sys/wait.h>
#include <sys/wait.h>
#include <sched.h>
/*
* CLONE_* definitions copied from lxc/namespace.h
*/
#ifndef CLONE_FS
# define CLONE_FS 0x00000200
#endif
#ifndef CLONE_NEWNS
# define CLONE_NEWNS 0x00020000
#endif
#ifndef CLONE_NEWCGROUP
# define CLONE_NEWCGROUP 0x02000000
#endif
#ifndef CLONE_NEWUTS
# define CLONE_NEWUTS 0x04000000
#endif
#ifndef CLONE_NEWIPC
# define CLONE_NEWIPC 0x08000000
#endif
#ifndef CLONE_NEWUSER
# define CLONE_NEWUSER 0x10000000
#endif
#ifndef CLONE_NEWPID
# define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWNET
# define CLONE_NEWNET 0x40000000
#endif
/* From sys/personality.h */
#define PER_LINUX 0x0000
#define PER_LINUX32 0x0008
/* Helper functions */
/* Helper functions */
/* Copied from lxc/utils.c */
static
int
lxc_wait_for_pid_status
(
pid_t
pid
)
{
int
status
,
ret
;
again:
ret
=
waitpid
(
pid
,
&
status
,
0
);
if
(
ret
==
-
1
)
{
if
(
errno
==
EINTR
)
goto
again
;
return
-
1
;
}
if
(
ret
!=
pid
)
goto
again
;
return
status
;
}
/* Copied from lxc/confile.c, with HAVE_SYS_PERSONALITY_H check removed */
signed
long
lxc_config_parse_arch
(
const
char
*
arch
)
{
struct
per_name
{
char
*
name
;
unsigned
long
per
;
}
pername
[]
=
{
{
"x86"
,
PER_LINUX32
},
{
"linux32"
,
PER_LINUX32
},
{
"i386"
,
PER_LINUX32
},
{
"i486"
,
PER_LINUX32
},
{
"i586"
,
PER_LINUX32
},
{
"i686"
,
PER_LINUX32
},
{
"athlon"
,
PER_LINUX32
},
{
"linux64"
,
PER_LINUX
},
{
"x86_64"
,
PER_LINUX
},
{
"amd64"
,
PER_LINUX
},
};
size_t
len
=
sizeof
(
pername
)
/
sizeof
(
pername
[
0
]);
size_t
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
strcmp
(
pername
[
i
].
name
,
arch
))
return
pername
[
i
].
per
;
}
return
-
1
;
}
char
**
char
**
convert_tuple_to_char_pointer_array
(
PyObject
*
argv
)
{
convert_tuple_to_char_pointer_array
(
PyObject
*
argv
)
{
int
argc
;
int
argc
;
...
...
src/python-lxc/setup.py
.in
→
src/python-lxc/setup.py
View file @
8c041c2f
...
@@ -22,30 +22,45 @@
...
@@ -22,30 +22,45 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
# USA
import
os
,
os
.
path
import
os
import
subprocess
from
distutils.core
import
setup
,
Extension
from
distutils.core
import
setup
,
Extension
from
distutils.command.build_ext
import
build_ext
as
BuildExtCommand
# Distutils doesn't cope well with source files that have relative paths going
# up in the directory tree: it tries to navigate outside of the build dir and
# fails miserably. Therefore, we will instead cd to the source directory,
# run this script from there, but write the build products to the correct path.
#
# Since we will be changing directories before building, we must transform
# all the path variables to their forms relative to srcdir.
srcdir
,
builddir
,
top_srcdir
,
top_builddir
=
map
(
os
.
path
.
abspath
,
class
LxcBuildExtCommand
(
BuildExtCommand
):
[
"@srcdir@"
,
"@builddir@"
,
"@top_srcdir@"
,
"@top_builddir@"
])
user_options
=
BuildExtCommand
.
user_options
+
[
(
'no-pkg-config'
,
None
,
"don't use pkg-config to detect include/library paths"
)
]
def
initialize_options
(
self
):
super
(
LxcBuildExtCommand
,
self
)
.
initialize_options
()
self
.
no_pkg_config
=
False
def
build_extensions
(
self
):
if
not
self
.
no_pkg_config
:
pkg_config_executable
=
os
.
environ
.
get
(
'PKG_CONFIG_EXECUTABLE'
,
'pkg-config'
)
def
get_pkg_config_var
(
name
):
args
=
[
pkg_config_executable
,
'--variable'
,
name
,
'lxc'
]
output
=
subprocess
.
check_output
(
args
,
universal_newlines
=
True
)
return
output
.
rstrip
(
'
\n
'
)
try
:
includedir
=
get_pkg_config_var
(
'includedir'
)
libdir
=
get_pkg_config_var
(
'libdir'
)
builddir
,
top_srcdir
,
top_builddir
=
map
(
lambda
d
:
os
.
path
.
relpath
(
d
,
srcdir
),
self
.
compiler
.
add_include_dir
(
includedir
)
[
builddir
,
top_srcdir
,
top_builddir
]
)
self
.
compiler
.
add_library_dir
(
libdir
)
os
.
chdir
(
srcdir
)
except
subprocess
.
CalledProcessError
:
pass
module
=
Extension
(
'_lxc'
,
sources
=
[
'lxc.c'
],
super
(
LxcBuildExtCommand
,
self
)
.
build_extensions
()
include_dirs
=
[
os
.
path
.
join
(
top_srcdir
,
'src'
),
os
.
path
.
join
(
top_builddir
,
'src'
)],
library_dirs
=
[
os
.
path
.
join
(
top_builddir
,
'src/lxc'
)],
libraries
=
[
'lxc'
])
setup
(
name
=
'_lxc'
,
setup
(
name
=
'_lxc'
,
...
@@ -53,5 +68,6 @@ setup(name='_lxc',
...
@@ -53,5 +68,6 @@ setup(name='_lxc',
description
=
'LXC'
,
description
=
'LXC'
,
packages
=
[
'lxc'
],
packages
=
[
'lxc'
],
package_dir
=
{
'lxc'
:
'lxc'
},
package_dir
=
{
'lxc'
:
'lxc'
},
ext_modules
=
[
module
],
ext_modules
=
[
Extension
(
'_lxc'
,
sources
=
[
'lxc.c'
],
libraries
=
[
'lxc'
])],
options
=
{
'build'
:
{
'build_base'
:
os
.
path
.
join
(
builddir
,
'build'
)}})
cmdclass
=
{
'build_ext'
:
LxcBuildExtCommand
},
)
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