When i install software(XYZ) using setup.py file using command "python setup.py install" it copy only files present in parent directory to the folder present in site_packages/XYZ .in setup file i define all packages and data_files which i want to use. Software package structure
XYZ
__init__.py
main.py
test1.py
vector
__init__.py
vector1.py
vector2.py
exlib
__init__.py
lib1.py
lib2.py
when install using setup.py install command it copy only main.py,test1.py files in XYZ folder present in site_packages . i want to copy all files present in xyz folder when i run install command . how i modify setup file or any other way to do this.
It sounds like your setup.py needs to have:
packages=['vector', 'exlib'],
Related
I have the following directory structure:
/pythonlibraries
/libraryA
setup.py
libraryA/
__init__.py
alib.py
/libraryB
setup.py
libraryB/
__init__.py
blib.py
blib.py:
import libraryA
setup.py for libraryB:
from setuptools import setup
setup(name='libraryB',
version='0.0',
description='',
packages=['libraryB'],
install_requires=["ujson", "/pythonlibraries/libraryA"])
This doesn't work :/
How can I install local dependencies with pip?
Ideally I'd like to do pip install -e /pythonlibraries/libraryB and have it automatically install libraryA from my local disk.
Right now I have to install each local library individually manually...
Did you try to write full path like this
install_requires=["ujson", "/home/user/pythonlibraries/libraryA"])
Because "/" --> this is absolute directory
I've restructured a project to the src directory structure. It looks like this:
root_dir/
src/
module1/
__init__.py
script1.py
script2.py
module2/
__init__.py
other_script1.py
other_script2.py
conftest.py
setup.py
tests/
conftest.py
some_tests/
conftest.py
test_some_parts.py
some_other_tests/
conftest.py
test_these_other_parts.py
My setup.py looks like this:
setup(
name='Project',
version=0.0,
author='Me',
install_requires=['pyodbc'],
tests_require=['pytest'],
setup_requires=['pytest-runner'],
test_suite='root_dir.Tests',
entry_points={
'console_scripts': ['load_data = module1.script1:main']
},
package_data={'Config': ['*.json']},
packages=find_packages('src'),
package_dir={'': 'src'})
I am running Anaconda3 on Windows 10. When I run python setup.py install, I am able to run the load_data script without any issue. However, from what I've been reading, it is preferable to use pip install . vice python setup.py install. When I pip install the package and attempt to run load_data, I get ModuleNotFoundError: No module named 'module1.script1'. I've attempted adding 'src' to the front of this, but this doesn't work either. I don't understand what the differences are or how to troubleshoot this.
When building the source distribution for the package not all files are included. Try creating a MANIFEST.in file with
recursive-include src/module1 *
Following is the folder structure:
Utility/utils/__init__.py, wrapper, auditory.py
/setup.py
I have been trying to install utils as site-package in python by running "python setup.py install"
When I go and check the site-package, there is a egg file which has my utils folder and egg-info.
But it should create my utils folder inside site-packages right?
Am I missing something here?
from setuptools import setup
setup(
name='utils',
version='0.1',
packages=['utils'],
license='Internal use only',
zip_safe = False
)
Ideally it should place the utils folder inside site-packages and egg-info inside egg file.
so that utils package would be available similar to and pandas
I am designing a python project like this:
packages/
__init__.py
setup.py
requierment.txt # Require package1
commons/
__init__.py
setup.py
requirement.txt
Common_module.py
package1/
__init__.py
setup.py
requirement.txt # Require commons
Package1_module.py
When I do pip install -r requierment.txt -t ./installation, I would like it to create a folder installation in which I have package1 and commons but it seems that it doesn't resolve the dependencies of package1 leaving the installation with package1 only.
How can I resolve dependencies recurcively?
After some research I found that requierment.txt should list all dependencies but I really don't want that.
So I tried the following:
from distutils.core import setup
required = []
with open('requirements.txt') as f:
for line in f.readline():
if not line.startswith('#'):
required.append(line.rstrip())
setup(...
install_requires=required)
But now, it looks for my dependencies on the Internet and not in my folder even if required is a list of local paths.
It's a simplified view of my issues, I can change my project achritecture a bit but let assume that the first requirement.txt cannot know the dependencies of the sub packages (like the commons package).
Is there a nice way to resolve the dependencies recurcively?
Thanks!
I have a python project with the following structure:
/project
/bin
executable
/app
__init__.py
a.py
b.py
c.py
From within the /project directory I try to run the executable, which depends on modules in the app package:
./bin/executable
However, when I try this, python fails to find any modules defined in the app package, giving the ImportError: No module named XYZ error.
From what I understood, the presence of __init__.py in the app directory should mark it as a module?
What am I doing wrong?
If you add the following to your executable (before you try importing your app module):
import sys; print sys.path
...
import app
You'll see that the current working directory is not included in the path. I suggest you create a proper Python package by adding a setup.py file. You can then install your package and your executable should work just fine.
Here is a simple setup.py file:
from setuptools import find_packages, setup
config = {
'name': 'app',
'version': '0.1.0',
'description': 'some app',
'packages': find_packages(),
}
setup(**config)
I prefer to install into a virtualenv:
virtualenv venv
source venv/bin/activate
python setup.py install
./bin/executable
Now, if you deactivate that virtualenv and try running your executable again, you will get your original ImportError.
Take a few minutes and read through the Python Packaging User Guide.
Also, you might want to use python setup.py develop instead of python setup.py install.