Creating a new installation layout

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a new installation layout

Tim Cuthbertson
I'm curious, how would one create a new layout? (as in a --layout=deb
alternative). I'd very much like to have a layout that doesn't include
any version information in the path, which both "deb" and "unix" do.
Ideally, output would look pretty much like:

bin/
bin/script1
bin/script2
lib/
lib/some_c_ext.so
lib/python/
lib/python/packagename/
lib/python/packagename/__init__.py
lib/python/packagename/core.py

Something simple, without the unnecessary layers of "usr", "local",
"site-packages", "python2.7" etc. The purpose is to be put into a
self-contained archive, so it's completely unnecessary to include such
namespacing (it will never be mixed in with any other files).

Is this possible? not worth it?


Right now to achieve at least version independence on the paths I'm running :

python setup.py install --root="$DISTDIR"
--single-version-externally-managed --install-layout=deb && \
mv "$DISTDIR/usr/lib/"python* "$DISTDIR/usr/lib/python"

which is hacky, but works. And you end up with paths like
"usr/lib/python/dist-packages" inside the archive, which is just
unnecessarily nested for a standalone archive.
_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new installation layout

PJ Eby


On Apr 8, 2012 7:47 AM, "Tim Cuthbertson" <[hidden email]> wrote:
>
> I'm curious, how would one create a new layout? (as in a --layout=deb
> alternative). I'd very much like to have a layout that doesn't include
> any version information in the path, which both "deb" and "unix" do.
> Ideally, output would look pretty much like:
>
> bin/
> bin/script1
> bin/script2
> lib/
> lib/some_c_ext.so
> lib/python/
> lib/python/packagename/
> lib/python/packagename/__init__.py
> lib/python/packagename/core.py

Use "setup.py install --single-version-externally-managed --install-lib=lib/python --install-scripts=bin"; add other options for any other directories as needed.

You can configure these options in your .pydistutils.cfg so as to not have to set them every time you create an installation.

> Something simple, without the unnecessary layers of "usr", "local",
> "site-packages", "python2.7" etc. The purpose is to be put into a
> self-contained archive, so it's completely unnecessary to include such
> namespacing (it will never be mixed in with any other files).

FWIW, you can use bdist_egg to create a similar archive, except that lib/ is replaced by ./ and bin/ is replaced by EGG-INFO/scripts/.


_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new installation layout

Tim Cuthbertson
On Tue, Apr 10, 2012 at 3:18 PM, PJ Eby <[hidden email]> wrote:

>
> On Apr 8, 2012 7:47 AM, "Tim Cuthbertson" <[hidden email]> wrote:
>>
>> I'm curious, how would one create a new layout? (as in a --layout=deb
>> alternative). I'd very much like to have a layout that doesn't include
>> any version information in the path, which both "deb" and "unix" do.
>> Ideally, output would look pretty much like:
>>
>> bin/
>> bin/script1
>> bin/script2
>> lib/
>> lib/some_c_ext.so
>> lib/python/
>> lib/python/packagename/
>> lib/python/packagename/__init__.py
>> lib/python/packagename/core.py
>
> Use "setup.py install --single-version-externally-managed
> --install-lib=lib/python --install-scripts=bin"; add other options for any
> other directories as needed.

Cheers, will look into it. Is there a canonical list of what possible
directories, or should I just look at the --help output?

Am I going to run into trouble where some projects have different
options? For example, calling `python setup.py` could be implemented
by distutils, setuptools, distribute, and god knows what else. I would
like for the same options to work across all backends, since I'm
building a lot of libraries without wanting to care too deeply about
which build system they use. Is this doable, or would it potentially
have to be crafted to each package?

> You can configure these options in your .pydistutils.cfg so as to not have
> to set them every time you create an installation.
>
>> Something simple, without the unnecessary layers of "usr", "local",
>> "site-packages", "python2.7" etc. The purpose is to be put into a
>> self-contained archive, so it's completely unnecessary to include such
>> namespacing (it will never be mixed in with any other files).
>
> FWIW, you can use bdist_egg to create a similar archive, except that lib/ is
> replaced by ./ and bin/ is replaced by EGG-INFO/scripts/.

True, although I want a folder, not an archive. I could unpack it, but
the less steps in a build script the better.
_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new installation layout

PJ Eby
On Tue, Apr 10, 2012 at 1:35 AM, Tim Cuthbertson <[hidden email]> wrote:
Cheers, will look into it. Is there a canonical list of what possible
directories, or should I just look at the --help output?

The latter.
 

Am I going to run into trouble where some projects have different
options? For example, calling `python setup.py` could be implemented
by distutils, setuptools, distribute, and god knows what else.

I can't speak for "what else", but the first three tools you mention support the same installation directory options for setup.py.  (Except distutils itself doesn't recognize --single-version-externally-managed.)
 

True, although I want a folder, not an archive. I could unpack it, but
the less steps in a build script the better.

Well, if you're willing to use setuptools or distribute, you can do  "easy_install -mxNZd tempdir projectdir", where projectdir is a directory with a setup.py.  After running this command, tempdir will have a single .egg subdirectory added to it, containing a version of the library with a known directory layout.  You can then do something like:

cd tempdir
mv *.egg/EGG-INFO/scripts bin
mv *.egg lib

To get your desired layout.  For bonus points, you can rename the EGG-INFO/ subdirectory to packagename.egg-info/.  ;-)


_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig