I tried to create executable of my File NewExistGUI2.py, where GUI is made using wxpython. The file depends upon other two files localsettings.py and Tryone.py. I referred to py2exe documentation, and created a setup.py file as:
from distutils.core import setup
import py2exe
setup(name = 'python eulexistdb module',
version = '1.0',
description = 'Python eXistdb communicator using eulexistdb module',
author = 'Sarvagya Pant',
py_modules = ['NewExistGUI2','localsettings','Tryone']
)
and compiled the program in command line using
python setup.py py2exe
But I didn't got any .exe file of the main program NewExistGUI2.py in dist folder created. What Should I do now?
I woul recommend you create a module (ExistGUI) with the following structure:
ExistGUI
\_ __init__.py
|_ localsettings.py
|_ Tryone.py
bin
\_ NewExistGUI2.py
Your init.py should have:
from . import localsettings, Tryone
__version__ = 1.0
Your setup.py should look something like:
from setuptools import setup, find_packages
import ExistGUI
import py2exe
setup(
name = 'ExistGUI',
version = ExistGUI.__version__,
console=['bin/NewExistGUI2.py'],
description = 'Python eXistdb communicator using eulexistdb module',
author = 'Sarvagya Pant',
packages= find_packages(),
scripts=['NewExistGUI2.py',],
py_modules = ['localsettings','Tryone'],
include_package_data=True,
zip_safe=False,
)
Then run python setup.py py2exe. Make sure you include any requirements for your module in setup.py. Also, remove the previously generated dist directory, just to be sure.
Hope this helps.
Related
I'm trying to distribute a personal python package over PyPi. While it successfully pip installs, there's a ModuleNotFound error when I go to import PythonDebuggerTools locally.
setup.py
from setuptools import setup, find_packages
import codecs
import os
import setuptools
VERSION = '0.0.3'
DESCRIPTION = 'Debugging tools'
LONG_DESCRIPTION = 'A package that gives users access to several debugging functionality to make their development process efficient.'
# Setting up
setup(
name='PythonDebuggerTools',
version=VERSION,
author='Aakash Haran',
author_email='email',
description='Testing installation of Package',
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
url='https://github.com/Luna-Cake/Logger',
license='MIT',
# packages=setuptools.find_packages(),
py_modules=['PythonDebuggerTools'],
install_requires=[],
)
My project structure looks like this:
>build
>dist
>PythonDebuggerTools-0.0.3.tar.gz
>PythonDebuggerTools
>__init__.py
>logger.py
>PythonDebuggerTools.egg-info
>dependency_links.txt
>PKG-INFO
>SOURCES.txt
>top_level.txt
>README.md
>setup.py
>setup.py~
=======
Any help would be greatly appreciated!
py_modules=['PythonDebuggerTools'],
is for *.py files. There is no PythonDebuggerTools.py so nothing was added to the wheel package.
Your PythonDebuggerTools is an importably directory so declare it as a packge:
packages=['PythonDebuggerTools'],
See https://packaging.python.org/tutorials/packaging-projects/
I would like to compile a Python3 project with cx_Freeze, but no matter what I do I can never import my own .py files.
Here's my directory structure:
projectname/
setup.py
app/
code/
__init__.py
config.py
run.py
run - editeur.py
...
image/
...
level/
...
My setup.py :
import sys, os
from cx_Freeze import setup, Executable
path = sys.path
includes = []
excludes = []
packages = ["app/code"]
includefiles = ["app/image", "app/level"]
optimize = 0
silent = True
options = {"path": path,
"includes": includes,
"excludes": excludes,
"packages": packages,
"include_files": includefiles,
"optimize": optimize,
"silent": silent
}
base = Win32GUI
cible_1 = Executable(
script="app/code/run.py",
)
cible_2 = Executable(
script="app/code/run - editeur.py",
)
setup(
name="project",
version="1.0",
description="blabla",
options={"build_exe": options},
executables=[cible_1, cible_2]
)
The cx_Freeze compilation is going well and I get my 2 executables.
But when I try to launch one, every time I get the same error:
[...]
File "app/code/run.py", line 7, in <module>
import config
ImportError: No module named 'config'
I really have to miss something stupid since I have no problem with the plug-ins.
It may also be a problem of path or something else I don't know...
Anyone know how to help me a little ? Thanks !
EDIT: I've managed to freeze a simplified example based on your directory structure with the following modification of the setup.py script:
path = sys.path + ['app/code']
packages = []
Alternatively, you could also try the following structure (modifying the import paths accordingly):
projectname/
setup.py
config.py
run.py
run - editeur.py
...
image/
...
level/
...
I have a directory with a lot of *.py files (scripts) and subdirs with *.py files.
How to add all *.py files from root directory to the package?
Now my setup.py is
from setuptools import setup, find_packages
setup(
name='my-awesome-helloworld-script', # This is the name of your PyPI-package.
version='0.1', # Update the version number for new releases
scripts=['????????????????????'], # The name of your scipt, and also the command you'll be using for calling it
# Packages
packages=find_packages(),
)
As you can see, I've solved addition question of folders with find_packages().
But how to add *.py files from root directory?
I am packaging with command python.exe setup.py sdist.
Thank you!
Solved with code:
from setuptools import setup, find_packages
pckgs=find_packages()
pckgs.append('.')
setup(
name='my-awesome-helloworld-script', # This is the name of your PyPI-package.
version='0.1', # Update the version number for new releases
# scripts=[''], # The name of your scipt, and also the command you'll be using for calling it
# Packages
packages=pckgs,
)
I have python module, named models.py which i would like to upload to PyPi. When afterwards i install it using pip i would like it to appear as a package.
To explain myself, I have following project structure:
my_utils
mapper/
models.py
MANIFEST.in
setup.py
README
logger/
logger.py
logger_conf.json
MANIFEST.in
README
setup.py
I would like to create a distributed package out mapper.models, but when it is being installed on target machine, i would like it to appear in site-packages under mapper_tools.models.
My setup.py:
from distutils.core import setup
setup(
name='mapper_tools',
version='0.1.0',
description='some description',
author='myname',
author_email='my#email.com',
url='https://github.com/mapper-tools',
py_modules=['models'],
)
My MANIFEST.in:
include models.py README
Currently, after running pip install mapper-tools, I find models.py right under site-packages and I would like it to appear under mapper_tools.
Can i specify the structure that should be installed without changing the layout of my project?
I have a python package "trees", which contains myscript.py file which makes use of a fortran subroutine.
Normally I compile the fortran module with
f2py -c -m calctree calctree.f90
and I can then do
from trees import myscript
myscript.mysub()
which makes use of calctree.so
If I package everything with distutils by running
python ./setup.py sdist
where the contents of setup.py are
#! /usr/bin/env python
from distutils.core import setup
setup(name='trees',
version='0.1',
packages=['trees']
)
and specify "include trees/calctree.f90" in a MANIFEST.in file, I can include the .f90 file, but I don't know how to make it compile with f2py on the user's computer, and have the .so file placed in an appropriate place. Can anybody help?
Thank you!
You want to use the numpy.distutils.core module which has its own setup function.
Your setup.py should look something like this (assuming the fortran files are in the directory named trees),
import numpy.distutils.core
import setuptools
# setup fortran 90 extension
#---------------------------------------------------------------------------
ext1 = numpy.distutils.core.Extension(
name = 'calctree',
sources = ['trees/calc_tree.f90'],
)
# call setup
#--------------------------------------------------------------------------
numpy.distutils.core.setup(
name = 'trees',
version = '0.1',
packages = setuptools.find_packages(),
package_data = {'': ['*.f90']},
include_package_data = True,
ext_modules = [ext1],
)
That should be a start at least.