How do I include non-.py files in PyPI?

2024/5/20 11:00:13

I am a newb to PyPI...so let me qualify with that. I am trying to put a package on PyPI but having a bit of trouble when I try to install it with pip. When I upload the file to PyPI, I get a warning (but the setup.py script finishes with not fatal errors and a 200 status):

'my_package/static/my_folder' not a regular file -- skipping

And then when I go to install it in pip, I get an error:

"error: can't copy 'my_package/static/my_folder': doesn't exist or not a regular file. 

From other answers on SO, I've tried changing up my MANIFEST.in and my setup.py files, with no luck. Here is my current MANIFEST.in:

recursive-include my_package *.css *.js *.jinja2

and setup.py:

try:from setuptools import setup, find_packages
except ImportError:from distutils.core import setup, find_packagessetup(name='my_package',packages=find_packages(),include_package_data=True,platforms='any',version='1.0',description='my_description',license='MIT',author='Me',author_email='[email protected]',install_requires=['Flask','Jinja2','requests',],url='http://www.example.com',download_url='https://github.com/me/my_package/tarball/1.0',classifiers=['License :: OSI Approved :: MIT License',],
)

EDIT: I've also tried leaving out the MANIFEST.in file just to see if that was messing anything up but I get the same result.

Answer

(Reposted from the comment on request.)

Your setup script and MANIFEST.in should work. To prove this with a minimal example:

my_project/my_package/static/a.css__init__.pyMANIFEST.insetup.py

Run python setup.py sdist and you'll find that both static/a.css and __init__.py are bundled in the tar.gz package.

https://en.xdnf.cn/q/72995.html

Related Q&A

How to create a custom AutoField primary_key entry within Django

I am trying to create a custom primary_key within my helpdesk/models.py that I will use to track our help desk tickets. I am in the process of writing a small ticking system for our office.Maybe there …

Multiple HoverTools for different lines (bokeh)

I have more than one line on a bokeh plot, and I want the HoverTool to show the value for each line, but using the method from a previous stackoverflow answer isnt working:https://stackoverflow.com/a/2…

Cant Install PIL 1.7

I have python 2.7.3 and I want to install PIL 1.7. I downloaded "PIL-1.1.7.win32-py2.7" and try to install it but it shows me an error messege that it cant find python 2.7 in the registry.&qu…

slice/split a layer in keras as in caffe

I have used this converter to convert a Caffe model to Keras. But one of my layers is of type slice and it needs to be converted as well but the converter currently does not support this and raises an …

Can I use regexes within datetime.strptime formats?

I have string values that contain a trailing time stamp. I thought I could use strptime with a regex pattern to extract those. Like:from __future__ import print_functionfrom datetime import datetime # …

Sort a list with longest items first

I am using a lambda to modify the behaviour of sort.sorted(list, key=lambda item:(item.lower(),len(item)))Sorting a list containing the elements A1,A2,A3,A,B1,B2,B3,B, the result is A,A1,A2,A3,B,B1,B2,…

Multivariate Root Finding in Python

Using excel solver, it is easy to find a solution (optimum value for x and y )for this equation: (x*14.80461) + (y * -4.9233) + (10*0.4803) ≈ 0However, I cant figure out how to do this in Python. The …

Python print not working when embedded into MPI program

I have an Python 3 interpreter embedded into an C++ MPI application. This application loads a script and passes it to the interpreter.When I execute the program on 1 process without the MPI launcher (s…

Detecting USB Device Insertion on Windows 10 using python

I cant get the following code for Detecting USB Device Insertion to work on my Windows 10 (64 bit) computer with Python 3.7.import win32serviceutil import win32service import win32event import servicem…

I get NotImplementedError when trying to do a prepared statement with mysql python connector

I want to use prepared statements to insert data into a MySQL DB (version 5.7) using python, but I keep getting a NotImplementedError. Im following the documentation here: https://dev.mysql.com/doc/con…