setuptools: adding additional files outside package
There is also data_files data_files=[(“yourdir”, [“additionalstuff/moredata.txt”, “INFO.txt”])], Have a think about where you want to put those files. More info in the docs.
There is also data_files data_files=[(“yourdir”, [“additionalstuff/moredata.txt”, “INFO.txt”])], Have a think about where you want to put those files. More info in the docs.
The way to address these deficiences is: Get the full path to the Python interpreter executing setup.py from sys.executable. Classes inheriting from setuptools.Command (such as setuptools.command.install.install which we use here) implement the execute method, which executes a given function in a “safe way” i.e. respecting the dry-run flag. Note however that the –dry-run option is … Read more
This is like using the src-layout for the “foo” and “bar” packages, but the flat layout for “baz”. It’s possible, but requires some custom configuration in the setup.py. Setuptools’ find_packages supports a “where” keyword (docs), you can use that. setup( … packages=( find_packages() + find_packages(where=”./bar-pack”) + find_packages(where=”./foo-pack”) ), … ) Since find_packages returns a plain … Read more
You have to list all packages in setup, including subpackages: setup( name = “mytestmodule”, version = “0.0.1”, description = (“A simple module.”), packages=[‘mymodule’, ‘mymodule.subdir’], ) Or you can use setuptools‘s magic function find_packages: from setuptools import setup, find_packages setup( name = “mytestmodule”, version = “0.0.1”, description = (“A simple module.”), packages=find_packages(), ) This is mentioned … Read more
What I ended up doing is: setup( name=”py_my_lib”, version=version, # specified elsewhere packages=[”], package_dir={”: ‘.’}, package_data={”: [‘py_my_lib.so’]}, ) This way I get to import the lib by its name, and don’t have another level of nestedness: import py_my_lib and not from py_my_lib_wrapper import py_my_lib
Late to the party, but never hurts to help fellow travellers down the namespace path in Python! #1: With the __init__.py, which of these should I be using (if any)?: It depends, There are three ways to do namespace packages as listed here: Use native namespace packages. This type of namespace package is defined in … Read more
I’d like to add a few notes on recent developments: PEP 518, first drafted in 2016, was marked as final in April of 2020. I’m interpreting it as an invitation to use pyproject.toml instead of setup.cfg. Quoting from the PEP: There are two issues with setup.cfg used by setuptools as a general format. One is … Read more
The standard pkgutil module’s get_data() function will calculate the path to your data, relative to your package, and retrieve the data for you via whatever module loader Python used to import the hermes package: import pkgutil data = pkgutil.get_data(‘hermes’, ‘templates/python.tpl’) Of course in certain cases you could just read your data using a path calculated … Read more
You could also try: pip install –upgrade setuptools as documented here https://askubuntu.com/questions/318824/how-to-solve-pkg-resources-versionconflict-error-during-bin-python-bootstrap-py/322701#322701
There is a new technique (Since version 19.1) called Direct references. Just pretend like your file is hosted on localhost. from setuptools import setup path_to_my_project = “/home/user/projects/my_package” # Do any sort of fancy resolving of the path here if you need to setup(# … other arguments install_requires=[f”my_package @ file://localhost/{path_to_my_project}#egg=my_package”] )