Giter Site home page Giter Site logo

Comments (6)

mbokil avatar mbokil commented on June 21, 2024

I found that you can still get this to work with services but it is missing in the documentation. I will see if I can add it to the migration document.

myservice = Target(
   script="myservice.py"
)

freeze(
   console = [myservice],
   version_info={'version':'1.0.0'}
)

from py2exe.

albertosottile avatar albertosottile commented on June 21, 2024

@caesimsol As you noted the feature does not work, it probably never worked properly with Python 3.x, and was officially dropped two major versions before. There is no workaround to build directly a COM server from py2exe, I am sure you can find some workaround to build a service starting from a console binary.

@mbokil Thanks for the workaround but, with this you would just build a console binary. Creating a service still requires extra work that has to be carried out manually with other tools. Therefore, I would advice not to add this in the documentation of py2exe.

from py2exe.

mbokil avatar mbokil commented on June 21, 2024

@albertosottile I think you might have misread the posters question. They wanted to know if the freeze API supports building a console based service. It clearly does support this feature I used it just the other day and then packaged up my project using Inno Setup and distributed the service to client Windows systems. I suggest keeping an example of building a console service like I listed above. It was hard to figure out how to do it with the freeze API but it definitely works. Thanks for you work on this project. I deployed my Windows service to 56K machines in our company. Zero reported defects.

from py2exe.

albertosottile avatar albertosottile commented on June 21, 2024

I am sorry, but I do not understand. What you are building is a console application, a binary that you can run from the terminal. What @caesimsol is asking for, and what the old service argument was doing is generating a Windows Service directly. py2exe does not support this anymore. However, you can of course build a console exe and pack it/deploy it as a service manually or with other tools, e.g. NSSM.

Freezing a console application is of course supported and, I think, well documented in the freeze API documentation https://github.com/py2exe/py2exe/blob/master/docs/py2exe.freeze.md . I am not sure in what your example differs from the existing documentation.

Thanks for you work on this project. I deployed my Windows service to 56K machines in our company. Zero reported defects.

Stories like these are always appreciated, Thank you for having reported this here.

from py2exe.

caesimsol avatar caesimsol commented on June 21, 2024

@albertosottile

I have to comment that with this definition in Python 3.10:

setup(
    data_files = Mydata_files,
    name='LimitLS',
    description = 'LIMIT License Server 2023',
    version=version_string,
    maintainer='CAE Simulation & Solutions GmbH',
    author='Michael Lindner, Svetoslav Inkolov',
    options={"py2exe": {"compressed": 1,
                          "optimize": 2,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
#                          "dll_excludes": dll_excludes_win_10,
                          "bundle_files": 3,
                          "dist_dir": "service",
                          "xref": False,
                          "skip_archive": False,
                          "ascii": False,
                          "custom_boot_script": '',
                         }
              },
    zipfile = 'limit_server.dll',
    version_info={'version':version_string,
                  'description':'LIMIT License Server 2023',
                  'product_name':'LimitLS',
                  'copyright':'© CAE Simulation & Solutions GmbH'},
    #windows=[{
    #console=[{
    service=[{
        'modules':'server'#,
        #'icon_resources':[(1, 'icon.ico')]
    }]

)

I got an service file named "server.exe" as a console module with a zipfile 'limit_server.dll' and it works perfectly fine.

The service was then installed with:

@echo off
set LLSDIR=%~dp0
service\server.exe -install
sc config LimitLS start= auto

In Python 3.11 this is unfortunately not possible anymore :'-(

from py2exe.

caesimsol avatar caesimsol commented on June 21, 2024

@albertosottile:

I just wanted to add that in Python 3.10 it was possible to set up or assign a value to the service parameter:

def patch_distutils():
import distutils.dist
import distutils.core
import distutils.command
import sys
from . import distutils_buildexe

class Distribution(distutils.dist.Distribution):

    def __init__(self, attrs):
        self.ctypes_com_server = attrs.pop("ctypes_com_server", [])
        self.com_server = attrs.pop("com_server", [])
        self.service = attrs.pop("service", [])
        self.windows = attrs.pop("windows", [])
        self.console = attrs.pop("console", [])
        self.isapi = attrs.pop("isapi", [])
        self.zipfile = attrs.pop("zipfile", "library.zip")

        distutils.dist.Distribution.__init__(self, attrs)

distutils.core.Distribution = Distribution

distutils.command.__all__.append('py2exe')

sys.modules['distutils.command.py2exe'] = distutils_buildexe

and in the Python 3.11 py2exe variant it is not possible anymore to assign anything to the service parameter:

console_targets = runtime.fixup_targets(console, "script")
for target in console_targets:
    target.exe_type = "console_exe"

windows_targets = runtime.fixup_targets(windows, "script")
for target in windows_targets:
    target.exe_type = "windows_exe"

# support the old dictionary structure with a global 'py2exe' key
if 'py2exe' in options:
    options = options['py2exe']

runtime_options = Namespace(
                    compress = options.get("compressed", 0),
                    unbuffered = options.get("unbuffered", 0),
                    optimize = options.get("optimize", 0),
                    includes = options.get("includes", []),
                    excludes = options.get("excludes", []),
                    packages = options.get("packages", []),
                    dll_excludes = options.get("dll_excludes", []),
                    bundle_files = options.get("bundle_files", 3),

                    script = console_targets + windows_targets,
                    service = [],
                    com_servers = [],

                    destdir = options.get("dist_dir", "dist"),
                    libname = zipfile,

                    verbose = options.get("verbose", 0),
                    report = False,
                    summary = False,

                    data_files = data_files,

                    version_info = {},

                )

from py2exe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.