distutils “not a regular file --skipped”

2019-06-26 08:20发布

问题:

I have a very simple setup:

from distutils.core import setup

setup(name='myscripts',
      description='my scripts',
      author='Ago',
      author_email='blah',
      version='0.1',
      packages=['myscripts']
      )

myscripts folder consists of about 10 python files. Everthing works fine if I just execute my main.py file (executable, which uses those myscripts files). Now I try to do: python setup.py sdist

But I get:

running sdist
warning: sdist: missing required meta-data: url
reading manifest file 'MANIFEST'
creating myscripts-0.1
making hard links in myscripts-0.1...
'file1.py' not a regular file -- skipping
hard linking setup.py -> myscripts-0.1
'file2.py' not a regular file -- skipping
tar -cf dist/myscripts-0.1.tar myscripts-0.1
gzip -f9 dist/myscripts-0.1.tar
removing 'myscripts-0.1' (and everything under it)

Files file1.py and file2.py are as regular as other files. Any suggestions?

回答1:

(Already worked, reposting as a proper answer):

Try removing the "MANIFEST" file and re-running it. If you've moved files around, MANIFEST can be wrong (it gets regenerated automatically if it's not there).



回答2:

NOTE: I am new to setup.py, sdist, etc. and am working through exercise 46 in "learn python the hard way"-> So I don't yet know what I'm doing :) http://learnpythonthehardway.org/

I found this question because I was receiving the same error when trying to include a script. For whatever reason I don't have a "manifest" file (that I can find)--perhaps I'm using a different distutils version? I used pip to install "distribute".

The solution for me was to include the extension "*.py" with the script name. As:

...
'scripts': ['bin/testscript.py'],
...

While following http://docs.python.org/distutils/setupscript.html#installing-scripts it seemed like I shouldn't include the extension. So, I'm not sure what's up here, but it works for me as of now and the "not a regular file -- skipped" error went away.

This solved my problem. You can find my newbie code at: https://github.com/stevekochscience/Test-python-package-with-script-LPTHW-EX46 The README file explains what I did to test the package along with test script. Hope this helps other newbies who stumble across this question!



回答3:

In my case this error was caused by inadvertly running distutils with Python 2.7 instead of Python 3. The quick fix:

python3 setup.py register sdist upload

Better still, mark the script correctly:

sed -i '1i #!/usr/bin/python3' setup.py