Steve Sawyer
Steve Sawyer

Reputation: 1885

Why is my Python setup script failing?

I have a more complex project that I'm working on, and in an attempt to simplify things down to their essence to understand why things are failing, I made up the following project (the screen shot is from Eclipse)

This is the directory structure before running setup.py sdist Directory structure before running **setup sdist** Note that there are TWO projects here - the simple project (Deploy_Test) I'm using for testing the distribution process, and the common project containing the class and function packages that I expect to share across projects. On the right is the contents of my setup.py file

Here is the output from running setup.py sdist. Note the error line at the end called out by the red box: Output from running **setup.py sdist**

Here are the results. Note the empty folders created (again called out by the red boxes). On the right you can see the contents of the MANIFEST file created: Results from running **setup.py sdist**

My initial thought was that despite my referring to the referenced "classes" and "functions" packages in setup.py via the package_dir argument, that this was somehow causing a problem.

To test this, I copied and pasted the "classes" and "functions" packages into the Deploy_Test folder, removed the package_dir argument from setup.py, removed the MANIFEST file and empty folders, and re-ran setup.py sdist, and got similar results - the formerly "common" directory was missing, but the "classes" and "functions" directories now appear in the Deploy_Test-1.0 directory, but are still empty, as is the Deploy_Test subdirectory below Deploy_Test-1.0.

I also still got the same error "Incorrect function" error message. I still don't understand what it's trying to tell me with that.

Thanks for any advice on this...

After getting @Cartroo's advice on this, I re-ran the process with the same structure on my local HD (NTFS). The "Incorrect function" error was indeed avoided, but now something else is screwing things up. Here is the output from setup.py sdist

running sdist
running check
writing manifest file 'MANIFEST'
creating Deployment Test-1.0
creating Common
creating Common\classes
creating Common\functions
creating Deployment Test-1.0\Deploy_Test
making hard links in Deployment Test-1.0...
hard linking setup.py -> Deployment Test-1.0
hard linking ..\Common\classes\__init__.py -> Deployment Test-1.0\..\Common\classes
hard linking ..\Common\classes\fw_ftp.py -> Deployment Test-1.0\..\Common\classes
hard linking ..\Common\functions\__init__.py -> Deployment Test-1.0\..\Common\functions
hard linking ..\Common\functions\fw_date.py -> Deployment Test-1.0\..\Common\functions
hard linking ..\Common\functions\fw_db.py -> Deployment Test-1.0\..\Common\functions
hard linking ..\Common\functions\fw_file.py -> Deployment Test-1.0\..\Common\functions
hard linking ..\Common\functions\fw_file_io.py -> Deployment Test-1.0\..\Common\functions
hard linking ..\Common\functions\fw_string.py -> Deployment Test-1.0\..\Common\functions
hard linking Deploy_Test\Deploy_Test.py -> Deployment Test-1.0\Deploy_Test
hard linking Deploy_Test\__init__.py -> Deployment Test-1.0\Deploy_Test
creating dist
creating 'dist\Deployment Test-1.0.zip' and adding 'Deployment Test-1.0' to it
adding 'Deployment Test-1.0\PKG-INFO'
removing 'Deployment Test-1.0' (and everything under it)
error removing Deployment Test-1.0: Deployment Test-1.0\Deploy_Test\Deploy_Test.py: The system cannot find the file specified
error removing Deployment Test-1.0: Deployment Test-1.0\Deploy_Test\__init__.py: The system cannot find the file specified
error removing Deployment Test-1.0: Deployment Test-1.0\Deploy_Test: The directory is not empty
error removing Deployment Test-1.0: Deployment Test-1.0\setup.py: The system cannot find the file specified
error removing Deployment Test-1.0: Deployment Test-1.0: The directory is not empty

The only thing contained in dist/Deployment Test-1.0.zip is a single file: PKG-INFO All of the files that the errors claim can't be found all exist in the Deployment Test-1.0 directory. The Common project folders all were copied to their own subfolder below the /Deploy_Test folder, and the MANIFEST file appears to be correct (it includes all of the modules contained in the packages specified in setup.py)

Ha! Interesting! After going back to the USB drive and adding adding the two lines to setup.py suggested by @Cartroo, I got no errors - not even the errors that I was getting on my local HD about the files it couldn't find.

I'm not sure if I'm completely out of the woods yet, as the dist folder contains a zip file with only the Deploy_Test.py file within it. The process copied the Common/ folder to the Deploy_Test\ folder, and included a reference to the contents of the original Common/ folder (which exists collateral to the Deploy_Test folder) in the manifest file, but none of those modules got included into the dist folder, which I was expecting. However, considering I have no idea what a successful Python distribution looks like, I may be making an incorrect assumption

Upvotes: 2

Views: 2084

Answers (1)

Cartroo
Cartroo

Reputation: 4343

From memory that "incorrect function" error is a Windows-specific one which is pretty generic and usually indicates that you're doing something unsupported by the system.

I notice that the message just prior to the error is about hard linking - I wonder if this only works on some filesystems. I suggest checking if you're using NTFS - if not, perhaps see if it's possible to create a small NTFS partition to try the build on (perhaps on a USB drive).

If it is related to the hard linking then this bug may be relevant. If so, that would give you an easy thing to try - insert this right at the start of your setup.py and see if it helps (even before your first import):

import os
del os.link

Of course, this is based on a hunch and some vague memory of looking into that error for other reasons on Windows some time ago. However, at least inserting those two lines is something you can very easily attempt. I'm also not suggesting that this is a robust and portable way of fixing the issue, but at least whether it changes the error you're seeing might give you information about whether it's at least related.

Upvotes: 1

Related Questions