python-packaging

How to easily create python package, keeping the folder structure and files?

空扰寡人 提交于 2020-02-25 05:49:49
问题 I have a folder with structure like this (names are not real): script0_1.py script0_2.py - folder1 - folder1_1 - script1_1_1.py - script1_1_2.py - folder1_2 - script1_2_1.py - script1_2_2.py - folder2 - script2_1.py - folder3 ... Important moment is that the structure can be changed, scripts added, etc. I want to create a package, to be able to run commands like this my_package.folder1.folder1_1.script1_1_1.some_func() , easily. I know a bit that I can create __init__.py in each folder, then

Cython C-level interface of package: *.pxd files are not found

依然范特西╮ 提交于 2020-02-04 01:46:38
问题 In a nutshell I try to compile a cython extension called extension2 that cimports a file extension from a self-created package. When building extension2 , I get the error that extension.pxd is not found though this file is exactly at the sepcified path. Details I am building two packages involving cython, a package A and a package B that depends on A . A is a subpacke of a namespace package nsp . That is, the folder structure looks as follows: ├── nsp │ └── A | ├── extension.pxd | ├──

Resolve conflicting package names in Python

元气小坏坏 提交于 2020-01-30 03:54:48
问题 Let's say we have two different Python packages from the same vendor, named with the same name -- foo . One is installed with pip and can be found in the /usr/lib/python/site-packages/foo directory, the second one is a system-wide dependency which you install with e.g. apt-get and the Python package ends up in /usr/lib/some-vendor-sdk/foo . Local and global foo do different things and I need them both to be importable in my source code, but I can only import one: $ python >>> import foo >>>

Package spacy model

≯℡__Kan透↙ 提交于 2020-01-28 11:25:25
问题 I want to include the spacy model de_core_news_sm in a python package. Here is my project: https://github.com/michaelhochleitner/package_de_core_news_sm . I package and install the project with the following commands. python setup.py sdist bdist_wheel pip install dist/example-pkg-mh-0.0.1.tar.gz I want to import the module example_pkg.import-model.py . $ python >>> import example_pkg.import_model Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mh

Python - fails importing package

喜夏-厌秋 提交于 2020-01-23 17:18:47
问题 I have trouble importing package. My file structure is like this: filelib/ __init__.py converters/ __init__.py cmp2locus.py modelmaker/ __init__.py command_file.py In module command_file.py I have a class named CommandFile which i want to call in the cmp2locus.py module. I have tried the following in cmp2locus.py module: import filelib.modelmaker.command_file import modelmaker.command_file from filelib.modelmaker.command_file import CommandFile All these options return ImportError: No modules

Anaconda/Python site-packages subfolders with tilde in name - what are they?

﹥>﹥吖頭↗ 提交于 2020-01-23 07:52:26
问题 Today, I went to change the config of matplotlib. Searching matplotlibrc revealed I have two of them: Looking at the site-packages folder, I found a lot of packages have a tilde in their name: ~klearn is sklearn , but there is another sklearn . ~atplotlib is matplotlib too, changed date is 2018-11 ~-tplotlib 's changed date is 2019-3.15 matplotlib 's changed date is 2019-3.28 (I did update matplotlib recently) What are these tilde name packages used for? Can I delete them safely? 回答1: Is it

Is there a way to import a python package from another python package, as if it was part of the same code?

五迷三道 提交于 2020-01-16 14:01:47
问题 Let's say that we have python packages package_a and package_b . As a user, I want to be able to say: from package_a.package_b import some_functionality My question is: is there a way to support this without literally copy-pasting the code of package_b to package_a ? EDIT 1: To clarify, I have shadow naming (my python package is named the same way as my folder), and I am wondering if there was a way to make the python package available somewhere else. And yes, I'm looking into ways how to

Python Packaging multiple subpackages with different data directories

独自空忆成欢 提交于 2020-01-15 12:03:12
问题 I have a structure of the directory as such with foobar and alphabet data directories together with the code something.py : \mylibrary \packages \foobar foo.zip bar.zip \alphabet abc.zip xyz.zip something.py setup.py And the goal is such that users can pip install the module as such: pip install mylibrary[alphabet] And that'll only include the data from the packages/alphabet/* data and the python code. Similar behavior should be available for pip install mylibrary[foobar] . If the user

Python Packaging multiple subpackages with different data directories

别说谁变了你拦得住时间么 提交于 2020-01-15 12:02:52
问题 I have a structure of the directory as such with foobar and alphabet data directories together with the code something.py : \mylibrary \packages \foobar foo.zip bar.zip \alphabet abc.zip xyz.zip something.py setup.py And the goal is such that users can pip install the module as such: pip install mylibrary[alphabet] And that'll only include the data from the packages/alphabet/* data and the python code. Similar behavior should be available for pip install mylibrary[foobar] . If the user

Add folders and subfolders outside of main module using setuptools(setup.py)

我只是一个虾纸丫 提交于 2020-01-14 03:32:14
问题 So it is yet another similar looking but different question than setuptools: adding additional files outside package and Including non-Python files with setup.py. I have structure very similar to that of first question -module -python_file1.py -python_file2.py -folder -subfolder1 -data_file_1.txt -subfolder2 -data_file_2.txt What I want: I want to install the packages along with the folder,subfolders and files within them. What I tried: Approach_1: If I move the folder inside the module then