[opensuse-packaging] Some python help please
Trying to create a package from source that has no setup.py. THus to keep things simple I figured I'd create one myself ;) . But that's not working out the way I figured it would, thus I could use a hint or two. The source tree has packages in the lib directory, i.e. lib/a lib/b lib/c exist. The problem now is that some of these are dependencies that are already packaged. For simplicty lets say I am only interested in installing b. Thus in my setup.py file I have setuptools.setup( ..... .... packages=setuptools.find_packages('lib', exclude=['a','c']), package_dir={'': 'lib'} ) Based on the info that I found the "exclude" argument should tell find_packages to not consider those packages and this works. When running in an active session and printing the results of find_packages I get only stuff in "b". However when I run setup.py I still get "a" and "c" installed in the target directory :( I've played around with various settings for "package_dir" but couldn't figure out a way to make setup happy and only get the "b" package installed into the target directory. How do I do that? Help is appreciated, Thanks, Robert -- Robert Schweikert MAY THE SOURCE BE WITH YOU SUSE-IBM Software Integration Center LINUX Tech Lead Public Cloud Architect rjschwei@suse.com rschweik@ca.ibm.com 781-464-8147 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 02/04/2014 02:46 PM, Robert Schweikert wrote:
Trying to create a package from source that has no setup.py. THus to keep things simple I figured I'd create one myself ;) . But that's not working out the way I figured it would, thus I could use a hint or two.
The source tree has packages in the lib directory, i.e. lib/a lib/b lib/c exist. The problem now is that some of these are dependencies that are already packaged. For simplicty lets say I am only interested in installing b.
Thus in my setup.py file I have
setuptools.setup( ..... .... packages=setuptools.find_packages('lib', exclude=['a','c']), package_dir={'': 'lib'} )
Based on the info that I found the "exclude" argument should tell find_packages to not consider those packages and this works. When running in an active session and printing the results of find_packages I get only stuff in "b".
However when I run setup.py I still get "a" and "c" installed in the target directory :(
When you say "when I run setup.py" do you mean you are calling python setup.py build and then you are looking in the "build" directory and seeing that the folders "lib/a" and "lib/c" still exist there? If that is the case, you can run "python setup.py clean --all" to remove the build directory and start fresh. The build command won't remove those folders if they already exist in the build output. Also, for some reason the clean command without the --all flag doesn't remove the build directory, only some "temporary files" which is unclear to me what that actually means. I think your packages and package_dir parameters are good for what you are trying to do. -- Jason Craig -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 02/04/2014 09:58 PM, Jason Craig wrote:
On 02/04/2014 02:46 PM, Robert Schweikert wrote:
Trying to create a package from source that has no setup.py. THus to keep things simple I figured I'd create one myself ;) . But that's not working out the way I figured it would, thus I could use a hint or two.
The source tree has packages in the lib directory, i.e. lib/a lib/b lib/c exist. The problem now is that some of these are dependencies that are already packaged. For simplicty lets say I am only interested in installing b.
Thus in my setup.py file I have
setuptools.setup( ..... .... packages=setuptools.find_packages('lib', exclude=['a','c']), package_dir={'': 'lib'} )
Based on the info that I found the "exclude" argument should tell find_packages to not consider those packages and this works. When running in an active session and printing the results of find_packages I get only stuff in "b".
However when I run setup.py I still get "a" and "c" installed in the target directory :(
When you say "when I run setup.py" do you mean you are calling
python setup.py build
Ooops, sorry should have been more specific, I run -> python setup.py install --prefix=/usr --root=/work/tmp/testInstall Then /work/tmp/testInstall/usr/lib/python2.7/site-packages/ contains a, b, and c, much to my dismay.
and then you are looking in the "build" directory and seeing that the folders "lib/a" and "lib/c" still exist there? If that is the case, you can run "python setup.py clean --all" to remove the build directory and start fresh. The build command won't remove those folders if they already exist in the build output. Also, for some reason the clean command without the --all flag doesn't remove the build directory, only some "temporary files" which is unclear to me what that actually means.
I think your packages and package_dir parameters are good for what you are trying to do.
I guess I'll have to invent some other code in setup.py to isolate b from its dependencies. Grmbl. Thanks, Robert -- Robert Schweikert MAY THE SOURCE BE WITH YOU SUSE-IBM Software Integration Center LINUX Tech Lead Public Cloud Architect rjschwei@suse.com rschweik@ca.ibm.com 781-464-8147 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Wednesday 05 February 2014 08:14:03 Robert Schweikert wrote:
On 02/04/2014 09:58 PM, Jason Craig wrote:
On 02/04/2014 02:46 PM, Robert Schweikert wrote:
Trying to create a package from source that has no setup.py. THus to keep things simple I figured I'd create one myself ;) . But that's not working out the way I figured it would, thus I could use a hint or two.
The source tree has packages in the lib directory, i.e. lib/a lib/b lib/c exist. The problem now is that some of these are dependencies that are already packaged. For simplicty lets say I am only interested in installing b.
Thus in my setup.py file I have
setuptools.setup(
..... .... packages=setuptools.find_packages('lib', exclude=['a','c']), package_dir={'': 'lib'}
)
Based on the info that I found the "exclude" argument should tell find_packages to not consider those packages and this works. When running in an active session and printing the results of find_packages I get only stuff in "b".
However when I run setup.py I still get "a" and "c" installed in the target directory :(
When you say "when I run setup.py" do you mean you are calling
python setup.py build
Ooops, sorry should have been more specific, I run
-> python setup.py install --prefix=/usr --root=/work/tmp/testInstall
Then /work/tmp/testInstall/usr/lib/python2.7/site-packages/
contains a, b, and c, much to my dismay.
and then you are looking in the "build" directory and seeing that the folders "lib/a" and "lib/c" still exist there? If that is the case, you can run "python setup.py clean --all" to remove the build directory and start fresh. The build command won't remove those folders if they already exist in the build output. Also, for some reason the clean command without the --all flag doesn't remove the build directory, only some "temporary files" which is unclear to me what that actually means.
I think your packages and package_dir parameters are good for what you are trying to do.
I guess I'll have to invent some other code in setup.py to isolate b from its dependencies. Grmbl.
Either specifying all (sub-)modules directly: packages=["b"], or the setuptools-lazy-bunch way: packages=find_packages(exclude=["a","c"]), will work. Your mistake seems to be the (first positional) argument. It's not needed (and could be redundant with packages_dir), check http://pythonhosted.org/setuptools/setuptools.html#using-find-packages. You can dry-run with python setup.py sdist (or bdist) and check dist/$foo.tar.gz contents. -- With kind regards, Sascha Peilicke SUSE Linux GmbH, Maxfeldstr. 5, D-90409 Nuernberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 02/05/2014 09:27 AM, Sascha Peilicke wrote:
On Wednesday 05 February 2014 08:14:03 Robert Schweikert wrote:
On 02/04/2014 09:58 PM, Jason Craig wrote:
On 02/04/2014 02:46 PM, Robert Schweikert wrote:
Trying to create a package from source that has no setup.py. THus to keep things simple I figured I'd create one myself ;) . But that's not working out the way I figured it would, thus I could use a hint or two.
The source tree has packages in the lib directory, i.e. lib/a lib/b lib/c exist. The problem now is that some of these are dependencies that are already packaged. For simplicty lets say I am only interested in installing b.
Thus in my setup.py file I have
setuptools.setup(
..... .... packages=setuptools.find_packages('lib', exclude=['a','c']), package_dir={'': 'lib'}
)
Based on the info that I found the "exclude" argument should tell find_packages to not consider those packages and this works. When running in an active session and printing the results of find_packages I get only stuff in "b".
However when I run setup.py I still get "a" and "c" installed in the target directory :(
When you say "when I run setup.py" do you mean you are calling
python setup.py build
Ooops, sorry should have been more specific, I run
-> python setup.py install --prefix=/usr --root=/work/tmp/testInstall
Then /work/tmp/testInstall/usr/lib/python2.7/site-packages/
contains a, b, and c, much to my dismay.
and then you are looking in the "build" directory and seeing that the folders "lib/a" and "lib/c" still exist there? If that is the case, you can run "python setup.py clean --all" to remove the build directory and start fresh. The build command won't remove those folders if they already exist in the build output. Also, for some reason the clean command without the --all flag doesn't remove the build directory, only some "temporary files" which is unclear to me what that actually means.
I think your packages and package_dir parameters are good for what you are trying to do.
I guess I'll have to invent some other code in setup.py to isolate b from its dependencies. Grmbl.
Either specifying all (sub-)modules directly:
packages=["b"],
or the setuptools-lazy-bunch way:
packages=find_packages(exclude=["a","c"]),
will work. Your mistake seems to be the (first positional) argument. It's not needed (and could be redundant with packages_dir), check http://pythonhosted.org/setuptools/setuptools.html#using-find-packages.
Hmm, dropping the "lib" from findpackages() resulted in nothing being installed. I guess the tools don't really support what simple interpretation would think they do. I'll write some code that finagles the directory structure, ugh do I hate this. Thanks, Robert -- Robert Schweikert MAY THE SOURCE BE WITH YOU SUSE-IBM Software Integration Center LINUX Tech Lead Public Cloud Architect rjschwei@suse.com rschweik@ca.ibm.com 781-464-8147 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 02/06/2014 12:47 PM, Robert Schweikert wrote:
On 02/05/2014 09:27 AM, Sascha Peilicke wrote:
On Wednesday 05 February 2014 08:14:03 Robert Schweikert wrote:
On 02/04/2014 09:58 PM, Jason Craig wrote:
On 02/04/2014 02:46 PM, Robert Schweikert wrote:
Hmm, dropping the "lib" from findpackages() resulted in nothing being installed.
I guess the tools don't really support what simple interpretation would think they do. I'll write some code that finagles the directory structure, ugh do I hate this.
Thanks, Robert
I've filled out a basic setup.py thusly: import setuptools setuptools.setup(name="Test", version="0.1", description="Python Package Test", packages=setuptools.find_packages('lib', exclude=["a"]), package_dir = {"": "lib"}) with simple packages in lib/a, lib/b, lib/c and run "python setup.py install ..." and I am only getting the b and c packages in the install directory. If I run it again without the exclude param, I get a, b, c. If I "python setup.py clean --all" and then install again with the exclude re-added, I still have a, b, c in the install directory. My conclusion is that the install directory is not getting cleared in between runs of install, so you should delete that manually, run "clean --all" to make sure your build dir is also cleaned, and then I think you will see the behavior you desire. -- Jason Craig -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (3)
-
Jason Craig
-
Robert Schweikert
-
Sascha Peilicke