6

Goals:

  • Make use of modern Python packaging toolsets to deploy/install proprietary packages into some virtualenv.
  • The installed packages should include compiled *.pyc(or *.pyo) only without source files.
  • There are a couple of packages, and a vendor name (here we choose dgmx for our studio) is used as the package names. Therefore, the installed packages would be something like dgmx/alucard, dgmx/banshee, dgmx/carmilla, ...
  • The file hierarchy of installed packages should be like ones by python setup.py install --single-version-externally-managed or pip install. Refer to How come I can't get the exactly result to *pip install* by manually *python setup.py install*?

Question in short:

I like to deploy proprietary namespaced packages into a virtualenv by only compiled *.pyc(or *.pyo) files, in which the file/directory hierarchy just reflects the namespace with polluting sys.path by lots of ooxx.egg paths.

Something I have tried:

  1. python setup.py bdist_egg --exclude-source-files then easy_install ooxx.egg.
    • pollute "sys.path" for each namespace package.
  2. python setup.py install --single-version-externally-managed.
    • not *.pyc only.
    • the "install_requires" got ignored!
    • need to manually put a ooxx.egg-info/installed-files.txt to make uninstall work correctly.
  3. pip install . in the location of "setup.py".
    • not *.pyc only.
  4. pysetup install . in the location of "setup.py".
    • not *.pyc only.

Update:

My current idea is to follow method 2.

  • python setup.py egg_info --egg-base . # get requires.txt
  • python setup.py install --single-version-externally-managed --record installed-files.txt # get installed-files.txt
  • manually install other dependencies through "requires.txt"
  • manually delete installed source files (*.py) through "installed-files.txt"
  • remove source files (*.py) from "installed-files.txt" and put it into deployed "ooxx.egg-info/installed-files.txt"

References:

  1. Migrating to pip+virtualenv from setuptools
  2. installing only .pyc (python compiled) with setuptools
  3. Can I deploy Python .pyc files only to Google App Engine?
  4. How come I can't get the exactly result to *pip install* by manually *python setup.py install*?
Community
  • 1
  • 1
Drake Guan
  • 14,514
  • 15
  • 67
  • 94

1 Answers1

-1

Some trick may help:

Compile your source into .pyc, zip them up in a single .zip file.

Write a new module with a simple module all it does is to add the .zip to the sys.path.

So when you import this module, the .zip is in the path. All you have to do is in a custom step in setup.py, copy the zip file to the proper place.

BOYPT
  • 329
  • 1
  • 4
  • 11
  • In case of Python called an `egg`, and he already mentioned that in the question (first option he has tried). – vartec Apr 17 '12 at 10:51